How to Use FFmpeg vfrdet to Detect VFR Video
The vfrdet (Variable Frame Rate Detector) filter in
FFmpeg inspects the presentation timestamps (PTS) of a video stream to
determine whether frames are displayed at constant or varying intervals.
This guide explains how to construct and execute the vfrdet
command, how to suppress unnecessary log output, and how to read the
resulting metrics to reliably identify variable frame rate (VFR)
streams.
The Basic Command
To scan a video file with vfrdet, apply the filter using
-vf and route the output to the null muxer
(-f null -) so FFmpeg decodes the frames without
re-encoding or saving a file:
ffmpeg -i input.mp4 -vf vfrdet -f null -Isolating the Detection Result
FFmpeg outputs detailed processing statistics by default. You can
filter the terminal output to show only the lines generated by the
vfrdet filter.
On Linux or macOS:
ffmpeg -i input.mp4 -vf vfrdet -f null - 2>&1 | grep "Parsed_vfrdet"On Windows (Command Prompt):
ffmpeg -i input.mp4 -vf vfrdet -f null - 2>&1 | findstr "Parsed_vfrdet"On Windows (PowerShell):
ffmpeg -i input.mp4 -vf vfrdet -f null - 2>&1 | Select-String "Parsed_vfrdet"Understanding the Output
At the end of processing, vfrdet outputs a summary
formatted like this:
[Parsed_vfrdet_0 @ 0x7fa890404dc0] VFR:0.000000 (0/1199) min: 40 max: 40 avg: 40
or:
[Parsed_vfrdet_0 @ 0x7fa890404dc0] VFR:0.425000 (510/1200) min: 20 max: 80 avg: 40
Each metric represents a specific aspect of the stream's frame timing:
- VFR Ratio: The decimal number immediately following
VFR:represents the proportion of frames that deviate from the expected constant duration.0.000000: The file is strictly Constant Frame Rate (CFR).> 0.000000: The file contains variable frame intervals and is considered VFR.
- Frame Counts
(X/Y):X: The number of frames detected with irregular durations.Y: The total number of frames evaluated.
- min / max / avg: The minimum, maximum, and average
durations between consecutive frame timestamps in timebase units. If
min,max, andavgare identical, the pacing between every frame is completely uniform.
Converting VFR to CFR
If the vfrdet filter reports a VFR value greater than
zero and your workflow requires constant timing (such as in non-linear
video editors), you can force a constant rate using the fps
filter:
ffmpeg -i input.mp4 -vf "fps=30" -c:v libx264 -crf 18 -c:a copy output.mp4Replace 30 with your desired target frame rate. FFmpeg
will drop or duplicate frames as necessary to maintain exact, uniform
intervals.