From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by master.gitmailbox.com (Postfix) with ESMTP id C65D044814 for ; Wed, 28 Dec 2022 16:28:55 +0000 (UTC) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 9269368B9DC; Wed, 28 Dec 2022 18:28:53 +0200 (EET) Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 8D600680C51 for ; Wed, 28 Dec 2022 18:28:47 +0200 (EET) Received: by mail-wm1-f51.google.com with SMTP id bg10so11549259wmb.1 for ; Wed, 28 Dec 2022 08:28:47 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=D2earPvzPy+0eYLp7dFXGyxU0ERgzXPL74nCRPPlq6s=; b=LQOI1gPLyBXK1iUczaAASfYA+6vraIKP4sZdIkBA+l4SyUcv9b2Y8phXozbcpGS2hE suIqbZLbdm9TyXGu46rLsoYA/JAiolKah+AWPjiSWVeKDYj7zH/vLw4aEMxcJKeXC8Zl l79t7T9mek0NbrHUfji++yCOZtrqUBDwwAN4/mXPjUis8Ye34xnyMHyb2KebLDqM25l6 425wdkxvh+bSdmVoRfoh4oxEMdeI8M6hZYmtA9zXGqP1j8m/D0Obq+cKc7KqX42dquLx p1ab0mtuP0HPZ538jTyf5pdi3wWGzCCjmSP5kj3Q5vPDQQbnb82UCxznheV8wk26ZUlg RJVw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=D2earPvzPy+0eYLp7dFXGyxU0ERgzXPL74nCRPPlq6s=; b=AL0OOT/gPu5XUmSWwQrmbogOPoHOodZuLLRtl55lVZYATYMtyseak3fqqfPtk5xrw/ /PmPq2+7s0S+aadE0V3dvlduAya4rJuq+Rtm3/Um18K+0cDPK9BHWmuAa4W0Mk4PMQGm dbrK+1W7L79qrzN9sFeIYfUQDay1WzEaouZZoocGpI6S0rQxkuHj4DxbNxJehiUEkTvy SMRFdSTYXHqiEih2uAvWdJ8qnFmVoQTa/qrb1CYjKmnI8lI3yXr6ViOIKa0p9mue+CGv 0br/KjeA9anjVHYUa+nNRngVJxbGMrWew1xSdkNjfA2mz7giC3fntaSbYkSBW9nXxzWB OIkw== X-Gm-Message-State: AFqh2krgHuG68ouBR5C5561gJAJRJhqfft2fsESPl3+8k9Q6NX7MhcH5 XMHqQJLrmBaVj9RSb06wFcbwcfsRPcY= X-Google-Smtp-Source: AMrXdXtWzgbDUmBSvl0jIa68dAo44+drVCnkQ7RQ2ci4JTN4DRQKwfvP/KGn1Eo+nGNJR5/1hAwUhA== X-Received: by 2002:a05:600c:512a:b0:3cf:8957:a441 with SMTP id o42-20020a05600c512a00b003cf8957a441mr18443829wms.12.1672244926572; Wed, 28 Dec 2022 08:28:46 -0800 (PST) Received: from localhost.localdomain (33bf250e.skybroadband.com. [51.191.37.14]) by smtp.gmail.com with ESMTPSA id s16-20020a1cf210000000b003c6bd12ac27sm21190643wmc.37.2022.12.28.08.28.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 28 Dec 2022 08:28:45 -0800 (PST) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Wed, 28 Dec 2022 16:28:44 +0000 Message-Id: <20221228162844.197098-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.39.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH][RFC][CURSED] mov: Disable advanced_editlist for fragmented MP4 input X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: FFmpeg development discussions and patches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Reply-To: FFmpeg development discussions and patches Cc: isasi@google.com Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Archived-At: List-Archive: List-Post: 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 --- 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".