[FFmpeg-devel] [PATCH] lavf/movenc: Replace dts by pts to calculate duration

Martin Storsjö martin at martin.st
Tue Dec 3 14:57:44 EET 2019

On Thu, 28 Nov 2019, manuelyuan wrote:

> There are many UGC videos with dynamic frame rates, which are represented by
> PTS jumps. After transcoding with ffmpeg -vsync 0 or -vsync 2, the output
> video duration becomes longer.

Did you post any reproduction case of what, exactly (which field in which 
box), you think is wrong?

Right now, this patch, among other things, breaks the implied last 
duration of the last packet in a fragment.

This can be reproduced by with the lavf-movenc test, like this:
$ make libavformat/tests/movenc
$ libavformat/tests/movenc -w

Then inspect vfr-noduration.mp4 (with a suitable tool, e.g. L-SMASH's 
boxdumper). Previously, the last packet in each fragment got an 
inferred/guessed duration (if the duration field of the AVFrame was zero) 
based on earlier frame intervals, but with your patch it is zero.

I'm fairly convinced that most of the changes in your patch shouldn't be 
made, but to make the discussion proceed you need to _exactly_ specify 
what you think is wrong, in a way that others can reproduce.

// Martin

More information about the ffmpeg-devel mailing list