* [FFmpeg-devel] [PATCH] [libavformat][mov] Fixes individual track duration on fragmented files (PR #20946)
@ 2025-11-17 18:36 anthonybajoua via ffmpeg-devel
0 siblings, 0 replies; only message in thread
From: anthonybajoua via ffmpeg-devel @ 2025-11-17 18:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: anthonybajoua
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 <anthonybajoua@meta.com>
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 <anthonybajoua@meta.com>
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 -- ffmpeg-devel@ffmpeg.org
To unsubscribe send an email to ffmpeg-devel-leave@ffmpeg.org
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2025-11-17 18:36 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-11-17 18:36 [FFmpeg-devel] [PATCH] [libavformat][mov] Fixes individual track duration on fragmented files (PR #20946) anthonybajoua via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git