[FFmpeg-devel] [PATCH] movenc: Write durations based on pts into mvhd/mdhd/tkhd/elst

Michael Niedermayer michael at niedermayer.cc
Mon Dec 16 21:25:49 EET 2019


On Mon, Dec 16, 2019 at 12:16:14AM +0200, Martin Storsjö wrote:
> Keep all the existing data fields as they are (there's lots and
> lots of nontrivial calculation and heuristics based on them in
> their current form), but derive the duration as the difference
> between the pts of the first packet to the maximum pts+duration
> (not necessarily the last packet); use this duration in any box
> where the actual presentation duration is supposed to be.
> 
> Fixes: 8420
> ---
>  libavformat/movenc.c | 21 ++++++++++++++++-----
>  tests/ref/lavf/mov   |  4 ++--
>  tests/ref/lavf/mp4   |  4 ++--
>  3 files changed, 20 insertions(+), 9 deletions(-)

This seems to loose duration for this: (not sure which way is more correct)

./ffmpeg -i ~/tickets/2892/MPEG_tbn_test.mov  -c:v copy -c:a copy -vtag mx3n -timecode 10:00:00:00 -vframes 3 x.mov && ./ffprobe -v x.mov -show_packets -print_format compact

https://samples.ffmpeg.org/ffmpeg-bugs/trac/ticket2892/

packet|codec_type=data|stream_index=1|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=3003|duration_time=0.100100|convergence_duration=N/A|convergence_duration_time=N/A|size=4|pos=36|flags=K_
packet|codec_type=video|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=125153|pos=40|flags=K_
packet|codec_type=video|stream_index=0|pts=1001|pts_time=0.033367|dts=1001|dts_time=0.033367|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=125153|pos=125193|flags=K_
packet|codec_type=video|stream_index=0|pts=2002|pts_time=0.066733|dts=2002|dts_time=0.066733|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=125153|pos=250346|flags=K_

vs.

packet|codec_type=data|stream_index=1|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=N/A|duration_time=N/A|convergence_duration=N/A|convergence_duration_time=N/A|size=4|pos=36|flags=KD
packet|codec_type=video|stream_index=0|pts=0|pts_time=0.000000|dts=0|dts_time=0.000000|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=125153|pos=40|flags=K_
packet|codec_type=video|stream_index=0|pts=1001|pts_time=0.033367|dts=1001|dts_time=0.033367|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=125153|pos=125193|flags=K_
packet|codec_type=video|stream_index=0|pts=2002|pts_time=0.066733|dts=2002|dts_time=0.066733|duration=1001|duration_time=0.033367|convergence_duration=N/A|convergence_duration_time=N/A|size=125153|pos=250346|flags=K_


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

No snowflake in an avalanche ever feels responsible. -- Voltaire
-------------- 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/20191216/0e598aaf/attachment.sig>


More information about the ffmpeg-devel mailing list