[FFmpeg-user] Is there a reason the default vsync for the mp4 muxer is not 2?
André Hänsel
andre at webkr.de
Wed May 23 16:39:00 EEST 2018
I was re-encoding a video with:
ffmpeg -i in.mp4 -c:v libx264 -movflags faststart -crf 30 out.mp4
and surprisingly the output file was much larger (9 MB) than the input file
(3 MB). I examined the files with:
ffprobe -show_entries frame=pict_type,pkt_size -of csv in.mp4
and I noticed that the output file just had many more frames. This is
confirmed by the fact that it says "dup=140" in the encoding log.
So I checked the presentation timestamps (pkt_pts_time) in the output file.
Input:
frame,0,0.000000,I
frame,675,0.038775,P
frame,1289,0.074046,P
frame,1941,0.111500,P
frame,4624,0.265625,P
frame,5341,0.306813,P
...
Output:
frame,0,0.000000,I
frame,1024,0.058824,P
frame,2048,0.117647,P
frame,3072,0.176471,B
frame,4096,0.235294,P
frame,5120,0.294118,P
...
As you can see, they are completely off. I added -vsync 2 to the command
line options and I got a file that has roughly the same number of frames as
the input. I think this would make much more sense as a default. The
documentation says about the default for vsync:
> Chooses between 1 and 2 depending on muxer capabilities.
So first question: Is there a reason why the mp4 muxer cannot choose vsync
2?
However, even with vsync 2 the timestamps were still slightly off, in fact
they looked somehow quantized:
frame,0,0.000000,I
frame,1024,0.058824,P
frame,2048,0.117647,P
frame,3072,0.176471,P
frame,5120,0.294118,P
frame,6144,0.352941,P
...
I was finally able to fix this with -enc_time_base -1. So same question: Any
reason to not have this as the default?
By the way, I tried one more thing. I thought maybe it will choose vsync 2
automatically *if* enc_time_base is -1 (because otherwise it works with
timestamps quantized to some arbitrary constant frame rate anyway and the
value of vsync doesn't matter much). So I tried *only* giving -enc_time_base
-1 and no -vsync. This led to:
[mp4 @ 0000000003ecd040] Frame rate very high for a muxer not efficiently
supporting it.
Please consider specifying a lower framerate, a different muxer or -vsync 2
More than 1000 frames duplicated
Thank you FFmpeg, I will consider it. Why not make it the default. :)
More information about the ffmpeg-user
mailing list