From patchwork Wed Oct 5 14:25:07 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 38561 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a05:6a20:4d9:b0:9c:f4b:4e41 with SMTP id 25csp651753pzd; Wed, 5 Oct 2022 07:25:37 -0700 (PDT) X-Google-Smtp-Source: AMsMyM4UYvUpJZJfgaq6uRDoc9LgaVQk3HMQFf+q77/By7Z5qLKLsAw+xzL2933Brc87Ly5NeZzt X-Received: by 2002:a17:907:2721:b0:77f:d471:47b3 with SMTP id d1-20020a170907272100b0077fd47147b3mr23987503ejl.591.1664979937587; Wed, 05 Oct 2022 07:25:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1664979937; cv=none; d=google.com; s=arc-20160816; b=cJCWGu+hTJYPmQg2aNErjgNWuxonAIz6TQSWucbij73tN38YdNXmT/GDcQdht7kHtu tYLFaSyGNPyJsaw5zz8wU91a+tzLp2zgUZ7d2A2v/+BzvVCmoAkyi1H4SJniMCDUa9wX iRc6alZ4SnaJgho7BI8aPnDNe+nR+7I+jcTHcc4ouTJAdKp0q/FW8MW0E2B8pjHn6rUj 3K3xQ2QG2NyastovCL6lnmNoizxs7bmLNzp1uwNV9fGMNVrpI7bcAF1hFqlWnA4g0hXw 4DOVVa3l9xzB0n0N04WNSyVxZKkOS9zRHQSNjR3dMov3yS4YWau/amtmoWktVTjSB7jx VJIw== 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:mime-version:fcc:date:references :in-reply-to:message-id:from:dkim-signature:delivered-to; bh=nC8bvxFlzI+Nzvwa2DdHerthL0DQP7dFdUpoFly1q0Y=; b=I2cpNBMUj0jgq7IHPxTh3NS7V3i+KkFfoo54jQIyR6ZXhwW74mQp/G1/TyU7+Lyo/O r0A8Bnn879o7+KNseAl/4EHkP5WAgOfR43pkPxRaGIPpR4ohSnS9AyinRYXaN4qaY5Wz AYfIHWXep7Q+DMwJQsWuYLAEiDRCPCYIhauBK5nW3Xfpc1IHBNHRMS3Jdm5pU07wIOQq hLyr7rRGDV0rcj9CBdfhg1Pomo7BOCLb9wBDFayY0/vr2juhHcnWK5CDeLKwkK5wuJVo f142U1EflASJurKe4/eJSfoJ4okdCUz//iB2QEuRs8V0Q+Y0Btphd/rYEvMJA7RULS/u 5fAQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=MH7Jnb1E; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id hq9-20020a1709073f0900b0078b8bc456dcsi5105462ejc.315.2022.10.05.07.25.29; Wed, 05 Oct 2022 07:25:37 -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; dkim=neutral (body hash did not verify) header.i=@gmail.com header.s=20210112 header.b=MH7Jnb1E; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from [127.0.1.1] (localhost [127.0.0.1]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTP id 844C568BCF2; Wed, 5 Oct 2022 17:25:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pj1-f50.google.com (mail-pj1-f50.google.com [209.85.216.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 4CA8768BCA9 for ; Wed, 5 Oct 2022 17:25:12 +0300 (EEST) Received: by mail-pj1-f50.google.com with SMTP id a5-20020a17090aa50500b002008eeb040eso3086904pjq.1 for ; Wed, 05 Oct 2022 07:25:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:from:to:cc:subject:date :message-id:reply-to; bh=sI+o/WGaS6N956Wp0zYaOls36OaLyzZ8uWFqnks0OrQ=; b=MH7Jnb1EgPThsvyeMEcglc8goOcfzgUh0BZFxe/4lF02DRyeXCUY8z69QgqlgVZX9v RNxlNEyoS/Jpa5wZDHQXUg4MTg+2dA2jbuo56AiRieHU8zsBuWunJxZ9NRDKfgAGl3oj a6RZPP7cLaBU5IJq6soI7vG7yV28Q7ifbuTVZGjWKZyWLtPT1fdLVPu5b22jwBfrWQBY xIBsZ0qkycJkZcUpvuJEJ2zNfmtQOG+1EhMVLlcvannrjCMe5WiA+F1FqV8QNpYhjijm E3jUjU1G2ImHdoai3i/2zN497+yJUbBJ/Tzzu18Qtxx9cM8pVJ2I10wVIoHiTCk3/dDD s5yQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:mime-version:content-transfer-encoding:fcc:subject:date :references:in-reply-to:message-id:from:x-gm-message-state:from:to :cc:subject:date:message-id:reply-to; bh=sI+o/WGaS6N956Wp0zYaOls36OaLyzZ8uWFqnks0OrQ=; b=MZCY1T1dbmR+ff2RmQgaADe09eyMi3AJEAy/WXmOxiJXpM9nWrkmdLPbxsYt+KOMVO D86aMMO2o+g19YzgM40oMTMc5WGh2HThapHcLSaPQGxXAAShF7ICii0yAV97UNCLLa46 T7znHl/izkK7lGlqZZNdSqjcDwKeuFKFb8kzVkYQEkJVc3GEqXkT6DjtPhDtufORHX6L mpVfYpr673UuyBXJ0O7IiLmU4riXyRQzgxcpNroDiwGpnReDjO9ktlTTRre5DH0O8sxa GBzbMppi5SKJXSegiUEsXLqnxK2kpICH+5+I6gU7ctvAU6VDJd0Qh+yL9CTiL8lkqVeC AvQQ== X-Gm-Message-State: ACrzQf31omC2nDAGZBg/nXT7csATsET0rD2nQ5WnSq+Jh48nU+13uzTR hRqCu1xOg16y9VE+ZV9NJI4u1OZ1bm4= X-Received: by 2002:a17:902:f312:b0:17d:79e9:1181 with SMTP id c18-20020a170902f31200b0017d79e91181mr22567153ple.173.1664979910444; Wed, 05 Oct 2022 07:25:10 -0700 (PDT) Received: from [127.0.0.1] (master.gitmailbox.com. [34.83.118.50]) by smtp.gmail.com with ESMTPSA id 69-20020a621948000000b0056008ac8148sm8419193pfz.143.2022.10.05.07.25.10 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Wed, 05 Oct 2022 07:25:10 -0700 (PDT) From: Bryce Chester Newman X-Google-Original-From: Bryce Chester Newman Message-Id: In-Reply-To: References: Date: Wed, 05 Oct 2022 14:25:07 +0000 Fcc: Sent MIME-Version: 1.0 To: ffmpeg-devel@ffmpeg.org Subject: [FFmpeg-devel] [PATCH v2 1/2] libavformat/mov: Add support for exporting poster time. 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: Bryce Chester Newman Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: XR30ONb21ex/ From: Bryce Chester Newman Export the poster_time_location if available. The poster_time_location is calculated using the poster_time / time_scale = X seconds. The value of poster_time_location indicates where in the video the poster frame is. Addresses feedback from https://www.mail-archive.com/ffmpeg-devel@ffmpeg.org/msg138122.html. Signed-off-by: Bryce Chester Newman bryce.newman@gettyimages.com --- doc/demuxers.texi | 6 ++++++ libavformat/isom.h | 1 + libavformat/mov.c | 13 +++++++++++-- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 2b6dd86c2a..b1f4926c40 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -749,6 +749,12 @@ cast to int32 are used to adjust onward dts. Unit is the track time scale. Range is 0 to UINT_MAX. Default is @code{UINT_MAX - 48000*10} which allows upto a 10 second dts correction for 48 kHz audio streams while accommodating 99.9% of @code{uint32} range. + +@item poster_time_location +Export the poster_time_location if available. +The poster_time_location is calculated using the poster_time / time_scale = X seconds. +The value of poster_time_location indicates where in the video the poster frame is. +Default is false. @end table @subsection Audible AAX diff --git a/libavformat/isom.h b/libavformat/isom.h index 64fb7065d5..fb3d8d5618 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -326,6 +326,7 @@ typedef struct MOVContext { int64_t extent_offset; } *avif_info; int avif_info_size; + int poster_time_location; } MOVContext; int ff_mp4_read_descr_len(AVIOContext *pb); diff --git a/libavformat/mov.c b/libavformat/mov.c index 1f436e21d6..b914bbc96a 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -1501,6 +1501,7 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) { int i; int64_t creation_time; + int32_t poster_time; int version = avio_r8(pb); /* version */ avio_rb24(pb); /* flags */ @@ -1535,12 +1536,20 @@ static int mov_read_mvhd(MOVContext *c, AVIOContext *pb, MOVAtom atom) avio_rb32(pb); /* preview time */ avio_rb32(pb); /* preview duration */ - avio_rb32(pb); /* poster time */ + poster_time = avio_rb32(pb); /* poster time */ avio_rb32(pb); /* selection time */ avio_rb32(pb); /* selection duration */ avio_rb32(pb); /* current time */ avio_rb32(pb); /* next track ID */ + if(c->poster_time_location && poster_time && c->time_scale && c->time_scale > 0) { + av_log(c->fc, AV_LOG_TRACE, "poster_time = %i, time_scale = %i\n", poster_time, c->time_scale); + char buffer[32]; + int poster_time_location = poster_time / c->time_scale; + snprintf(buffer, sizeof(buffer), "%i", poster_time_location); + av_dict_set(&c->fc->metadata, "poster_time_location", buffer, 0); + } + return 0; } @@ -9114,7 +9123,7 @@ static const AVOption mov_options[] = { { "enable_drefs", "Enable external track support.", OFFSET(enable_drefs), AV_OPT_TYPE_BOOL, {.i64 = 0}, 0, 1, FLAGS }, { "max_stts_delta", "treat offsets above this value as invalid", OFFSET(max_stts_delta), AV_OPT_TYPE_INT, {.i64 = UINT_MAX-48000*10 }, 0, UINT_MAX, .flags = AV_OPT_FLAG_DECODING_PARAM }, - + { "poster_time_location", "Export the poster time location.", OFFSET(poster_time_location), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, FLAGS | AV_OPT_FLAG_EXPORT }, { NULL }, };