2

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?

0

1 Answer 1

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")
2
  • Thank you, @Gyan. This is a lot of command line! Can you elaborate on the output format compact=p=0:nk=1?
    – iter
    Commented May 11, 2018 at 18:08
  • 1
    compact -> no linebreaks within a section; p=0 -> no section titles; nk=1 -> no key labels
    – Gyan
    Commented May 11, 2018 at 18:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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