* [FFmpeg-devel] [PATCH][RFC][CURSED] mov: Disable advanced_editlist for fragmented MP4 input
@ 2022-12-28 16:28 Derek Buitenhuis
2023-01-05 19:44 ` Derek Buitenhuis
0 siblings, 1 reply; 4+ messages in thread
From: Derek Buitenhuis @ 2022-12-28 16:28 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: isasi
Advanced edit list support is entirely broken for fragmented MP4s,
currently. mov_fix_index is never run in mov_build_index, since
in fragmented MP4s the stco, stsz, stts, and stsc boxes have zero
entries, with the index being filled in as each fragment's trun
box is seen.
The result of this is that the skip samples is never set properly,
since half the code thinks it doesn't need to, as advanced_editlist
is enabled, but as mov_fix_index is never called, it doesnt get set.
This means that any edits for e.g. priming are not properly applied
as skip samples side data.
This also means remuxing to fragmented MP4 from progressive MP4 with
lavf will quietly drop the edit list, currently.
Example:
$ ffmpeg -loglevel quiet -advanced_editlist 1 -i non_fragmented.mp4 -f md5 -
MD5=d02d929f8eb4edef624758a298d5f7c6
$ ffmpeg -loglevel quiet -advanced_editlist 0 -i non_fragmented.mp4 -f md5 -
MD5=d02d929f8eb4edef624758a298d5f7c6
$ ffmpeg -loglevel quiet -advanced_editlist 1 -i fragmented.mp4 -f md5 -
MD5=e38b110f586fa886ff94e0ca98a95d59 <-- wrong, extra samples are output instead of being skipped
$ ffmpeg -loglevel quiet -advanced_editlist 0 -i fragmented.mp4 -f md5 -
MD5=d02d929f8eb4edef624758a298d5f7c6
We cannot call mov_fix_index after reading a trun box
since mov_fix_index seems to assume it is only called once, on a
fully complete index, an multiple calls to it don't seem like
they'd work, so the "best" option seems to be disabling advanced
edit list support entirely for the time being, as it is broken
for these types of files.
Signed-off-by: Derek Buitenhuis <derek.buitenhuis@gmail.com>
---
Obviously, I think this is a pretty gross 'fix', but short of a rewrite(-ish) of
advanced edit list support, I don't know a better option. Ideas welcome.
I've CCed the authors of advanced edit list support, although I am not sure if
they're still around or involved in FFmpeg.
Files from example above:
* https://www.dropbox.com/s/zw626kck6d9eist/non_fragmented.mp4?dl=0
* https://www.dropbox.com/s/c46ajkqewqurdrz/fragmented.mp4?dl=0
---
libavformat/mov.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 29bd3103e3..e0b7df2815 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -4499,6 +4499,20 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom)
avpriv_set_pts_info(st, 64, 1, sc->time_scale);
+ /*
+ * Advanced edit list support does not work with fragemented MP4s, which
+ * have stsc, stsz, stco, and stts with zero entries in the moov atom.
+ * In these files, trun atoms may be streamed in.
+ *
+ * It cannot be used with use_mfra_for = {pts,dts} either, as the index
+ * is not complete, but filled in as more trun atoms are read, as well.
+ */
+ if (!sc->stts_count || c->use_mfra_for != FF_MOV_FLAG_MFRA_AUTO) {
+ av_log(c->fc, AV_LOG_WARNING, "advanced_editlist does not work with fragmented "
+ "MP4. disabling.\n");
+ c->advanced_editlist = 0;
+ }
+
mov_build_index(c, st);
if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {
--
2.39.0
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH][RFC][CURSED] mov: Disable advanced_editlist for fragmented MP4 input
2022-12-28 16:28 [FFmpeg-devel] [PATCH][RFC][CURSED] mov: Disable advanced_editlist for fragmented MP4 input Derek Buitenhuis
@ 2023-01-05 19:44 ` Derek Buitenhuis
2023-01-07 16:11 ` Derek Buitenhuis
0 siblings, 1 reply; 4+ messages in thread
From: Derek Buitenhuis @ 2023-01-05 19:44 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: isasi
On 12/28/2022 4:28 PM, Derek Buitenhuis wrote:
> ---
> libavformat/mov.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
Ping.
- Derek
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH][RFC][CURSED] mov: Disable advanced_editlist for fragmented MP4 input
2023-01-05 19:44 ` Derek Buitenhuis
@ 2023-01-07 16:11 ` Derek Buitenhuis
2023-01-08 6:29 ` Zhao Zhili
0 siblings, 1 reply; 4+ messages in thread
From: Derek Buitenhuis @ 2023-01-07 16:11 UTC (permalink / raw)
To: ffmpeg-devel
On 1/5/2023 7:44 PM, Derek Buitenhuis wrote:
> On 12/28/2022 4:28 PM, Derek Buitenhuis wrote:
>> ---
>> libavformat/mov.c | 14 ++++++++++++++
>> 1 file changed, 14 insertions(+)
>
> Ping.
Will push some time soon if there are no objections.
- Derek
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [FFmpeg-devel] [PATCH][RFC][CURSED] mov: Disable advanced_editlist for fragmented MP4 input
2023-01-07 16:11 ` Derek Buitenhuis
@ 2023-01-08 6:29 ` Zhao Zhili
0 siblings, 0 replies; 4+ messages in thread
From: Zhao Zhili @ 2023-01-08 6:29 UTC (permalink / raw)
To: FFmpeg development discussions and patches
> 在 2023年1月8日,00:11,Derek Buitenhuis <derek.buitenhuis@gmail.com> 写道:
>
> On 1/5/2023 7:44 PM, Derek Buitenhuis wrote:
>>> On 12/28/2022 4:28 PM, Derek Buitenhuis wrote:
>>> ---
>>> libavformat/mov.c | 14 ++++++++++++++
>>> 1 file changed, 14 insertions(+)
>>
>> Ping.
>
> Will push some time soon if there are no objections.
LGTM.
>
> - Derek
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2023-01-08 6:29 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-12-28 16:28 [FFmpeg-devel] [PATCH][RFC][CURSED] mov: Disable advanced_editlist for fragmented MP4 input Derek Buitenhuis
2023-01-05 19:44 ` Derek Buitenhuis
2023-01-07 16:11 ` Derek Buitenhuis
2023-01-08 6:29 ` Zhao Zhili
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