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

Michael Niedermayer michael at niedermayer.cc
Thu Nov 7 20:21:16 EET 2019


On Thu, Nov 07, 2019 at 05:55:18PM +0800, manuelyuan wrote:
> From: Mengyang Yuan <manuelyuan at 163.com>
> 
> In this case, the input video is of dynamic frame rate and we don't want to
> duplicate or drop frames, but the output video duration calculated by DTS is
> incorrect, I solved it by using PTS.
> 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.By reading the code of x264/encoder/encoder.c,
> I found that in order to predict the B frame, x264 needs to ensure that there
> are enough reference frames when DTS = 0, so the DTS of these reference frames
> will subtract the cache time. However, the cache time includes the part of PTS
> jumps, which results in the abnormal small DTS.
> 
> Signed-off-by: Mengyang Yuan <manuelyuan at 163.com>
> ---
>  libavformat/movenc.c  | 23 ++++++++++++++---------
>  libavformat/movenc.h  |  2 ++
>  tests/ref/fate/movenc | 20 ++++++++++----------
>  tests/ref/lavf/mov    |  4 ++--
>  tests/ref/lavf/mp4    |  4 ++--
>  5 files changed, 30 insertions(+), 23 deletions(-)

breaks fate-binsub-movtextenc
...

[mp4 @ 0x29327c0] Estimating the duration of the last packet in a fragment, consider setting the duration field in AVPacket instead.
size=       1kB time=00:00:05.85 bitrate=   1.3kbits/s speed=6.03e+04x    
video:0kB audio:0kB subtitle:0kB other streams:0kB global headers:0kB muxing overhead: 1809.803955%
make: *** [fate-binsub-movtextenc] Error 1

[...]
-- 
Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

Any man who breaks a law that conscience tells him is unjust and willingly 
accepts the penalty by staying in jail in order to arouse the conscience of 
the community on the injustice of the law is at that moment expressing the 
very highest respect for law. - Martin Luther King Jr
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 181 bytes
Desc: not available
URL: <https://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20191107/07823f13/attachment.sig>


More information about the ffmpeg-devel mailing list