[FFmpeg-user] Recording a video when framerate is unknown before recording starts
jdxsolutions at gmail.com
Fri Feb 24 12:20:28 CET 2012
On 24 February 2012 11:04, Andrey Utkin <andrey.krieger.utkin at gmail.com> wrote:
> 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.
Does that mean videos can also have variable framerate? I always (I
don't know why) assumed framerate was a property of the video itself.
When you say "set the timestamp to it, by yourself" can you point me
which struct/field/function I use for this? Is it something to do with
AVFrame, or maybe we're looking at pts/dts on AVPacket?
More information about the ffmpeg-user