[FFmpeg-user] Recording a video when framerate is unknown before recording starts

Andrey Utkin andrey.krieger.utkin at gmail.com
Fri Feb 24 12:04:16 CET 2012


2012/2/24 John Dexter <jdxsolutions at gmail.com>:
> I am dynamically recording the output of a 3D rendering app to video.
> Although we seek a locked framerate of 30fps, on slower PCs it can be
> less (it IS pretty constant). As each frame is rendered, it is passed
> into ffmpeg as the next video frame.
>
> So this raises an issue recording video - until we start recording we
> don't know what the fps will be. I don't know enough about ffmpeg to
> know if the fps is just a value in a header, or is baked into how
> every frame is stored - so any advice or tips or discussion on how to
> handle this are welcome. If we assume my fps is stable but not known
> in advance, what can/should I do?
>
> I'm using libav programatically, not using the ffmpeg command-line
> tool(s). Should this be on the dev list instead?

When you create the frame, you set the timestamp to it, by yourself.
For simplicity of example, let output codec's and format's timebases
be 1/1000 (one timestamp tick is 1/1000 of second).
You should decide, what the framerate will be. E.g., frame_rate = 20.
Then, you can create a variable like timestamp_step = 1000/frame_rate.
For first output frame, set timestamp to 0.
For next, set it to previous frame's timestamp + timestamp_step.

-- 
Andrey Utkin


More information about the ffmpeg-user mailing list