ffmpeg drawtext timecode source framerate
FFmpeg has a modular design. The module which unpacks a stream from a file and discovers/sets its properties, including framerate, is ffmpeg base code. drawtext is a filter module that operates upon decoded frames. It has no concept of a framerate because it receives a sequence of individual frames in series, and only gets to see the metadata pertaining to that frame.

Usual M.O. when performing such operations is to get the framerate information by running ffprobe beforehand and saving it to a variable, referencing that variable in the drawtext options so that the shell can substitute the value.

That ffprobe command is

FPS=$(ffprobe -v 0 -show_entries stream=r_frame_rate -select_streams v:0 -of compact=p=0:nk=1 "$file")