PR #20946 opened by anthonybajoua URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20946 Patch URL: https://code.ffmpeg.org/FFmpeg/FFmpeg/pulls/20946.patch
Currently, when there is a file that is muxed in fragmented mode with flags `frag_keyframe+delay_moov+empty_moov+dash` the second track's length is underreported the length of one fragment. ## Before: ``` ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 /Users/anthonybajoua/Downloads/ungraceful.mp4 5.011090 ``` ## After: ``` ❯ ./ffprobe -v error -select_streams v:0 -show_entries stream=duration -of default=noprint_wrappers=1:nokey=1 /Users/anthonybajoua/Downloads/ungraceful.mp4 10.011090 ``` From 33aae22ff41f89977e7dea4607e6334072993334 Mon Sep 17 00:00:00 2001 From: Anthony Bajoua <[email protected]> Date: Sat, 25 Oct 2025 02:10:06 -0700 Subject: [PATCH 1/2] libavformat/movenc: Output ftyp atom with hybrid_fragmented+delay_moov --- libavformat/movenc.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index eabc1b95ca..e949c54f04 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -6536,7 +6536,8 @@ static int mov_flush_fragment(AVFormatContext *s, int force) mov->tracks[i].data_offset = pos + moov_size + 8; avio_write_marker(s->pb, AV_NOPTS_VALUE, AVIO_DATA_MARKER_HEADER); - if (mov->flags & FF_MOV_FLAG_DELAY_MOOV) + if (mov->flags & FF_MOV_FLAG_DELAY_MOOV && + !(mov->flags & FF_MOV_FLAG_HYBRID_FRAGMENTED)) mov_write_identification(s->pb, s); if ((ret = mov_write_moov_tag(s->pb, mov, s)) < 0) return ret; @@ -8413,7 +8414,8 @@ static int mov_write_header(AVFormatContext *s) } } - if (!(mov->flags & FF_MOV_FLAG_DELAY_MOOV)) { + if (!(mov->flags & FF_MOV_FLAG_DELAY_MOOV) || + (mov->flags & FF_MOV_FLAG_HYBRID_FRAGMENTED)) { if ((ret = mov_write_identification(pb, s)) < 0) return ret; } -- 2.49.1 From 85b5a4b57e1cf667d541e4a930bcead6bf829dd2 Mon Sep 17 00:00:00 2001 From: Anthony Bajoua <[email protected]> Date: Mon, 17 Nov 2025 10:30:35 -0800 Subject: [PATCH 2/2] [libavformat][mov] Fixes individual track duration on fragmented files --- libavformat/mov.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index eab9f79577..360d297021 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -6183,7 +6183,8 @@ static int mov_read_sidx(MOVContext *c, AVIOContext *pb, MOVAtom atom) } } - c->frag_index.complete = 1; + if (offset == 0) + c->frag_index.complete = 1; } return 0; -- 2.49.1 _______________________________________________ ffmpeg-devel mailing list -- [email protected] To unsubscribe send an email to [email protected]
