From patchwork Sat Apr 15 22:05:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 41196 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1412023pzb; Sat, 15 Apr 2023 15:06:32 -0700 (PDT) X-Google-Smtp-Source: AKy350ZcHURdeSgHg9RJZepXVEXHLz4h84WuKTYDI9dEWLNYmQR0BHjjR3wfOR3MCjyeRrAe+qnT X-Received: by 2002:a17:907:30cd:b0:94b:22a7:7865 with SMTP id vl13-20020a17090730cd00b0094b22a77865mr2549195ejb.28.1681596391979; Sat, 15 Apr 2023 15:06:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681596391; cv=none; d=google.com; s=arc-20160816; b=OtWaInc8nQPp/zB4k9z7p9XaIZf+eC8LgmWWQ1zdu3gJ+3T9sc+Joxy+ib4XlUlwWi fU2m7S5ALjKBBh9+2+d3MBYet+HJ2g2y1mlut0Vo+WkD23l39fMtEfddPT35b6kQ3YBj H2QEs9usbu7frxSYTDT3Dxxo2RxI+oovQyVlDlAY+qF+iAqw5CCYZ8zhfObPDh6GiQ8X seD36mzQEG4k7gEYQxFJPcDWowu+aX6S7csEbNW/NbfjU4vSoeP2QfM0qdU2pJu5DiAo 6CbSoKPicv7ZEoq944JpAzWvIJsSQ8Qy+roTGa8DpZIIT3GLfWdf/8z88EGINlhzaRki xVzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:message-id:date:to:from :delivered-to; bh=Xg4ZDbkptTHs8DnfvM33ocIazb6pw7xSW9w9lUqR4P0=; b=zjjNTHflHUPYoMfWLhbnzEXB5I8K2E6YjdfPZ7BFrZskpqr4NoTFTuIZ5B1gBwZ74b 2spLUdL249XzZDq1GlF4/qWcZxupPIsYbkY+xw8p+tP8/VkIfFGeiYi8h0ulxyaivVwr RbhxboZaUcBJ21IJwgJvgEMaq4RdHghGGxwBDrWLEnoUefZhKctsZMwZcXzOoExlUi3d yNCYYLqTIhcMT3r3ciWcQKe2zCw0HFK1bHZgEXd0nKggxjM0d+/jauVbK8tgzd3+UNWT k9ulIBuqI44vApLdnwRsd6VNXIV+a8ce2Qe955vPMm9mqdzF3eMgvyWm9JFDG5ptkAhp gXqA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id h23-20020aa7c957000000b004fe961ba207si7161078edt.236.2023.04.15.15.06.31; Sat, 15 Apr 2023 15:06:31 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id BED4368BE10; Sun, 16 Apr 2023 01:06:18 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (unknown [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 2341268A0A2 for ; Sun, 16 Apr 2023 01:06:11 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id A3AB8E8A1F; Sun, 16 Apr 2023 00:05:31 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id I02Flsczn7JP; Sun, 16 Apr 2023 00:05:24 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id F304DE0C64; Sun, 16 Apr 2023 00:05:23 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 16 Apr 2023 00:05:53 +0200 Message-Id: <20230415220558.16122-1-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 1/6] avformat/mov: factorize reading creation time metadata 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 2/DnW81chay6 Signed-off-by: Marton Balint --- libavformat/mov.c | 32 ++++++++++++-------------------- 1 file changed, 12 insertions(+), 20 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 057fd872b1..5d00ff6e8b 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1515,14 +1515,22 @@ static int mov_read_moof(MOVContext *c, AVIOContext *pb, MOVAtom atom) return mov_read_default(c, pb, atom); } -static void mov_metadata_creation_time(AVDictionary **metadata, int64_t time, void *logctx) +static void mov_metadata_creation_time(MOVContext *c, AVIOContext *pb, AVDictionary **metadata, int version) { + int64_t time; + if (version == 1) { + time = avio_rb64(pb); + avio_rb64(pb); + } else { + time = avio_rb32(pb); + avio_rb32(pb); /* modification time */ + } if (time) { if (time >= 2082844800) time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ if ((int64_t)(time * 1000000ULL) / 1000000 != time) { - av_log(logctx, AV_LOG_DEBUG, "creation_time is not representable\n"); + av_log(c->fc, AV_LOG_DEBUG, "creation_time is not representable\n"); return; } @@ -1537,7 +1545,6 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) int version; char language[4] = {0}; unsigned lang; - int64_t creation_time; if (c->fc->nb_streams < 1) return 0; @@ -1555,14 +1562,7 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) return AVERROR_PATCHWELCOME; } avio_rb24(pb); /* flags */ - if (version == 1) { - creation_time = avio_rb64(pb); - avio_rb64(pb); - } else { - creation_time = avio_rb32(pb); - avio_rb32(pb); /* modification time */ - } - mov_metadata_creation_time(&st->metadata, creation_time, c->fc); + mov_metadata_creation_time(c, pb, &st->metadata, version); sc->time_scale = avio_rb32(pb); if (sc->time_scale <= 0) { @@ -1587,18 +1587,10 @@ static int mov_read_mdhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) { int i; - int64_t creation_time; int version = avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ - if (version == 1) { - creation_time = avio_rb64(pb); - avio_rb64(pb); - } else { - creation_time = avio_rb32(pb); - avio_rb32(pb); /* modification time */ - } - mov_metadata_creation_time(&c->fc->metadata, creation_time, c->fc); + mov_metadata_creation_time(c, pb, &c->fc->metadata, version); c->time_scale = avio_rb32(pb); /* time scale */ if (c->time_scale <= 0) { av_log(c->fc, AV_LOG_ERROR, "Invalid mvhd time scale %d, defaulting to 1\n", c->time_scale); From patchwork Sat Apr 15 22:05:54 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 41195 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1411928pzb; Sat, 15 Apr 2023 15:06:22 -0700 (PDT) X-Google-Smtp-Source: AKy350b0glabGag4ioFMKXLQpnPR5IHksUYcLdtslKnoJRK2bFlXcB5x6ha9UCw8QmELjrKM2v0E X-Received: by 2002:a17:907:8a21:b0:94f:3521:394 with SMTP id sc33-20020a1709078a2100b0094f35210394mr1771294ejc.51.1681596382269; Sat, 15 Apr 2023 15:06:22 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681596382; cv=none; d=google.com; s=arc-20160816; b=AQkzoJtM9FnebRde1Ec33koJd9pIUPOc2H+TlLnSG9DbB15r04/Iq1m0fdiqMlhzX/ jMAuuwQhSF1CJNOErzmkh2FHeinJwiy8Ui99wYSaghYsXvDRnczZN0jNyojuFbgwkIJB 9V5Huw9cZ/0JAaXU4I2nWtkCFtlFiCpwM9/lqkPdvOBg1zlmD4j4wjIVsRegECEaVEIh N+j7Za0qni/2zl5ezXQjCR20bdAdt6D2tMqqqGq/uJQZFydIoT7VRdaQj+tOrlcjoCCb YgYfRWr9ggH6QmIrBnEa8raRfQyYf6izaXN2rFG54WHzD5fhtK2B4i76/c6DDEj1ovtb tgEA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=AtYxrHXEK4pbXBJhf64BcUyu/kBybE+zvJpsIXEUUBM=; b=PPiSPh8x7KvTzbph/qQoltWROxAreKfv5Rm90JKv0ilO9d1vFQeECIvIMHcYSe59m1 5GMBAGNIOmodBW3XyiQz5s9GBrGxkUJdaSZ0ZjJQKhXlNAbhhU9AsrUjg4mBox64yJ78 gW9zWbsCB2R5ZBVhXa+PvqeBg74dv0ySj9JNVvdt2Ehw4MsWcgQX1G0w0jlgx69X2R+Q I4f7locVpz/lSNztT+OuzmG7x1T96zWLyvugCpCtoqRrITOAZEtjjHbdG1J2BxYEDkYp +/O9jVaNcm/yKfY7bvIL9sHz/K/gAjYzmGuO9EghdLxRSJV7/5NypNFwZsBnlIjXP8RZ DXEQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id fd10-20020a1709072a0a00b0094f41b55cb8si578275ejc.675.2023.04.15.15.06.21; Sat, 15 Apr 2023 15:06:22 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id A1EB168BDFB; Sun, 16 Apr 2023 01:06:16 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (unknown [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 5D24368B36D for ; Sun, 16 Apr 2023 01:06:10 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 5BA34E8A15; Sun, 16 Apr 2023 00:05:30 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id HN-YWDM_JXvt; Sun, 16 Apr 2023 00:05:25 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 48238E8A01; Sun, 16 Apr 2023 00:05:25 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 16 Apr 2023 00:05:54 +0200 Message-Id: <20230415220558.16122-2-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230415220558.16122-1-cus@passwd.hu> References: <20230415220558.16122-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 2/6] avformat/mov: restrict unix timestamp hack to version 0 mdhd/mvhd 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 8b7wsAKf04rD Commit 23eeffcd48a15e73fb2649b712870b6d101c5471 added a hack to support invalid files where the creation date was encoded as a classic unix timestamp. Let's reduce the scope of the hack by only applying it to version 0 mdhd/mvhd atoms. Also warn the user of such possibly broken files. Signed-off-by: Marton Balint --- libavformat/mov.c | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/libavformat/mov.c b/libavformat/mov.c index 5d00ff6e8b..1b3c1d7683 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1524,10 +1524,13 @@ static void mov_metadata_creation_time(MOVContext *c, AVIOContext *pb, AVDiction } else { time = avio_rb32(pb); avio_rb32(pb); /* modification time */ + if (time > 0 && time < 2082844800) { + av_log(c->fc, AV_LOG_WARNING, "Detected creation time before 1970, parsing as unix timestamp.\n"); + time += 2082844800; + } } if (time) { - if (time >= 2082844800) - time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ + time -= 2082844800; /* seconds between 1904-01-01 and Epoch */ if ((int64_t)(time * 1000000ULL) / 1000000 != time) { av_log(c->fc, AV_LOG_DEBUG, "creation_time is not representable\n"); From patchwork Sat Apr 15 22:05:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 41197 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1412095pzb; Sat, 15 Apr 2023 15:06:40 -0700 (PDT) X-Google-Smtp-Source: AKy350byQM7hf/TqhasJKwMcZS+3etU2VeOhQES8c1OO5+9XjVYQW2xaOabqyUtpF7vae48sKJ1x X-Received: by 2002:a17:906:9711:b0:94e:dda6:993d with SMTP id k17-20020a170906971100b0094edda6993dmr3009337ejx.3.1681596400069; Sat, 15 Apr 2023 15:06:40 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681596400; cv=none; d=google.com; s=arc-20160816; b=XGntlEYiAxFdgFkGxKGbdJ62/+t5FZ2WPDEGgHFSr2gEd8yi9trYrUk4UfBamYiyym veT7s0bOCMKdSqEwfdDbvFxwkCbpYHg3PPJ/QcUw1pMysEoRDa366A+MIKi9cQ+yvSDi nKdP76gVWO0/09ndDq/K7tj+yEbJzC0SsCCVSwnV6gH2cW5HBQYnjjhH48OTaYGNJYTk 9lJnudehSwN7mQBBuq7DHcUnzKuW/O1fFJDFleI5T8YlA1HNi1iy8Ncmy1GT8mQR/V/G 10F0lNDtyafj/IPCJDDjY+ghSoSvAVrjs6VrJKttqQQenkJpS/k/mSZrAj8zUqTfHqS8 AWcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=grfk3M5e3zjkcF9hyFXhHx6+AfPfhaL0dY7x2NeJiBM=; b=gnqPawZuavmiXWRXeDN6/TcGpkvJmxw4ZUetC4ztZDWZlOy2OfcLCzMou2thsUTsHt 7xzTafL5+WG6a09DAr4+a939rJvfevqOIU/hNTl8LJehxAUIwEH4KCdiJzNy3yU0TnYP Exxyl7Hz5r7IecNQ9a9WedALfnlH0z5qacKx/+kxdeAn3dlPtD0N/pYA7Mj7H8Pae58t shi555yR0LcCFc0hVd01K9gsNAf9yChH+rmgycV2C81urrYIIYemqTTYhWUsNJUkQ+FE chVt7tzkgOyYktsfegQ9/TBXjGubmc3A6kfRdb2poabEfU4MnfrK2Lqx/UTkSAr+a0tF Pv7w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id su21-20020a17090703d500b0094f507a9f21si131491ejb.710.2023.04.15.15.06.39; Sat, 15 Apr 2023 15:06:40 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B979068BC3C; Sun, 16 Apr 2023 01:06:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (unknown [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 550B668BDFF for ; Sun, 16 Apr 2023 01:06:12 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D26FDE8A01; Sun, 16 Apr 2023 00:05:32 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id jmTcjfg5auc1; Sun, 16 Apr 2023 00:05:30 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 621B5E8A25; Sun, 16 Apr 2023 00:05:30 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 16 Apr 2023 00:05:55 +0200 Message-Id: <20230415220558.16122-3-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230415220558.16122-1-cus@passwd.hu> References: <20230415220558.16122-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 3/6] avformat/movenc: factorize determining mdhd/mvhd/tkhd version 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: /OaTEZCV3UQ0 Also make duration check for mvhd more consistent with the others, write version 1 of mvhd if duration is at least INT32_MAX instead of UINT32_MAX. Signed-off-by: Marton Balint --- libavformat/movenc.c | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index c370922c7d..32a675b285 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -3269,14 +3269,20 @@ static int64_t calc_pts_duration(MOVMuxContext *mov, MOVTrack *track) return end - start; } +static int mov_mdhd_mvhd_tkhd_version(MOVMuxContext *mov, MOVTrack *track, int64_t duration) +{ + if (track && track->mode == MODE_ISM) + return 1; + if (duration < INT32_MAX) + return 0; + return 1; +} + static int mov_write_mdhd_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) { int64_t duration = calc_samples_pts_duration(mov, track); - int version = duration < INT32_MAX ? 0 : 1; - - if (track->mode == MODE_ISM) - version = 1; + int version = mov_mdhd_mvhd_tkhd_version(mov, track, duration); (version == 1) ? avio_wb32(pb, 44) : avio_wb32(pb, 32); /* size */ ffio_wfourcc(pb, "mdhd"); @@ -3362,8 +3368,6 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov, else duration *= mov->avif_loop_count; - version = duration < INT32_MAX ? 0 : 1; - if (st) { if (mov->per_stream_grouping) group = st->index; @@ -3379,8 +3383,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov, if (track->flags & MOV_TRACK_ENABLED) flags |= MOV_TKHD_FLAG_ENABLED; - if (track->mode == MODE_ISM) - version = 1; + version = mov_mdhd_mvhd_tkhd_version(mov, track, duration); (version == 1) ? avio_wb32(pb, 104) : avio_wb32(pb, 92); /* size */ ffio_wfourcc(pb, "tkhd"); @@ -3863,7 +3866,7 @@ static int mov_write_mvhd_tag(AVIOContext *pb, MOVMuxContext *mov) max_track_id = 1; } - version = max_track_len < UINT32_MAX ? 0 : 1; + version = mov_mdhd_mvhd_tkhd_version(mov, NULL, max_track_len); avio_wb32(pb, version == 1 ? 120 : 108); /* size */ ffio_wfourcc(pb, "mvhd"); From patchwork Sat Apr 15 22:05:56 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 41198 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1412162pzb; Sat, 15 Apr 2023 15:06:48 -0700 (PDT) X-Google-Smtp-Source: AKy350a1sjyI+R1s7B7HMekYVUUJg72M91HHl0JkfV2hgF2FlpCoNf53tL3ifj/BMbHdZFT6pdzl X-Received: by 2002:a05:6402:1486:b0:504:8a10:ac34 with SMTP id e6-20020a056402148600b005048a10ac34mr9939672edv.24.1681596408544; Sat, 15 Apr 2023 15:06:48 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681596408; cv=none; d=google.com; s=arc-20160816; b=hnNIchT2FZSLU7Qjr1V5abmXM0RWcNhUo1Ze/Zng0osTgWacNZV/3WP3Y1BNfA7IVy 7rkKzpTydMUJYJmY2G1lxjDFqu/kufhTH8c4Fa0NjHZwYFJWZv1cTSWDi6JtjXiiT3sM QOz61AxO3rNgAmV+nPZ4PU3wl2fqehlyzcsfn+6Z+/0hfhSftTJtvDvBfav28YgVjXaC GW1Cf/jDTjhcgABFAH/brWDOfiQFFmcIQc/0xi8SR2gIEZ6TD8XWxAVWmIZWNrG02eBG 5BqAJjichuINQ8uejiYuk1itH5jYm7K4lIIiK8hJEbn3UORH4CcGuTxF26yEQIhoMkBt VOsg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=eePVqQWDzqbmR2L7GgxGlMaucFiBAtUQ4tK5rh5Uj40=; b=L71+exaQXPZY/1FYdo8AFCFfITeP8Kg5rJaodMb1wYLwijnaJZZsoRml/OEdXkBtZY QqI1QuuThG+M/ZLe3WCQH4mhD0fNaRgAwHlRN6UiLgyn4Lx0ReN1PvTCW2n6SK+wV+6k +AQsW3wog4SdBhRKB1eqzfaGmXYmw1vGaWBlvzy2I4ACoYOSIsBMALFmfaqC7/G1ymhd ay6plNFVfcbrwUlbkmKjHK2CY4TQ1tDUeXlR/5unrG1X+rItspy/VNLX93HJxeEABgnJ fFwaWmLLlaX0vtSj15YzXe9906CPInK2SYu2p64ldOqDynYoZU0RcJuXJsNCUso5F6F9 r5zQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id r26-20020a056402019a00b0050508b222f1si6361594edv.461.2023.04.15.15.06.48; Sat, 15 Apr 2023 15:06:48 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C06F368BE2B; Sun, 16 Apr 2023 01:06:20 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (unknown [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id C127368BE11 for ; Sun, 16 Apr 2023 01:06:13 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 47F13E8A2D; Sun, 16 Apr 2023 00:05:34 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 0VN4Yjvxe_Qa; Sun, 16 Apr 2023 00:05:33 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id B108AE8A0F; Sun, 16 Apr 2023 00:05:31 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 16 Apr 2023 00:05:56 +0200 Message-Id: <20230415220558.16122-4-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230415220558.16122-1-cus@passwd.hu> References: <20230415220558.16122-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 4/6] avformat/smoothstreamingenc: do not override movflag defaults 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: CUXNvmPCK3ng Signed-off-by: Marton Balint --- libavformat/smoothstreamingenc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/smoothstreamingenc.c b/libavformat/smoothstreamingenc.c index 66e6313934..3c050ca54e 100644 --- a/libavformat/smoothstreamingenc.c +++ b/libavformat/smoothstreamingenc.c @@ -340,7 +340,7 @@ static int ism_write_header(AVFormatContext *s) } av_dict_set_int(&opts, "ism_lookahead", c->lookahead_count, 0); - av_dict_set(&opts, "movflags", "frag_custom", 0); + av_dict_set(&opts, "movflags", "+frag_custom", 0); ret = avformat_write_header(ctx, &opts); av_dict_free(&opts); if (ret < 0) { From patchwork Sat Apr 15 22:05:57 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 41199 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1412232pzb; Sat, 15 Apr 2023 15:06:57 -0700 (PDT) X-Google-Smtp-Source: AKy350Z0iksGOtzYiWc4aon+/25y+nXK8G2oEhlJm0uvj1rqc7wGEz+V6DG2pmYQoT7gOYQh9dOH X-Received: by 2002:a17:907:2149:b0:94a:4d06:3de3 with SMTP id rk9-20020a170907214900b0094a4d063de3mr2788785ejb.72.1681596417570; Sat, 15 Apr 2023 15:06:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681596417; cv=none; d=google.com; s=arc-20160816; b=iGy4sj9uWsbMdqHkrpE6XlylxMxYAWXrJez+mC30LsgozgKwW6M3zBDtJZsoyn+IHR ldKZwU6Y0RpN0fuyIkGE/zVG9+AsdSgrROalGYQrqkjldperZ0COZP8Tn597967VsknV VPexjcPrrJJbD25yfGQm6rArLgCamKRiOFkZV6wyDGjaWqypexiF3hyRk5Yw/3WPiuX2 4d1nqauhUMaoMgaHW531Iph1P2nH2iTSzT/dxIYTRdxLEiMpCKr3q+ryTHTP0GKHp/V9 8gA9gPzEvzHPHG9r+JPFDv7sv4RewO7P0k+p1qgZRzvZKH3b9dxrVScSCWWmBxPuwzDK LpXA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=pGUfyFX+Shxx17f+bpTmVaqI9uG3eFdpcsBeP5qm3pg=; b=Cy8pBkLV8SexUQMLNcW+/Phm4KeSCDlWGz2TIN7YuivvjqSFeKK0Op8JQLpo8qMB30 anmYhlS/W1PumvcfqBEAiriXdyYG7Vpnt+plBC1owKfs6V6WDK/rE6mbp4J936gw9Db7 9dPfWtAM8MfV7rxDo6fQVJMAiGjsG6Kh+wuLpPwpItk3JPUkj4acUnmJcgkmQD0jb6Yb JJW7rOG0I80JDo+b2q9j2OBgpfMaZ4DUbtloG91vweWOcp9r4I7ClfRYybsEqXOfJneK Z4yb1w1yoefvNUvGwrLm+WYjRZwhxYM55xNwFPkxxX/+5/i0uDho4BDTSfSybGdcHpVp TwVg== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id wi24-20020a170906fd5800b0094f174acc94si2412345ejb.408.2023.04.15.15.06.57; Sat, 15 Apr 2023 15:06:57 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id B768B68BE34; Sun, 16 Apr 2023 01:06:21 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (unknown [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 64A3E68BE17 for ; Sun, 16 Apr 2023 01:06:15 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id E6378E0C64; Sun, 16 Apr 2023 00:05:35 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wWcfOnw6GrZw; Sun, 16 Apr 2023 00:05:34 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 3651AE8A1B; Sun, 16 Apr 2023 00:05:33 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 16 Apr 2023 00:05:57 +0200 Message-Id: <20230415220558.16122-5-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230415220558.16122-1-cus@passwd.hu> References: <20230415220558.16122-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 5/6] tests: do not override movflags defaults 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: +OjOTdoVMVu7 It does not matter if the default is 0, but still it is cleaner that way. Signed-off-by: Marton Balint --- libavformat/tests/movenc.c | 54 +++++++++++++++++++------------------- tests/fate/subtitles.mak | 2 +- tests/fate/vcodec.mak | 2 +- 3 files changed, 29 insertions(+), 29 deletions(-) diff --git a/libavformat/tests/movenc.c b/libavformat/tests/movenc.c index 6f9d381927..fca3213285 100644 --- a/libavformat/tests/movenc.c +++ b/libavformat/tests/movenc.c @@ -389,7 +389,7 @@ int main(int argc, char **argv) // samples. One moov+mdat with 1 second of data and one moof+mdat with 1 // second of data. init_out("non-empty-moov"); - av_dict_set(&opts, "movflags", "frag_keyframe", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe", 0); init(0, 0); mux_gops(2); finish(); @@ -398,7 +398,7 @@ int main(int argc, char **argv) // Write a similar file, but with B-frames and audio preroll, handled // via an edit list. init_out("non-empty-moov-elst"); - av_dict_set(&opts, "movflags", "frag_keyframe", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe", 0); av_dict_set(&opts, "use_editlist", "1", 0); init(1, 1); mux_gops(2); @@ -410,7 +410,7 @@ int main(int argc, char **argv) // of the first audio packet is > 0, but it is set to zero since edit // lists aren't used, increasing the duration of the first packet instead. init_out("non-empty-moov-no-elst"); - av_dict_set(&opts, "movflags", "frag_keyframe", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(1, 0); mux_gops(2); @@ -420,7 +420,7 @@ int main(int argc, char **argv) format = "ismv"; // Write an ISMV, with B-frames and audio preroll. init_out("ismv"); - av_dict_set(&opts, "movflags", "frag_keyframe", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe", 0); init(1, 1); mux_gops(2); finish(); @@ -430,7 +430,7 @@ int main(int argc, char **argv) // An initial moov that doesn't contain any samples, followed by two // moof+mdat pairs. init_out("empty-moov"); - av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+empty_moov", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(0, 0); mux_gops(2); @@ -442,7 +442,7 @@ int main(int argc, char **argv) // pts/dts 0. avoid_negative_ts behaves in the same way as // in non-empty-moov-no-elst above. init_out("empty-moov-no-elst"); - av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+empty_moov", 0); init(1, 0); mux_gops(2); finish(); @@ -454,7 +454,7 @@ int main(int argc, char **argv) // This should trigger a warning - we check that the warning is produced. init_count_warnings(); init_out("empty-moov-no-elst-no-adjust"); - av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+empty_moov", 0); av_dict_set(&opts, "avoid_negative_ts", "disabled", 0); init(1, 0); mux_gops(2); @@ -467,7 +467,7 @@ int main(int argc, char **argv) // Verify that delay_moov produces the same as empty_moov for // simple input init_out("delay-moov"); - av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+delay_moov", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(0, 0); mux_gops(2); @@ -477,7 +477,7 @@ int main(int argc, char **argv) // Test writing content that requires an edit list using delay_moov init_out("delay-moov-elst"); - av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+delay_moov", 0); init(1, 1); mux_gops(2); finish(); @@ -486,7 +486,7 @@ int main(int argc, char **argv) // Test writing a file with one track lacking packets, with delay_moov. skip_write_audio = 1; init_out("delay-moov-empty-track"); - av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+delay_moov", 0); init(0, 0); mux_gops(2); // The automatic flushing shouldn't output anything, since we're still @@ -501,7 +501,7 @@ int main(int argc, char **argv) // Check that manually flushing still outputs things as expected. This // produces two fragments, while the one above produces only one. init_out("delay-moov-empty-track-flush"); - av_dict_set(&opts, "movflags", "frag_custom+delay_moov", 0); + av_dict_set(&opts, "movflags", "+frag_custom+delay_moov", 0); init(0, 0); mux_gops(1); av_write_frame(ctx, NULL); // Force writing the moov @@ -519,7 +519,7 @@ int main(int argc, char **argv) // Verify that the header written by delay_moov when manually flushed // is identical to the one by empty_moov. init_out("empty-moov-header"); - av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+empty_moov", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(0, 0); close_out(); @@ -542,7 +542,7 @@ int main(int argc, char **argv) finish(); init_out("delay-moov-header"); - av_dict_set(&opts, "movflags", "frag_custom+delay_moov", 0); + av_dict_set(&opts, "movflags", "+frag_custom+delay_moov", 0); av_dict_set(&opts, "use_editlist", "0", 0); init(0, 0); check(out_size == 0, "Output written during init with delay_moov"); @@ -563,7 +563,7 @@ int main(int argc, char **argv) // Verify that we can produce an identical second fragment without // writing the first one. First write the reference fragments that // we want to reproduce. - av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash", 0); + av_dict_set(&opts, "movflags", "+frag_custom+empty_moov+dash", 0); init(0, 0); mux_gops(1); av_write_frame(ctx, NULL); // Output the first fragment @@ -576,7 +576,7 @@ int main(int argc, char **argv) // Produce the same second fragment without actually writing the first // one before. - av_dict_set(&opts, "movflags", "frag_custom+empty_moov+dash+frag_discont", 0); + av_dict_set(&opts, "movflags", "+frag_custom+empty_moov+dash+frag_discont", 0); av_dict_set(&opts, "fragment_index", "2", 0); av_dict_set(&opts, "avoid_negative_ts", "disabled", 0); av_dict_set(&opts, "use_editlist", "0", 0); @@ -591,7 +591,7 @@ int main(int argc, char **argv) // Produce the same thing by using delay_moov, which requires a slightly // different call sequence. - av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0); + av_dict_set(&opts, "movflags", "+frag_custom+delay_moov+dash+frag_discont", 0); av_dict_set(&opts, "fragment_index", "2", 0); init(0, 0); skip_gops(1); @@ -607,7 +607,7 @@ int main(int argc, char **argv) // Test discontinuously written fragments with B-frames (where the // assumption of starting at pts=0 works) but not with audio preroll // (which can't be guessed). - av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash", 0); + av_dict_set(&opts, "movflags", "+frag_custom+delay_moov+dash", 0); init(1, 0); mux_gops(1); init_out("delay-moov-elst-init"); @@ -622,7 +622,7 @@ int main(int argc, char **argv) memcpy(content, hash, HASH_SIZE); finish(); - av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0); + av_dict_set(&opts, "movflags", "+frag_custom+delay_moov+dash+frag_discont", 0); av_dict_set(&opts, "fragment_index", "2", 0); init(1, 0); skip_gops(1); @@ -640,7 +640,7 @@ int main(int argc, char **argv) // Test discontinuously written fragments with B-frames and audio preroll, // properly signaled. - av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash", 0); + av_dict_set(&opts, "movflags", "+frag_custom+delay_moov+dash", 0); init(1, 1); mux_gops(1); init_out("delay-moov-elst-signal-init"); @@ -655,7 +655,7 @@ int main(int argc, char **argv) memcpy(content, hash, HASH_SIZE); finish(); - av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0); + av_dict_set(&opts, "movflags", "+frag_custom+delay_moov+dash+frag_discont", 0); av_dict_set(&opts, "fragment_index", "2", 0); init(1, 1); signal_init_ts(); @@ -673,7 +673,7 @@ int main(int argc, char **argv) // Test muxing discontinuous fragments with very large (> (1<<31)) timestamps. - av_dict_set(&opts, "movflags", "frag_custom+delay_moov+dash+frag_discont", 0); + av_dict_set(&opts, "movflags", "+frag_custom+delay_moov+dash+frag_discont", 0); av_dict_set(&opts, "fragment_index", "2", 0); init(1, 1); signal_init_ts(); @@ -700,7 +700,7 @@ int main(int argc, char **argv) // match - the input stream starts at pts=-2048, but that part is excluded // by the edit list. init_out("vfr"); - av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+delay_moov+dash", 0); init_fps(1, 1, 3); mux_frames(gop_size/2, 0); duration /= 10; @@ -719,7 +719,7 @@ int main(int argc, char **argv) init_count_warnings(); clear_duration = 1; init_out("vfr-noduration"); - av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+dash", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+delay_moov+dash", 0); init_fps(1, 1, 3); mux_frames(gop_size/2, 0); duration /= 10; @@ -735,7 +735,7 @@ int main(int argc, char **argv) // this will cause write_data_type to be called with the type unknown. force_iobuf_size = 1500; init_out("large_frag"); - av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+delay_moov", 0); init_fps(1, 1, 3); mux_gops(2); finish(); @@ -748,7 +748,7 @@ int main(int argc, char **argv) // the expected, but we simulate dropped frames at one point. do_interleave = 1; init_out("vfr-noduration-interleave"); - av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+delay_moov", 0); av_dict_set(&opts, "frag_duration", "650000", 0); init_fps(1, 1, 30); mux_frames(gop_size/2, 0); @@ -771,7 +771,7 @@ int main(int argc, char **argv) // with negative cts values, removing the edit list for the // video track. init_out("delay-moov-elst-neg-cts"); - av_dict_set(&opts, "movflags", "frag_keyframe+delay_moov+negative_cts_offsets", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+delay_moov+negative_cts_offsets", 0); init(1, 1); mux_gops(2); finish(); @@ -781,7 +781,7 @@ int main(int argc, char **argv) // with negative cts values, avoiding any edit lists, allowing // to use empty_moov instead of delay_moov. init_out("empty-moov-neg-cts"); - av_dict_set(&opts, "movflags", "frag_keyframe+empty_moov+negative_cts_offsets", 0); + av_dict_set(&opts, "movflags", "+frag_keyframe+empty_moov+negative_cts_offsets", 0); init(1, 0); mux_gops(2); finish(); diff --git a/tests/fate/subtitles.mak b/tests/fate/subtitles.mak index e6684a814b..59595b9cc1 100644 --- a/tests/fate/subtitles.mak +++ b/tests/fate/subtitles.mak @@ -39,7 +39,7 @@ FATE_SUBTITLES_ASS-$(call DEMDEC, MOV, MOVTEXT) += fate-sub-movtext fate-sub-movtext: CMD = fmtstdout ass -i $(TARGET_SAMPLES)/sub/MovText_capability_tester.mp4 FATE_SUBTITLES-$(call ENCDEC, MOVTEXT, MOV) += fate-binsub-movtextenc -fate-binsub-movtextenc: CMD = md5 -i $(TARGET_SAMPLES)/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f mp4 -flags +bitexact -fflags +bitexact -movflags frag_keyframe+empty_moov +fate-binsub-movtextenc: CMD = md5 -i $(TARGET_SAMPLES)/sub/MovText_capability_tester.mp4 -map 0 -scodec mov_text -f mp4 -flags +bitexact -fflags +bitexact -movflags +frag_keyframe+empty_moov FATE_SUBTITLES_ASS-$(call DEMDEC, MPL2, MPL2) += fate-sub-mpl2 fate-sub-mpl2: CMD = fmtstdout ass -i $(TARGET_SAMPLES)/sub/MPL2_capability_tester.txt diff --git a/tests/fate/vcodec.mak b/tests/fate/vcodec.mak index bf9de0327a..fbee264a9d 100644 --- a/tests/fate/vcodec.mak +++ b/tests/fate/vcodec.mak @@ -111,7 +111,7 @@ fate-vsynth%-dnxhd-1080i-10bit: ENCOPTS = -s hd1080 -b 185M -flags +ildct \ -pix_fmt yuv422p10 -frames 5 -qmax 8 fate-vsynth%-dnxhd-1080i-10bit: DECOPTS = -sws_flags area+accurate_rnd+bitexact -fate-vsynth%-dnxhd-1080i-colr: ENCOPTS = -s hd1080 -b 120M -flags +ildct -movflags write_colr \ +fate-vsynth%-dnxhd-1080i-colr: ENCOPTS = -s hd1080 -b 120M -flags +ildct -movflags +write_colr \ -pix_fmt yuv422p -frames 5 -qmax 8 fate-vsynth%-dnxhd-1080i-colr: DECOPTS = -sws_flags area+accurate_rnd+bitexact From patchwork Sat Apr 15 22:05:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marton Balint X-Patchwork-Id: 41200 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4645:b0:e3:3194:9d20 with SMTP id eb5csp1412292pzb; Sat, 15 Apr 2023 15:07:07 -0700 (PDT) X-Google-Smtp-Source: AKy350aBoIqg+3gYM/TmqZlMHv0SRy9lawkkF3FL+7VjgYr7gyVrPMze7+7EyjGf4AYdjmllGBO4 X-Received: by 2002:a17:906:a0c7:b0:8b1:7ae8:ba6f with SMTP id bh7-20020a170906a0c700b008b17ae8ba6fmr2873889ejb.16.1681596426944; Sat, 15 Apr 2023 15:07:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681596426; cv=none; d=google.com; s=arc-20160816; b=nMflr1FODIq1LuBD6g+Sg6aAAH5BWxI4TGqa4z8Aq3teXSeRrya8FrBizqDMAHCemx 1AUnpFu7IlOLZoIQntMPaFSzJ/GW9NCZA8vus+uEhnlCUCvG95JWt+C+0p3fiQ9ROdhM BRsnsSkA+GWOIt7lX7pqt70fxpRBFeiAMsrHEadjXELdWXkKx0HMZrCpUR56bnFxbz3A We9QqA3gTOAKycqFiQW5uJd5601W/FLNM5orv3zmFCeBGtu0sqgi4AklpXQQg57YwRi4 GVOxrd/ptb5xvegWJJ6G5lZhVcrwtfZLSinD4j8shAMcj0PWDtBgtON32Pq/zgMfrsa7 +q8Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:mime-version:references:in-reply-to :message-id:date:to:from:delivered-to; bh=f/V2hEyVQM3ZHEl6FXHx8DuOuamMG4ASefuqCHSQ63k=; b=Gz+/3Es1batIAsJGBqPZGwsILKiYf/tUk7lXYmiq/YuXskg/s3EnFCigZFD9JzaNOJ P1j/7+cIGdxaTIirLJZl0yfA8+G+kKEsrrG3uzOkEfHLEc6UypM1tuEOb+HBoVY9QDJV D/4yM5OXxMEdLGcfwBjCt5tDc6AAfYkcRUhTFOjUsKmwIl+34uqqX9m3YUQtaaQr9K0T cpz9N3gh6KY9EeBCVZr9FpUYxRC/ILAvPxA5+huH/BhjucicOXAf/YT0SBvp9hl8xvVT nvL/T2GCSKXkg1Xrz1hagkv+zbQ2bhON6S09RBgpfniw8Sf9Uo6AwxTyEqA1xl3LmLNg N1PA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id b15-20020a170906708f00b0092be625bf1dsi6955064ejk.826.2023.04.15.15.07.06; Sat, 15 Apr 2023 15:07:06 -0700 (PDT) Received-SPF: pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) client-ip=79.124.17.100; Authentication-Results: mx.google.com; spf=pass (google.com: domain of ffmpeg-devel-bounces@ffmpeg.org designates 79.124.17.100 as permitted sender) smtp.mailfrom=ffmpeg-devel-bounces@ffmpeg.org Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id AD5AF68BE41; Sun, 16 Apr 2023 01:06:24 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from iq.passwd.hu (unknown [217.27.212.140]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 4E67668BE3D for ; Sun, 16 Apr 2023 01:06:17 +0300 (EEST) Received: from localhost (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id D5D12E8A0F; Sun, 16 Apr 2023 00:05:37 +0200 (CEST) X-Virus-Scanned: amavisd-new at passwd.hu Received: from iq.passwd.hu ([127.0.0.1]) by localhost (iq.passwd.hu [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id wHeTTzCa-p1g; Sun, 16 Apr 2023 00:05:35 +0200 (CEST) Received: from bluegene.passwd.hu (localhost [127.0.0.1]) by iq.passwd.hu (Postfix) with ESMTP id 48175E8A30; Sun, 16 Apr 2023 00:05:34 +0200 (CEST) From: Marton Balint To: ffmpeg-devel@ffmpeg.org Date: Sun, 16 Apr 2023 00:05:58 +0200 Message-Id: <20230415220558.16122-6-cus@passwd.hu> X-Mailer: git-send-email 2.35.3 In-Reply-To: <20230415220558.16122-1-cus@passwd.hu> References: <20230415220558.16122-1-cus@passwd.hu> MIME-Version: 1.0 Subject: [FFmpeg-devel] [PATCH 6/6] doc/muxers: reorder and cleanup mov muxer options 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: Marton Balint Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: wNZF7lofnTDq Make various movflags grouped together similar to how it is done for other options. Signed-off-by: Marton Balint --- doc/muxers.texi | 88 +++++++++++++++++++++++++------------------------ 1 file changed, 45 insertions(+), 43 deletions(-) diff --git a/doc/muxers.texi b/doc/muxers.texi index 79dd864182..d1e825eec5 100644 --- a/doc/muxers.texi +++ b/doc/muxers.texi @@ -1630,8 +1630,10 @@ MOV/MP4/ISMV (Smooth Streaming) muxer. The mov/mp4/ismv muxer supports fragmentation. Normally, a MOV/MP4 file has all the metadata about all packets stored in one location (written at the end of the file, it can be moved to the start for -better playback by adding @var{faststart} to the @var{movflags}, or -using the @command{qt-faststart} tool). A fragmented +better playback by adding @code{+faststart} to the @code{-movflags}, or +using the @command{qt-faststart} tool). + +A fragmented file consists of a number of fragments, where packets and metadata about these packets are stored together. Writing a fragmented file has the advantage that the file is decodable even if the @@ -1641,40 +1643,34 @@ very long files (since writing normal MOV/MP4 files stores info about every single packet in memory until the file is closed). The downside is that it is less compatible with other applications. -@subsection Options +Fragmentation is enabled by setting one of the options that define +how to cut the file into fragments: @code{-frag_duration}, @code{-frag_size}, +@code{-min_frag_duration}, @code{-movflags +frag_keyframe} and +@code{-movflags +frag_custom}. If more than one condition is specified, +fragments are cut when one of the specified conditions is fulfilled. The +exception to this is @code{-min_frag_duration}, which has to be fulfilled for +any of the other conditions to apply. -Fragmentation is enabled by setting one of the AVOptions that define -how to cut the file into fragments: +@subsection Options @table @option -@item -moov_size @var{bytes} -Reserves space for the moov atom at the beginning of the file instead of placing the -moov atom at the end. If the space reserved is insufficient, muxing will fail. -@item -movflags frag_keyframe -Start a new fragment at each video keyframe. -@item -frag_duration @var{duration} +@item frag_duration @var{duration} Create fragments that are @var{duration} microseconds long. -@item -frag_size @var{size} +@item frag_size @var{size} Create fragments that contain up to @var{size} bytes of payload data. -@item -movflags frag_custom +@item min_frag_duration @var{duration} +Don't create fragments that are shorter than @var{duration} microseconds long. +@item movflags @var{flags} +Set various muxing switches. The following flags can be used: +@table @samp +@item frag_keyframe +Start a new fragment at each video keyframe. +@item frag_custom Allow the caller to manually choose when to cut fragments, by calling @code{av_write_frame(ctx, NULL)} to write a fragment with the packets written so far. (This is only useful with other applications integrating libavformat, not from @command{ffmpeg}.) -@item -min_frag_duration @var{duration} -Don't create fragments that are shorter than @var{duration} microseconds long. -@end table - -If more than one condition is specified, fragments are cut when -one of the specified conditions is fulfilled. The exception to this is -@code{-min_frag_duration}, which has to be fulfilled for any of the other -conditions to apply. - -Additionally, the way the output file is written can be adjusted -through a few other options: - -@table @option -@item -movflags empty_moov +@item empty_moov Write an initial moov atom directly at the start of the file, without describing any samples in it. Generally, an mdat/moov pair is written at the start of the file, as a normal MOV/MP4 file, containing only @@ -1683,43 +1679,40 @@ mdat atom, and the moov atom only describes the tracks but has a zero duration. This option is implicitly set when writing ismv (Smooth Streaming) files. -@item -movflags separate_moof +@item separate_moof Write a separate moof (movie fragment) atom for each track. Normally, packets for all tracks are written in a moof atom (which is slightly more efficient), but with this option set, the muxer writes one moof/mdat pair for each track, making it easier to separate tracks. This option is implicitly set when writing ismv (Smooth Streaming) files. -@item -movflags skip_sidx +@item skip_sidx Skip writing of sidx atom. When bitrate overhead due to sidx atom is high, this option could be used for cases where sidx atom is not mandatory. When global_sidx flag is enabled, this option will be ignored. -@item -movflags faststart +@item faststart Run a second pass moving the index (moov atom) to the beginning of the file. This operation can take a while, and will not work in various situations such as fragmented output, thus it is not enabled by default. -@item -movflags rtphint +@item rtphint Add RTP hinting tracks to the output file. -@item -movflags disable_chpl +@item disable_chpl Disable Nero chapter markers (chpl atom). Normally, both Nero chapters and a QuickTime chapter track are written to the file. With this option set, only the QuickTime chapter track will be written. Nero chapters can cause failures when the file is reprocessed with certain tagging programs, like mp3Tag 2.61a and iTunes 11.3, most likely other versions are affected as well. -@item -movflags omit_tfhd_offset +@item omit_tfhd_offset Do not write any absolute base_data_offset in tfhd atoms. This avoids tying fragments to absolute byte positions in the file/streams. -@item -movflags default_base_moof +@item default_base_moof Similarly to the omit_tfhd_offset, this flag avoids writing the absolute base_data_offset field in tfhd atoms, but does so by using the new default-base-is-moof flag instead. This flag is new from 14496-12:2012. This may make the fragments easier to parse in certain circumstances (avoiding basing track fragment location calculations on the implicit end of the previous track fragment). -@item -write_tmcd -Specify @code{on} to force writing a timecode track, @code{off} to disable it -and @code{auto} to write a timecode track only for mov and mp4 output (default). -@item -movflags negative_cts_offsets +@item negative_cts_offsets Enables utilization of version 1 of the CTTS box, in which the CTS offsets can be negative. This enables the initial sample to have DTS/CTS of zero, and reduces the need for edit lists for some cases such as video tracks with @@ -1727,15 +1720,24 @@ B-frames. Additionally, eases conformance with the DASH-IF interoperability guidelines. This option is implicitly set when writing ismv (Smooth Streaming) files. +@end table + +@item moov_size @var{bytes} +Reserves space for the moov atom at the beginning of the file instead of placing the +moov atom at the end. If the space reserved is insufficient, muxing will fail. + +@item write_tmcd +Specify @code{on} to force writing a timecode track, @code{off} to disable it +and @code{auto} to write a timecode track only for mov and mp4 output (default). -@item -write_btrt @var{bool} +@item write_btrt @var{bool} Force or disable writing bitrate box inside stsd box of a track. The box contains decoding buffer size (in bytes), maximum bitrate and average bitrate for the track. The box will be skipped if none of these values can be computed. Default is @code{-1} or @code{auto}, which will write the box only in MP4 mode. -@item -write_prft +@item write_prft Write producer time reference box (PRFT) with a specified time source for the NTP field in the PRFT box. Set value as @samp{wallclock} to specify timesource as wallclock time and @samp{pts} to specify timesource as input packets' PTS @@ -1746,15 +1748,15 @@ where PTS values are set as as wallclock time at the source. For example, an encoding use case with decklink capture source where @option{video_pts} and @option{audio_pts} are set to @samp{abs_wallclock}. -@item -empty_hdlr_name @var{bool} +@item empty_hdlr_name @var{bool} Enable to skip writing the name inside a @code{hdlr} box. Default is @code{false}. -@item -movie_timescale @var{scale} +@item movie_timescale @var{scale} Set the timescale written in the movie header box (@code{mvhd}). Range is 1 to INT_MAX. Default is 1000. -@item -video_track_timescale @var{scale} +@item video_track_timescale @var{scale} Set the timescale used for video tracks. Range is 0 to INT_MAX. If set to @code{0}, the timescale is automatically set based on the native stream time base. Default is 0.