From patchwork Sun Oct 4 14:28:41 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derek Buitenhuis X-Patchwork-Id: 22724 Return-Path: X-Original-To: patchwork@ffaux-bg.ffmpeg.org Delivered-To: patchwork@ffaux-bg.ffmpeg.org Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org [79.124.17.100]) by ffaux.localdomain (Postfix) with ESMTP id 7E0FB44A761 for ; Sun, 4 Oct 2020 17:29:01 +0300 (EEST) Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 52F2468AA90; Sun, 4 Oct 2020 17:29:01 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm1-f47.google.com (mail-wm1-f47.google.com [209.85.128.47]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id E53A6687F85 for ; Sun, 4 Oct 2020 17:28:54 +0300 (EEST) Received: by mail-wm1-f47.google.com with SMTP id d4so6010494wmd.5 for ; Sun, 04 Oct 2020 07:28:54 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xD+lsEDa7QuUpxNv5vCNw5rEf+B2h3pUlAPCQ9zQjSY=; b=ZRRqkiDH7XyKrHM5XJV8p7f/HN6QkH1hVUmYAg8f2SMDaooR8UNzVNA0/w8ikDOp0c c4ejeLIPL2cA6WmDzhQWEbKshprAJm4tZN/tGdVjmZLA/zO9OaevCdZZ+EJoxBolOULv GglzjPcJaDmVw7HY4fZOWlknEa/lnxBXEfIWIKdOPfJ7719XXZuwUvvjeMv4/+mNrxSp YQxQw5hPMZIeO8EZ82dDQpRcbJmZBxAwLV0lfuWzBGPKmXIpEl6lld7OzKtMzwJYAGUM l84rJAl0ojyuwqLXi5lJ/okQrc9zKqvrXxnasfMKPZG1LfBPz/kadFdaZwq7wQyfbdfw rJaw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=xD+lsEDa7QuUpxNv5vCNw5rEf+B2h3pUlAPCQ9zQjSY=; b=RwrreSK0C79Khl/K4saRURyi79UvzhOwGibcWUr7cuWt4rHP8n5db/z1LlZ9n7QDYp HGABWLZ04HVLC7KwJrT8d1NvMPAp40CJ4lHKybG6mhWiF4Nvs8mEu4ig82idZD6jxcYC 5t3MxIEI0qKxJsCS15enGV4Xp0t8r+to86I3tEnyu769tg+xZuElqH2z/3oyw9DHJHfJ OJxP5uqzqqGC/OYncZl06uM8hWCSYi+BnPhZlLe//cN0Sc+TcnQcPcHQKV8snMegMV0u YJsq886iIPRkSxEvBDw1m76Ogm10Hz/n4rSZIpdMzKj9Y2p6ZODRv1qMus1NGWUeGSj1 TIhQ== X-Gm-Message-State: AOAM533mNaOIRCbQwJfBZZ4QABMu4Apl8/VCCw6QasHKZuTsWfX1MOzz ZChX7sJFTSkoUWg7NhWYmIByBuuBdE0= X-Google-Smtp-Source: ABdhPJxs9c70f3lzqSobRXthLVBADcEjxavIC0dkp/5Av5VlHa4ybjC4ttA/XIg4uOSTklk1XNd/AQ== X-Received: by 2002:a1c:2905:: with SMTP id p5mr12572420wmp.187.1601821734092; Sun, 04 Oct 2020 07:28:54 -0700 (PDT) Received: from localhost.localdomain ([81.2.169.31]) by smtp.gmail.com with ESMTPSA id e18sm9797431wra.36.2020.10.04.07.28.53 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 04 Oct 2020 07:28:53 -0700 (PDT) From: Derek Buitenhuis To: ffmpeg-devel@ffmpeg.org Date: Sun, 4 Oct 2020 15:28:41 +0100 Message-Id: <20201004142841.179499-1-derek.buitenhuis@gmail.com> X-Mailer: git-send-email 2.28.0 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH] Allow using only the mfra info for seeking using the fragment index X-BeenThere: ffmpeg-devel@ffmpeg.org X-Mailman-Version: 2.1.20 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: dalecurtis@chromium.org Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Justin Ruggles The mfra has enough information to enable seeking, and reading it is behind an AVOption flag, so we shouldn't require that sidx information also be present in order to seek using the fragment index. Signed-off-by: Derek Buitenhuis --- This is especially important want I/O is networked, since otherwise it will read essentially the entire file by seeking to every sidx in the file, which for a live-style FMP4 can be a *lot*. Dale Curtis is CC'd, as this is probably highly relevant to him. Note: If a global sidx is present, that information will override the mfra, but if sidx are before each moof, those will no longer be parsed in mov_read_header if you set use_mfra_for, which can result in a wrong duration since mfra isn't used for setting duration while sidx is. --- libavformat/mov.c | 1 + 1 file changed, 1 insertion(+) diff --git a/libavformat/mov.c b/libavformat/mov.c index 4f64e96bc0..7fd43a8fc5 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -7529,6 +7529,7 @@ static int mov_read_mfra(MOVContext *c, AVIOContext *f) goto fail; } while (!ret); ret = 0; + c->frag_index.complete = 1; fail: seek_ret = avio_seek(f, original_pos, SEEK_SET); if (seek_ret < 0) {