History

mov: Disable advanced_editlist for fragmented MP4 input

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.

Derek Buitenhuis committed 3 years ago

Commit dae36791 parent 13d04e31 file · +14 −0Browse files

Unified · Split

libavformat/mov.c+14−0
@@ -4499,6 +4499,20 @@ static int mov_read_trak(MOVContext *c, AVIOContext *pb, MOVAtom atom) · 4498 unmodified lines
44994499
45004500 avpriv_set_pts_info(st, 64, 1, sc->time_scale);
45014501
4502+ /*
4503+ * Advanced edit list support does not work with fragemented MP4s, which
4504+ * have stsc, stsz, stco, and stts with zero entries in the moov atom.
4505+ * In these files, trun atoms may be streamed in.
4506+ *
4507+ * It cannot be used with use_mfra_for = {pts,dts} either, as the index
4508+ * is not complete, but filled in as more trun atoms are read, as well.
4509+ */
4510+ if (!sc->stts_count || c->use_mfra_for != FF_MOV_FLAG_MFRA_AUTO) {
4511+ av_log(c->fc, AV_LOG_WARNING, "advanced_editlist does not work with fragmented "
4512+ "MP4. disabling.\n");
4513+ c->advanced_editlist = 0;
4514+ }
4515+
45024516 mov_build_index(c, st);
45034517
45044518 if (sc->dref_id-1 < sc->drefs_count && sc->drefs[sc->dref_id-1].path) {

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t