r_frame_rate vs. avg_frame_rate: The Two ffprobe Numbers Behind Stutter, Drift, and Wrong Frame Counts
If you have ever opened a screen recording in an editor and watched it stutter, or written a frame-count assumption like duration * fps and gotten a number that was off by half, the file was probably not lying about its resolution or its codec. It was lying about its frame rate - or more precisely, it had no single frame rate at all.
Screen recorders and phone cameras produce variable frame rate (VFR) video under common conditions: mobile encoders skip frames when nothing changes on screen, or when the device is busy, so recorded frames land on irregular timestamps. Players don't care. Everything downstream that assumes frames arrive at fixed intervals - editors, frame-accurate trimming, ffmpeg filters that count frames, ML pipelines that sample "every Nth frame" - does care.
This post is a short diagnostic recipe: two ffprobe fields to read, one command to confirm what you're dealing with, and what to do about it. Everything below was run locally on macOS 15.4.1 with ffmpeg 8.0.1 on synthetic test clips, so the numbers are real outputs, but the clips are generated patterns rather than phone footage.
Where the second number comes from
Ask ffprobe about almost any video and you'll see two frame-rate fields that look redundant:
ffprobe -v error -select_streams v:0 \
-show_entries stream=codec_name,r_frame_rate,avg_frame_rate,nb_frames,duration \
-of default=nw=1 input.mp4
For a well-behaved constant frame rate (CFR) file, this prints:
codec_name=h264
r_frame_rate=30/1
avg_frame_rate=30/1
duration=6.000000
nb_frames=180
The two fields are not duplicates. Per the ffprobe documentation, r_frame_rate is the base rate that can represent every timestamp in the stream - the fastest clock the container needs. avg_frame_rate is effectively total frames divided by duration.
On a CFR file they match, because frames really do land every 1/30th of a second. On a VFR file they drift apart, because the encoder recorded fewer frames than the time axis implies.
A five-minute diagnosis
To have a known VFR file to test against, I generated a 6-second 30 fps clip and then re-encoded it while keeping only irregularly spaced frames (every 2nd frame for the first two seconds, every 5th after that), preserving original timestamps:
ffmpeg -i cfr.mp4 \
-vf "select='not(mod(n,2))*lt(n,60)+not(mod(n,5))*gte(n,60)'" \
-fps_mode vfr -c:v libx264 -pix_fmt yuv420p -c:a copy vfr2.mp4
The same ffprobe command now reports:
r_frame_rate=30/1
avg_frame_rate=162/17
duration=5.666667
nb_frames=54
162/17 is about 9.53. The stream still claims 30 fps at the codec level, but 54 frames spread over 5.67 seconds averages 9.53 - a 3× gap between the two numbers. That gap is your first red flag.
The mismatch alone isn't proof, though. To confirm, measure the actual gaps between frame timestamps:
ffprobe -v error -select_streams v:0 \
-show_entries frame=best_effort_timestamp_time \
-of csv=p=0 vfr2.mp4 \
| awk -F, 'NR==1{p=$1;next}{d=$1-p;p=$1;s+=d;n++; if(min==""||d<min)min=d; if(d>max)max=d} END{printf "intervals=%d min=%.4f max=%.4f mean=%.4f\n",n,min,max,s/n}'
Output for the VFR file:
intervals=53 min=0.0667 max=0.1667 mean=0.1101
Gaps ranging from 1/15th to 1/6th of a second - a 2.5× spread - is variable frame rate, confirmed.
One honest counter-example, because I hit it while building this test: a clip that drops every 3rd frame uniformly reports r_frame_rate=10/1 and avg_frame_rate=900/89 (≈10.11). The numbers mismatch, but measuring the intervals shows a constant 0.1000s gap - that file is CFR at 10 fps with cosmetic metadata noise, and it will behave fine.
So treat the mismatch as a reason to run the interval check, not as a verdict on its own. As a rule of thumb from these samples: mismatch plus a wide min/max interval spread means VFR; mismatch with a tight spread means a rescaled-but-regular stream.
What actually breaks downstream
With VFR confirmed, here is what it explains:
- Editors that assume a CFR timeline snap every frame to a fixed grid, so irregular gaps become repeated or dropped frames - visible as rhythmic stutter, especially on pans and scrolling text.
- Audio drift accumulates when an editor stretches video to fill a CFR timeline while the audio track keeps its real clock.
- Frame-index math fails.
frame_number / fpsstops equaling the presentation timestamp. Anything that seeks "to frame 450" or samples "every 30th frame" lands on unpredictable moments. - Frame counts don't match duration. 54 frames ≠ 5.67 s × 30, and pipelines that validate that invariant reject or corrupt files.
None of this is corruption. The file is a faithful recording of irregular timing; the tools around it just assumed regularity.
Normalizing to constant frame rate
The fix is a re-encode that redistributes existing frames onto a fixed grid:
ffmpeg -i vfr2.mp4 -vf "fps=30" -fps_mode cfr \
-c:v libx264 -crf 18 -pix_fmt yuv420p \
-c:a aac -b:a 160k fixed2.mp4
Verified output:
r_frame_rate=30/1
avg_frame_rate=30/1
duration=5.866016
nb_frames=176
intervals=175 min=0.0333 max=0.0333 mean=0.0333
Uniform 1/30th-second intervals - the downstream stutter and frame-math problems go away.
Two caveats from the same run:
- Normalization is not quality recovery. Going from ~9.5 fps of real frames to 30 fps duplicates frames; motion is smoother on a fixed grid but no new detail appears. Pick the output rate based on what the source actually contains, not the highest number you can type. Re-encoding at
-crf 18also means this is lossy, like any re-encode. - Watch the A/V tail. In my sample, the CFR output's video stream measured 5.866s while the audio measured 6.014s - about 148ms of audio hanging past the last frame, a side effect of grid alignment. Add
-shortestif you need the streams to end together, or trim in the editor.
Re-run the interval check on the output. It should come back with a tight spread before you hand the file to anything downstream.
If you don't want to install ffmpeg
The same normalization exists without a terminal. A browser-based converter like VideoBee's video converter lets you set an explicit output frame rate and resolution, with batch conversion for a pile of clips, files up to 5 GB per file, no account required, and - per its product page - result files deleted within 24 hours of processing.
Set the target frame rate, download, and then run the same ffprobe interval check on the output - the verification step is the same regardless of which tool did the conversion. (Full disclosure: I write content for VideoBee, which is why it's the tool linked here; the diagnostic workflow above works with any converter that lets you pin an output frame rate.)
A short checklist
- ffprobe both frame-rate fields. A large mismatch means: keep digging.
- Measure frame-interval spread. Wide spread confirms VFR.
- Re-encode to a constant rate appropriate to the source's real content, not higher.
- Re-verify intervals on the output, and check that audio and video durations still line up.
The whole loop costs a couple of minutes per file, and it's much cheaper than discovering the problem as mysterious stutter in a client review.
Comments
No comments yet. Start the discussion.