<p>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.</p>

<p>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.</p>

<p>That ffprobe command is</p>

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

CC BY-SA 4.0
2018-05-11T18:08:50.960Z
Thank you, @Gyan. This is a lot of command line! Can you elaborate on the output format `compact=p=0:nk=1`?
iter
CC BY-SA 4.0
2018-05-11T18:22:38.107Z
compact -> no linebreaks within a section; p=0 -> no section titles; nk=1 -> no key labels
Gyan
CC BY-SA 4.0
2018-05-11T06:26:00.337Z
2018-05-11T15:13:41.057Z
2018-05-11T15:13:41.057Z
Gyan
<p>I'm trying to burn timecode onto a video file with ffmpeg. <a href="https://ffmpeg.org/ffmpeg-filters.html#drawtext" rel="nofollow noreferrer">Documentation</a> notes that frame rate is a required parameter. It confuses me that I need to specify it manually when the information is available for the source file. This confusion suggests I'm missing an important assumption.</p>

<p>I'm batch-processing source files with different frame rates depending on their source (24, 29.97, 30). How can I set the frame rate automatically?</p>

<ffmpeg>
ffmpeg drawtext timecode source framerate
iter
# ffmpeg drawtext timecode source framerate

(Asked by: username_0 on 2018-05-11)

I'm trying to burn timecode onto a video file with ffmpeg. [Documentation](https://ffmpeg.org/ffmpeg-filters.html#drawtext) notes that frame rate is a required parameter. It confuses me that I need to specify it manually when the information is available for the source file. This confusion suggests I'm missing an important assumption.

I'm batch-processing source files with different frame rates depending on their source (24, 29.97, 30). How can I set the frame rate automatically?

**Tags:** ffmpeg


---

## 1 answers

### Answer by username_1 on 2018-05-11. Score: 1 | Accepted answer

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")

> **Comments:**
> **username_0**: Thank you, @username_1. This is a lot of command line! Can you elaborate on the output format `compact=p=0:nk=1`?  
> **username_1**: compact -> no linebreaks within a section; p=0 -> no section titles; nk=1 -> no key labels  

---

