Discussion:
[FFmpeg-user] Is there a reason the default vsync for the mp4 muxer is not 2?
André Hänsel
2018-05-23 13:39:00 UTC
Permalink
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
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. :)



_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-reques
Carl Eugen Hoyos
2018-05-23 13:51:38 UTC
Permalink
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.
But it is - unfortunately! - an invalid file.
I think this would make much more sense as a default. The
Chooses between 1 and 2 depending on muxer capabilities.
So first question: Is there a reason why the mp4 muxer
cannot choose vsync 2?
Because our mov muxer does not support vfr (correctly).

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
f
André Hänsel
2018-05-23 14:24:33 UTC
Permalink
Post by Carl Eugen Hoyos
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.
But it is - unfortunately! - an invalid file.
Is there a ticket/additional info about what is/can be invalid in this file? With -enc_time_base -1 -vsync 2 my output files seem just fine.



_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-
Carl Eugen Hoyos
2018-05-23 21:27:14 UTC
Permalink
Post by André Hänsel
Post by Carl Eugen Hoyos
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.
But it is - unfortunately! - an invalid file.
Is there a ticket/additional info about what is/can be invalid in this file?
I don't remember atm, sorry, git blame may help you.
Post by André Hänsel
With -enc_time_base -1 -vsync 2 my output files seem just fine.
Do you have access to an isom stream analyzer?
If not, this discussion won't be very fruitful, sorry;-(

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscr
André Hänsel
2018-05-24 05:18:11 UTC
Permalink
Post by Carl Eugen Hoyos
Post by André Hänsel
Post by Carl Eugen Hoyos
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.
But it is - unfortunately! - an invalid file.
Is there a ticket/additional info about what is/can be invalid in this file?
I don't remember atm, sorry, git blame may help you.
Hm, I found https://github.com/FFmpeg/FFmpeg/commit/91360ce61d00bb20429fb41857abebf50a5c6b1d. It says timespamps must start at 0 and that "causes sync problems" - is that about audio? I don't have any audio in my files, maybe that is why I'm not experiencing problems?
Post by Carl Eugen Hoyos
Post by André Hänsel
With -enc_time_base -1 -vsync 2 my output files seem just fine.
Do you have access to an isom stream analyzer?
If not, this discussion won't be very fruitful, sorry;-(
I usually use http://mp4parser.com/, which shows hex, which I cross reference with https://developer.apple.com/library/content/documentation/QuickTime/QTFF/QTFFChap2/qtff2.html.


_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ffmpeg-user-***@ffmpeg.org with subject "unsubscribe"
Carl Eugen Hoyos
2018-05-24 16:36:01 UTC
Permalink
Post by André Hänsel
Post by Carl Eugen Hoyos
Post by André Hänsel
Post by Carl Eugen Hoyos
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.
But it is - unfortunately! - an invalid file.
Is there a ticket/additional info about what is/can be invalid in this file?
I don't remember atm, sorry, git blame may help you.
Hm, I found
https://github.com/FFmpeg/FFmpeg/commit/91360ce6
Yes, this is the relevant commit.

Feel free to check the ffmbc sources (do not take patches
from it though, ffmbc is not lgpl!).

Carl Eugen
_______________________________________________
ffmpeg-user mailing list
ffmpeg-***@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-user

To unsubscribe, visit link above, or email
ff

Loading...