1

I'm trying to burn timecode onto a video file with ffmpeg. Documentation 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?

1

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")
  • Thank you. I'm reading through ffprobe documentation, and there's a lot. Is there an ffprobe command line I can put in backticks that would pull the frame rate out of the file? – iter May 11 '18 at 14:55
  • 1
    Added command.. – Gyan May 11 '18 at 15:13
  • Thank you, @Gyan. This is a lot of command line! Can you elaborate on the output format compact=p=0:nk=1? – iter May 11 '18 at 18:08
  • 1
    compact -> no linebreaks within a section; p=0 -> no section titles; nk=1 -> no key labels – Gyan May 11 '18 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.