joeycato
joeycato

Reputation: 128

Why does doubling the frame rate generate inconsistent frames?

So I have a constant 59.94 fps (i.e. 60000/1001) video and when I attempt to extract one second:

ffmpeg -y -i input60fps.avi -ss 0 -t 1 -c:v huffyuv -an output60fps.avi
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 ./output60fps.avi

it returns 1.001 seconds, which I now understand is appropriate since it is the multiple of the video's frame time (60000/1001 seconds) nearest to the requested duration.

Repeating this experiment on a 59.94 fps video that was previously converted from a 29.97 fps source, I'd expect similar results, but I'm seeing that's not actually the case:

ffmpeg -i input30fps.avi -vcodec huffyuv -r 60000/1001 -an output60fps.avi
ffmpeg -i ./output60fps.avi -ss 0 -t 1 -c:v huffyuv -an test.avi
ffprobe -v error -show_entries format=duration -of default=noprint_wrappers=1:nokey=1 ./test.avi

This actually results in 0.984317 seconds.

Why is this behavior different? Is there some way for me to control how the total frames get distributed evenly such that each boundary occurs every 60000/1001 milliseconds? My expectation here is that since I'm just doubling the frame rate, I should expect a frame every 1001/60000 seconds.

Upvotes: 0

Views: 479

Answers (1)

Gyan
Gyan

Reputation: 93008

AVI is a variable frame rate muxer. In addition to -r, you need to enable constant frame rate so

ffmpeg -i input30fps.avi -vcodec huffyuv -r 60000/1001 -vsync cfr -an output60fps.avi

Upvotes: 1

Related Questions