From patchwork Sat May 29 09:04:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Gyan Doshi X-Patchwork-Id: 27977 Delivered-To: ffmpegpatchwork2@gmail.com Received: by 2002:a6b:b214:0:0:0:0:0 with SMTP id b20csp1237283iof; Sat, 29 May 2021 02:05:24 -0700 (PDT) X-Google-Smtp-Source: ABdhPJxLktfDf4juNefGIzyZ2zc4D5ekhYWvSgaWbtP53Lh2LNRa5GpQgEsf8pwLL26hrW6KwhTM X-Received: by 2002:a17:906:6c97:: with SMTP id s23mr7973071ejr.224.1622279124253; Sat, 29 May 2021 02:05:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1622279124; cv=none; d=google.com; s=arc-20160816; b=r6miZDWkOuM9NM0r3sizEJ5WttHj0Y/U5HczIQIImXRUyhtm8uxwc4XpP/ZceDEo54 ZBxQfYbkmu7HywCW7O2sKP6Kzh53CV3ouOYBvwoScbTIm7s7shsocGxaHVH6FExgcvGl K2UsRcgMkCESman6r5897FVE6hRwmzm7X4Lf/2fyyzSE8rvrPpKY9AqPTgVHVg7ijBlO bFq6X5sw83zJYFE8rqvle2y6jG4ivk+3IO/did7bsWzo0nlHyshaZUFZQhKqLgyjCtnm zUMRP9LvTtF0NhcrkV5ZH//oPoSAUUjrKDBmRzAp3dK18QYJfG8w4IPfeelp2rx+cFvp IXvg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding: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=tu4owVqPZsVPeLLDTzpjzqE+nBuGvwMRQYY7xIPUWpg=; b=iCKmW1ZYv7L3ewV9Ix4r8429uZ6XlThGQL24HNey/aiFJ0opitzoCzXyBnyNBKoyka ng9I18hfRO10ITx+migzeR/2UOmfbZDrZxysX2QdaoaKvgha9N88HE/R/sBhpsE8w1Gk 6jK2z9LG1evzknBmFs1NqcH2HZN9O+QJG45TmFzO+gVtCwpfaRn/8W1aab7IjMOYkMFB ufYy9g7xHmnhn5XFU/cLijHbkbYnxuxBg5H5xb/eU60pKOO0jwNM2mQhbtlYe4oq0J9w oOPKFEi8RGKTjsTcPZzuQtB7BEPYAxmtZiCTybckwymi4i/YK4ZCQPWVLcSsLufzSw9i nXlQ== 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 z9si7966167edr.483.2021.05.29.02.05.23; Sat, 29 May 2021 02:05:24 -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 BDD4D68804C; Sat, 29 May 2021 12:05:19 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mout-p-101.mailbox.org (mout-p-101.mailbox.org [80.241.56.151]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DD2226804FC for ; Sat, 29 May 2021 12:05:12 +0300 (EEST) Received: from smtp2.mailbox.org (smtp2.mailbox.org [IPv6:2001:67c:2050:105:465:1:2:0]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-384) server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mout-p-101.mailbox.org (Postfix) with ESMTPS id 4FsbHC1fp7zQk1J for ; Sat, 29 May 2021 11:05:11 +0200 (CEST) X-Virus-Scanned: amavisd-new at heinlein-support.de Received: from smtp2.mailbox.org ([80.241.60.241]) by spamfilter02.heinlein-hosting.de (spamfilter02.heinlein-hosting.de [80.241.56.116]) (amavisd-new, port 10030) with ESMTP id MualhKf1lwAs for ; Sat, 29 May 2021 11:05:07 +0200 (CEST) From: Gyan Doshi To: ffmpeg-devel@ffmpeg.org Date: Sat, 29 May 2021 14:34:52 +0530 Message-Id: <20210529090452.10239-1-ffmpeg@gyani.pro> MIME-Version: 1.0 X-MBO-SPAM-Probability: **** X-Rspamd-Score: 5.86 / 15.00 / 15.00 X-Rspamd-Queue-Id: 0B24F1817 X-Rspamd-UID: 06f11f Subject: [FFmpeg-devel] [PATCH] avformat/mov: add option to use tfdt for fragment timestamps. 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" X-TUID: 1W/3ZiNWzhTY --- I faced the same issue as the poster in https://lists.ffmpeg.org/pipermail/ffmpeg-user/2018-March/039038.html After patch, start_time is correct as well as monotonicity of ts. doc/demuxers.texi | 6 ++++++ libavformat/isom.h | 1 + libavformat/mov.c | 4 +++- 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/doc/demuxers.texi b/doc/demuxers.texi index 13fe17ff4f..38734b577f 100644 --- a/doc/demuxers.texi +++ b/doc/demuxers.texi @@ -662,6 +662,12 @@ Set mfra timestamps as PTS Don't use mfra box to set timestamps @end table +@item use_tfdt +For fragmented input, set fragment's starting timestamp to @code{baseMediaDecodeTime} from the @code{tfdt} box. +Default is disabled, which will preferentially use the @code{earliest_presentation_time} from the @code{sidx} box. +In either case, the timestamp from the @code{mfra} box will be used if it's available and @code{use_mfra_for} is +set to pts or dts. + @item export_all Export unrecognized boxes within the @var{udta} box as metadata entries. The first four characters of the box type are set as the key. Default is false. diff --git a/libavformat/isom.h b/libavformat/isom.h index 5a6d504090..ac1b3f3d56 100644 --- a/libavformat/isom.h +++ b/libavformat/isom.h @@ -277,6 +277,7 @@ typedef struct MOVContext { int moov_retry; int use_mfra_for; int has_looked_for_mfra; + int use_tfdt; MOVFragmentIndex frag_index; int atom_depth; unsigned int aax_mode; ///< 'aax' file has been detected diff --git a/libavformat/mov.c b/libavformat/mov.c index c088c9f515..6c99a67ff5 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -4803,7 +4803,7 @@ static int mov_read_trun(MOVContext *c, AVIOContext *pb, MOVAtom atom) dts = frag_stream_info->first_tfra_pts; av_log(c->fc, AV_LOG_DEBUG, "found mfra time %"PRId64 ", using it for dts\n", pts); - } else if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE) { + } else if (frag_stream_info->sidx_pts != AV_NOPTS_VALUE && !c->use_tfdt) { // FIXME: sidx earliest_presentation_time is *PTS*, s.b. // pts = frag_stream_info->sidx_pts; dts = frag_stream_info->sidx_pts - sc->time_offset; @@ -8169,6 +8169,8 @@ static const AVOption mov_options[] = { FLAGS, "use_mfra_for" }, {"pts", "pts", 0, AV_OPT_TYPE_CONST, {.i64 = FF_MOV_FLAG_MFRA_PTS}, 0, 0, FLAGS, "use_mfra_for" }, + {"use_tfdt", "use tfdt for fragment timestamps", OFFSET(use_tfdt), AV_OPT_TYPE_BOOL, {.i64 = 0}, + 0, 1, FLAGS}, { "export_all", "Export unrecognized metadata entries", OFFSET(export_all), AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, .flags = FLAGS }, { "export_xmp", "Export full XMP metadata", OFFSET(export_xmp),