-
Notifications
You must be signed in to change notification settings - Fork 19
Variable Frame Rate
FFMPEG has introduced a new filter in FFMPEG 4.0 called vfrdet
. Using this filter you can easily check if the video is with CFR (constant frame rate) or VFR (variable frame rate). The syntax of the command is:
ffmpeg -i input.mp4 -vf vfrdet -f null -
And the output of this command should give you an idea whether you have any deviation of the frame duration or not. This is an exemplary output of the above mentioned command:
[Parsed_vfrdet_0 @ 0x56518fa3f380] VFR:0.400005 (15185/22777) min: 1801 max: 3604)
It means that 15818 frames have variable frame rate and 22777 have constant bitrate, and 40.005% of all the frames in the video (1585 + 22777 = 37962) have variable frame rate. If there was frames with variable delta, than it will also show min and max delta encountered.
NUT is a low overhead generic container format. It stores audio, video, subtitle and user-defined streams in a simple, yet efficient, way. It was created by a group of FFmpeg and MPlayer developers in 2003 and was finalized in 2008. It provides exact timestamps for synchronization and seeking, is simple, has low overhead and can recover in case of errors in the stream. It supports both uncompressed and also compressed video/audio encoding formats.
There are two variants of this container format:
- broadcast - extends the syncpoint to report the sender wallclock
- pipe - omits completely the syncpoint
The broadcast variant provides a secondary time reference to facilitate detecting endpoint latency and network delays. The syntax is the following:
CFR video files:
ffmpeg -i input.mp4 -c:v videocodec -vsync 0 -enc_time_base 1/1000 output.nut
-enc_time_base[:stream_specifier] timebase (output,per-stream)
Set the encoder timebase. timebase is a floating point number, for video - use 1/framerate, for audio - use 1/samplerate this variable can assume one of the following values:
- 0 - assigns a default value according to the media type.
- -1 - use the input stream timebase when possible. If an input stream is not available, the default timebase will be used.
- greater than 0 - Use the provided number as the timebase.
This field can be provided as a ratio of two integers (e.g. 1:24, 1:48000) or as a floating point number (e.g. 0.04166, 2.0833e-5).
The -vsync 0
tells ffmpeg that the output should be also CFR.
In case of VFR input video and that you want to convert it to CFR you can use the following syntax:
ffmpeg -i input.mp4 -c:v videocodec -vsync 0 -vf setpts=N/FRAME_RATE/TB output.nut
This will preserve all the frames in the output file and will create a CFR ouput.nut file fixing all delta PTS deviations.