From patchwork Wed Jan 4 22:16:18 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Venkat X-Patchwork-Id: 39874 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp9124719pzb; Wed, 4 Jan 2023 14:17:03 -0800 (PST) X-Google-Smtp-Source: AMrXdXvLVPaSzUgsMjQJ6qyRLbElutW0uoF/0QrijxcXSEtTP63W8dgcET0Wd1M1TJCj+zOVQ0Fy X-Received: by 2002:aa7:c911:0:b0:48d:4504:32ed with SMTP id b17-20020aa7c911000000b0048d450432edmr12001911edt.37.1672870623186; Wed, 04 Jan 2023 14:17:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672870623; cv=none; d=google.com; s=arc-20160816; b=axo31jRtwd4CuMVdM2fY1gUDc4wrZzBWMPh2318DTaSVxb2CO+o8LPVcHK5C59NkV9 ouA9Uwfqvkl3ItVqkmA3y2UsvdtTazgEfXDpf30wYPxBsY24ekf/HrMJADOvYBprpxXQ orRghx8wYuuYkASIdcnAhs7MHa/MSBF2VECeyJT20NLRYQAK1jFccisGztnNtcXMucsz X3PMaq9ERsyO+SanEgITOMA2qRlbm0iCnDpxg/cvRsSXqXx4r+FIqoqQ8RF5d5+v4mT9 PXnj8Q5Aq0UnIiA4rpuBwdETJsx9DI4xjJS3Vc6wPUfme341Hqa+7UYP8Zf5b8UJcuqw q5BQ== 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:to:from:message-id:mime-version:date :dkim-signature:delivered-to; bh=NcNgPfNvw3G8BSyd1jCk4L2WEBUoeJ6wxVlUhl/F9G8=; b=lpE37QhQW4pzzjOYa3lITVuxWKX+IpvOxTR4rICXaqLqbC4VOUqxtqTS5VCvBMe5yj Nk/IKl76d5hJfz7c3hz/RnbpMssbxZRZUoqgEQ09wG/oM5uXn0ZYTRqkKsOs7DEFyLkv J/r9jjlGLR0u4dzMVoV6kTQ4bRMlWPjF5YqysB+xVLlKUOmujZMgS9UWHGPQrkbaYgvK OzeI5ZdQzGy2kuat+o9LsHCqa0DrHmYy41IgF0bYMTZShfGBnYLoQcBlpL6Ff5Dm4Sq/ ZVN5zlh+Ui2qDNDSJ2uyb9+rHUFCH31Hh6LwL8WNT7Z3t1sapCVjAWHDXqPp5dYypgjC gcoQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=HDe0sWPW; 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 z11-20020a05640235cb00b0046bccab3947si32776014edc.469.2023.01.04.14.16.41; Wed, 04 Jan 2023 14:17:03 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=HDe0sWPW; 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 4242E68B3A2; Thu, 5 Jan 2023 00:16:37 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw1-f201.google.com (mail-yw1-f201.google.com [209.85.128.201]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 9E9C168BBB4 for ; Thu, 5 Jan 2023 00:16:30 +0200 (EET) Received: by mail-yw1-f201.google.com with SMTP id 00721157ae682-4ad7a1bd6f4so72787077b3.21 for ; Wed, 04 Jan 2023 14:16:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:from:to:cc:subject :date:message-id:reply-to; bh=FBkBEFUBNARDRxMCVlFgdC88Nvn3/9kbSZ5Cr+RshJg=; b=HDe0sWPWkC1/xi8QptAdfjDYF3EZ2H7aZo7nCn8+OFLKHSF0W7QJxlM3Nrt105Edwd Qc+bXg6STpW8TbuXjO3Cux+YmjAz5q+w4pJ6hrza0QMmYx3nzDceg3RhMzCWkeQN7cg4 jZdki7NPb2wiZLtKSVEfPV5aWD4rRap35PC6URnF9tyYV3/KIggJa//eCbcICeYVw06X +V4HbrkZ9n3FG2AviKjPCwQteeCsQVE27/PW1+736C4GQNWn/bRuoy3bXI2mGaesd7/M ftYhDo/Yle/mkrBJUmF1N29UJgjjTkJ1OaKIny+BBghyMHu/MpTMdjHa/I+sYWGd7zS8 Vm5w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:mime-version:date:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FBkBEFUBNARDRxMCVlFgdC88Nvn3/9kbSZ5Cr+RshJg=; b=E+g06CdCW4oKrNdS+B3Tmld4PrvhCDaYACQRgXF5UrehkMeDvfrz1Tg+s4cfOd3Gbj fkVcCUBhppYeFKzOhuAkuupf7nWi+9bdlFy/wXqFMqb52JXyaC7NtEpZ3hvTgytCTUXb ctrxpM+0FzQMXoMSB+yN32vYmFgpsFNpFkD43KkOehxFOjDzuRnpBRhyyWL5Omwzkg/q F74CJDOddf5Drgq9ij4W1MS5pOCKzWOGdJzsJrBHO6CFK20RLe2y8weEHQBOxclyi6lY yLYjW+1xTYTy4wJsQO5WJZWvkb0EvL+k6Oz+O4SBxen0U2kPeXoBtywIRBWyCK0RPh/B 8jUw== X-Gm-Message-State: AFqh2kokPzrV/fVVDzQpkqARiRtahzVxJIEw7R+q7Gim9TI1IG952B4L Hw1WDNFCUQfvLB20Kq926dz0CyefeJzRVroS88gdEFJnEkGWux57U9dbw78d0iqMIYWhWJ4Wffk VPKDYLgG6nHWSk4otKk20iG4sYk4HM0OCO2O8uxlJPQ/qWXo4B57ODk0g43dhrfNRLydT X-Received: from vigneshv3.mtv.corp.google.com ([2620:0:1000:2511:9d8e:5d6:981:d60b]) (user=vigneshv job=sendgmr) by 2002:a25:cc7:0:b0:6e0:c7d3:f026 with SMTP id 190-20020a250cc7000000b006e0c7d3f026mr5433026ybm.275.1672870588812; Wed, 04 Jan 2023 14:16:28 -0800 (PST) Date: Wed, 4 Jan 2023 14:16:18 -0800 Mime-Version: 1.0 X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230104221619.919110-1-vigneshv@google.com> From: Vignesh Venkatasubramanian To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 1/2] avformat/movenc: Add movie_timescale option to AVIF 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: Vignesh Venkatasubramanian Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: Kvo/weSrRFcb Allow specifying the movie_timescale options to AVIF ouptut. This also makes sure that when movie_timescale is not specified, the default value of 1000 is used instead of 0. Animated AVIF files which don't specify the movie_timescale will have the correct duration written in the track and movie headers after this change (instead of writing 0). Signed-off-by: Vignesh Venkatasubramanian --- libavformat/movenc.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 7d49892283..36c76f7f60 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -7758,6 +7758,11 @@ static const AVCodecTag codec_f4v_tags[] = { }; #if CONFIG_AVIF_MUXER + +static const AVOption avif_options[] = { + { "movie_timescale", "set movie timescale", offsetof(MOVMuxContext, movie_timescale), AV_OPT_TYPE_INT, {.i64 = MOV_TIMESCALE}, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, + { NULL }, +}; static const AVCodecTag codec_avif_tags[] = { { AV_CODEC_ID_AV1, MKTAG('a','v','0','1') }, { AV_CODEC_ID_NONE, 0 }, @@ -7767,6 +7772,7 @@ static const AVCodecTag *const codec_avif_tags_list[] = { codec_avif_tags, NULL static const AVClass mov_avif_muxer_class = { .class_name = "avif muxer", .item_name = av_default_item_name, + .option = avif_options, .version = LIBAVUTIL_VERSION_INT, }; #endif From patchwork Wed Jan 4 22:16:19 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Vignesh Venkat X-Patchwork-Id: 39873 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:bc95:b0:ad:ade2:bfd2 with SMTP id fx21csp9124710pzb; Wed, 4 Jan 2023 14:17:02 -0800 (PST) X-Google-Smtp-Source: AMrXdXvY82AXOHPaO2+enhF/NUIfUHvhTvf9hq33W6GyYHZTx0ky2cpOedWqyUJDZpDPFukCLHiE X-Received: by 2002:a05:6402:3ce:b0:481:f14d:fda5 with SMTP id t14-20020a05640203ce00b00481f14dfda5mr38852900edw.39.1672870622488; Wed, 04 Jan 2023 14:17:02 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1672870622; cv=none; d=google.com; s=arc-20160816; b=Mh9MqPiLeFZ61RaCLzN92JBl033zOpBLvWdWw/m4MQ5MfHhKbQFDkoBoA47pVE3kY2 zCHFF2Y2t8mFS8K6pQKHGCTJIuxk9fUm+tfDR4hcBX1RGnasSeOHnJXAoq4HYzKzYOod ltCARkPMshMbd6pQ3/lJP7/6CHuh+HzY/UVJE7L+FjpLIJEpVU5RLDF8zUtwfqW9boNW 5mireyE5ueJw6y1CHKcxa4iru5lmj8Q+g8x49+aNSRhjitub+Y/yw5Q3W29R2wqLIEYD S6yESyePs0byRuFByTLqDogla1sdJpPGBxFgfyINbf0WEYrxhe+7arSfX9kvQ+QOS1b1 iwng== 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:to:from:message-id:references :mime-version:in-reply-to:date:dkim-signature:delivered-to; bh=W1Kjcxn02FksnlC93DGAOjEZdTAqFRnXyAHlDtrIb+s=; b=nYV0rRwMt0kU1lYoe9RQHbzBtPfTxaJIu2tbeuMeciW6nW5KrzaYq1dI9PY1Y8qhos awmX0KDTQfIZDud4s+vZ5GO7SZUKGdiwutSF77r28rl64DtX8//YFKH0EU9gcWS1M8O1 GsBYVwcmqMlViCrR5iWKme6xDNhpJPbSTsdokxahdmHb+Nc2J963rUAVB50IwNu37wah HrmRCKBUpRJ3yQFF1CDyh8pIzlH+JkiQ2pJO4Ijfg0iFNqcJwngBWdBjZZpLMrze+3tk V1Z9FkeXNpVKXjOkOv9J8sgpPNzhMLUPZkXJFikxmFzquyg0Si6bjfPaePaZCJpKjkfe z3kw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=jZS88Xfh; 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 g21-20020aa7d1d5000000b00489cfdb858bsi15806051edp.430.2023.01.04.14.16.52; Wed, 04 Jan 2023 14:17:02 -0800 (PST) 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; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20210112 header.b=jZS88Xfh; 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 6332668BC2D; Thu, 5 Jan 2023 00:16:40 +0200 (EET) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-yw1-f202.google.com (mail-yw1-f202.google.com [209.85.128.202]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 50A5A68BC2D for ; Thu, 5 Jan 2023 00:16:34 +0200 (EET) Received: by mail-yw1-f202.google.com with SMTP id 00721157ae682-46a518991cfso329695107b3.18 for ; Wed, 04 Jan 2023 14:16:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=SInEb05g0upWak0VeHinJu85JDCmeDHMBQQ/w7aHKTk=; b=jZS88Xfhz8cr+hRqP9LXnADrakJPdQPCcbW/cNxRzt5iQdRubsWA+nNCZ2BJC4K3+k SnHykaUBOlYQM3VMse9FIKOpLaV4P+3uUTFtc3Eh95/h58qwa2c+vy3mRoeo3nYewmlw XnYx5mlbp+UDF6arBInDr+o+BNcXjXyWAoVDQ7xTPgI3+PCJUKu5jhwXOAz7fsIoBqWw 5coNzyYwzjbFDB0PiqASi5psxcDqJHUp8cbO7ynXwsy1SjUQq+RL3uH57PHepCEIVKYz JegjS0A85Kq6AIT1xyZgJTkivxxZGEUWyDkBZzuTa5wV58reuIyKXWZBgeIxjtNwSYah Nb4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=SInEb05g0upWak0VeHinJu85JDCmeDHMBQQ/w7aHKTk=; b=gHH83y42om79HJvuETzlqRw1Jr0rCD5IVMDX7bIJwKPSSSPCtoAil7gLqyERUyPpTc fV4AYoDq4hvEMcDtZR9Bl9hbbPtPISnGmBRUrDLSRxRwy74M99OFR4h6l492PFBqKCvF YhZzfcd7g5thItG0UK8t3S8Fec3obu2pBeniOQ3I6bBChDIxBv9+6IrtwhGvWbPGZpE6 gQEqulxQWyeC2i3kIIiNJmXybEoo+5XudxZ3RYwYz2bkPfE9cAwXxRRXpx8ADxq2iprm 5DoiEc1PEXya3VgOfXhlecyrJe3PtfNnZoIpSE1f2KqzgTaQ/Vk1IbtI/9ua45UHEM1h ujlQ== X-Gm-Message-State: AFqh2krgly5MMlUhggVnIqMJH3vN3rU0xN8VIej+Y9XMpDCgTpokl7GI iIDt+ciAFdC3MsYggXF6F8dP55YsEN/w55n3ic98c6ht6A7fOhSqw5ySbCCSrYxG/izZ4Wl6MPS frBXBTZnIkDgaW1dBX0qVvqS6DwuEuO36Hn/GElpkpwx8wuba+9UyKHd4cdgOzOjG3wx1 X-Received: from vigneshv3.mtv.corp.google.com ([2620:0:1000:2511:9d8e:5d6:981:d60b]) (user=vigneshv job=sendgmr) by 2002:a25:dd83:0:b0:758:65d6:915f with SMTP id u125-20020a25dd83000000b0075865d6915fmr3668998ybg.582.1672870592845; Wed, 04 Jan 2023 14:16:32 -0800 (PST) Date: Wed, 4 Jan 2023 14:16:19 -0800 In-Reply-To: <20230104221619.919110-1-vigneshv@google.com> Mime-Version: 1.0 References: <20230104221619.919110-1-vigneshv@google.com> X-Mailer: git-send-email 2.39.0.314.g84b9a713c41-goog Message-ID: <20230104221619.919110-2-vigneshv@google.com> From: Vignesh Venkatasubramanian To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH 2/2] avformat/movenc: Add loop parameter to animated AVIF 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: Vignesh Venkatasubramanian Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: PlDynGxJCW3A The HEIF specification permits specifying the looping behavior of animated sequences by using the EditList (elst) box. The track duration will be set to the total duration of all the loops (or infinite) and the duration of a single loop will be set in the edit list box. The default behavior is to loop infinitely. Compliance verification: * This was added in libavif recently [1] and the files produced by ffmpeg after this change have EditList boxes similar to the ones produced by libavif (and avifdec is able to parse the loop count as intended). * ComplianceWarden is ok with the produced files. * Chrome is able to play back the produced files. Signed-off-by: Vignesh Venkatasubramanian --- libavformat/movenc.c | 35 +++++++++++++++++++++++++++++++---- libavformat/movenc.h | 1 + 2 files changed, 32 insertions(+), 4 deletions(-) diff --git a/libavformat/movenc.c b/libavformat/movenc.c index 36c76f7f60..8d31317838 100644 --- a/libavformat/movenc.c +++ b/libavformat/movenc.c @@ -3287,7 +3287,7 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov, int64_t duration = av_rescale_rnd(calc_pts_duration(mov, track), mov->movie_timescale, track->timescale, AV_ROUND_UP); - int version = duration < INT32_MAX ? 0 : 1; + int version; int flags = MOV_TKHD_FLAG_IN_MOVIE; int group = 0; @@ -3295,6 +3295,14 @@ static int mov_write_tkhd_tag(AVIOContext *pb, MOVMuxContext *mov, size_t display_matrix_size; int i; + if (mov->mode == MODE_AVIF) + if (!mov->avif_loop_count) + duration = INT64_MAX; + else + duration *= mov->avif_loop_count; + + version = duration < INT32_MAX ? 0 : 1; + if (st) { if (mov->per_stream_grouping) group = st->index; @@ -3414,7 +3422,10 @@ static int mov_write_tapt_tag(AVIOContext *pb, MOVTrack *track) return update_size(pb, pos); } -// This box seems important for the psp playback ... without it the movie seems to hang +// This box is written in the following cases: +// * Seems important for the psp playback. Without it the movie seems to hang. +// * Used for specifying the looping behavior of animated AVIF (as specified +// in Section 9.6 of the HEIF specification ISO/IEC 23008-12). static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, MOVTrack *track) { @@ -3425,6 +3436,7 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, int entry_size, entry_count, size; int64_t delay, start_ct = track->start_cts; int64_t start_dts = track->start_dts; + int flags = 0; if (track->entry) { if (start_dts != track->cluster[0].dts || start_ct != track->cluster[0].cts) { @@ -3440,6 +3452,17 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, delay = av_rescale_rnd(start_dts + start_ct, mov->movie_timescale, track->timescale, AV_ROUND_DOWN); + + if (mov->mode == MODE_AVIF) { + delay = 0; + // Section 9.6.3 of ISO/IEC 23008-12: flags specifies repetition of the + // edit list as follows: (flags & 1) equal to 0 specifies that the edit + // list is not repeated, while (flags & 1) equal to 1 specifies that the + // edit list is repeated. + flags = mov->avif_loop_count != 1; + start_ct = 0; + } + version |= delay < INT32_MAX ? 0 : 1; entry_size = (version == 1) ? 20 : 12; @@ -3452,7 +3475,7 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, avio_wb32(pb, size - 8); ffio_wfourcc(pb, "elst"); avio_w8(pb, version); - avio_wb24(pb, 0); /* flags */ + avio_wb24(pb, flags); /* flags */ avio_wb32(pb, entry_count); if (delay > 0) { /* add an empty edit to delay presentation */ @@ -3469,7 +3492,7 @@ static int mov_write_edts_tag(AVIOContext *pb, MOVMuxContext *mov, avio_wb32(pb, -1); } avio_wb32(pb, 0x00010000); - } else { + } else if (mov->mode != MODE_AVIF) { /* Avoid accidentally ending up with start_ct = -1 which has got a * special meaning. Normally start_ct should end up positive or zero * here, but use FFMIN in case dts is a small positive integer @@ -3670,6 +3693,9 @@ static int mov_write_trak_tag(AVFormatContext *s, AVIOContext *pb, MOVMuxContext "Not writing any edit list even though one would have been required\n"); } + if (mov->is_animated_avif) + mov_write_edts_tag(pb, mov, track); + if (track->tref_tag) mov_write_tref_tag(pb, track); @@ -7761,6 +7787,7 @@ static const AVCodecTag codec_f4v_tags[] = { static const AVOption avif_options[] = { { "movie_timescale", "set movie timescale", offsetof(MOVMuxContext, movie_timescale), AV_OPT_TYPE_INT, {.i64 = MOV_TIMESCALE}, 1, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM}, + { "loop", "Number of times to loop animated AVIF: 0 - infinite loop", offsetof(MOVMuxContext, avif_loop_count), AV_OPT_TYPE_INT, {.i64 = 0}, 0, INT_MAX, AV_OPT_FLAG_ENCODING_PARAM, 0 }, { NULL }, }; static const AVCodecTag codec_avif_tags[] = { diff --git a/libavformat/movenc.h b/libavformat/movenc.h index c6b3313deb..e85d83abdb 100644 --- a/libavformat/movenc.h +++ b/libavformat/movenc.h @@ -249,6 +249,7 @@ typedef struct MOVMuxContext { int64_t avif_extent_pos[2]; // index 0 is YUV and 1 is Alpha. int avif_extent_length[2]; // index 0 is YUV and 1 is Alpha. int is_animated_avif; + int avif_loop_count; } MOVMuxContext; #define FF_MOV_FLAG_RTP_HINT (1 << 0)