When encoding H.264 using ffmpeg I get the following type of warnings en masse:
Past duration 0.603386 too large
Past duration 0.614372 too large
Past duration 0.606377 too large
What do they mean? I have not found anything clear online or in the ffmpeg documentation.
I was getting thousands of these warnings with a particular encode. I was downscaling 1080p video to 480p. At an edit point, where there was some dodgy video due to a defect in the source laserdisc, these messages started coming up and then appeared for, I think, every frame thereafter. They went on and on, like this short excerpt:
The original ffmpeg invocation was this:
Following suggestions here I first added
-framerate 60000/1001
to the input. That did not improve anything. I retained-framerate
and added-r 60000/1001
to the output. That still did not improve anything. Retaining both I finally added-async 1 -vsync 1
. This resulted in my receiving a single warning, and that's all. That invocation was:The only difference I found in a detailed dump from MediaInfo was the removal of this line found in the original invocation but not in the second one:
However, I checked A/V sync near the beginning of the files and near the end, and there was no discernible difference in sync between the two files. Their running times were also the same, but that was only measured to the nearest second, in VLC. So I checked the frame counts using ffmpeg like so:
and looking for "frame=#" near the end of the output.
Turns out the source video was 375226 frames long, the original invocation yielded 375195 frames, and the second invocation yielded 375200. So the second invocation, with vastly fewer warning messages also dropped 5 fewer frames.
Subsequent testing showed that
-framerate
and-r
were unnecessary, and just using the two sync flags was sufficient. This produced identical results to the second invocation above, so the third and simplest invocation I found to solve the problem is this:And yet another file subsequently produced a bunch of these warnings even with the sync flags, but adding back the rate flags "fixed" it (only produced two instead of thousands of warnings). So sometimes the second invocation works when the third doesn't. For my immediate purposes I'm going to settle on the second invocation and hope it fixes most of these problems.
This was all with ffmpeg version 4.0.