From patchwork Thu May 31 23:26:24 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sasi Inguva X-Patchwork-Id: 9219 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:11c:0:0:0:0:0 with SMTP id c28-v6csp212497jad; Thu, 31 May 2018 16:34:50 -0700 (PDT) X-Google-Smtp-Source: ADUXVKIj7U+vBVB9JxRrM8KAMgVlNYuAeRKBeaLkIgu6g+LUGHyApZIOKWqGo4o4RSoZJLr7sCZ7 X-Received: by 2002:a1c:e14:: with SMTP id 20-v6mr1151601wmo.85.1527809690076; Thu, 31 May 2018 16:34:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527809690; cv=none; d=google.com; s=arc-20160816; b=WaTthcVi5T3Si3dRQ31R+oWAuH80omCfGVvZ2AXeSsNOhYFhSbloaBjwGY1DYEcnhR ldhZaaqdu57mRpOs9+jELE1wkwaR0iifcxQX6RuNW9oR+ZCxWEt4c3obPEduSAIWaDRM 15uyGuE16d8CC6XfAY6mBRZ7B2ZUqNuxvVejaY57Xjklj7pzcYrvMxo3nXyyegtp5DEA 3SVu0r5BlJ1Blm9ZVsHj/hcv/1JDg9FcUr/kGry63Yqo2wCGEp2WSJsGnVeyF5ntjczR 3EgrnH2+8GtzIqI9Tt0321lFGiEzXi51UewnNqFwBYNZQy1Aph51m3dQ1qPwc1BGBhDQ nQBg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:reply-to:list-subscribe:list-help:list-post :list-archive:list-unsubscribe:list-id:precedence:subject:to :message-id:date:from:in-reply-to:references:mime-version :dkim-signature:delivered-to:arc-authentication-results; bh=OzJC7YmcgOxqcVnICrOY8EWDzoL/hBD1dxJAGWudv84=; b=coo801b7/4nDL8VojdQIu5ymo+bY6U/2LkqjmSeSEB7T8fVp2GqLc/7WQcMiUsH2tr xTWL5d0gPCyq1WjJdahrlZuIPS2X46Prajz03qj2OwEh27q34MUHFCHV2tYt1Cu4titX qRmoB8HnNsBbnpW7XusWIIWF6pTiPlYCCAFDlgvDTHintkbhIoAg/aJ2yNbUCMCJBEM4 2vsk1KdrD8YhtkFYhimTQfwa3M/YirjGB2gSSzirmgjCDD9052W+xzdH6Pqkw+VpJr2Z lAWHNGwiJ37JnMhg6sQpOptZC0HimgJybQf57tUnm0TaZIszJ9+8fz/NOtB8iAzob3TX 6MSw== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@google.com header.s=20161025 header.b=j+eTR34C; 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 i196-v6si393895wmg.94.2018.05.31.16.34.49; Thu, 31 May 2018 16:34:50 -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=@google.com header.s=20161025 header.b=j+eTR34C; 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 6034B68A494; Fri, 1 Jun 2018 02:34:03 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-wm0-f48.google.com (mail-wm0-f48.google.com [74.125.82.48]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 43834689C72 for ; Fri, 1 Jun 2018 02:33:56 +0300 (EEST) Received: by mail-wm0-f48.google.com with SMTP id v131-v6so37493536wma.1 for ; Thu, 31 May 2018 16:34:41 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to; bh=FAX338PBVktqHAY6EO8GgqEUKWMhokqOvia2GEG1fSg=; b=j+eTR34CeSSTqf6+dkRpBPxesksimz9Kazj/+sjw2mbHkys2jzGWzINtvunlv2Y87o xcsMEl/rkwahGjUPwH0JicEku85MGQpcmoGXBgd41DpdSiAJ/YWnzr1cn4Hthp/W3AaD pEGBrQq5leQTXe6TSFC3+CXa44LYz4ZZpXHFdYZWf1mzv3ldopXl9N1yt76nXOCByAQa MyLFfYQo4xf1G0BaEdhCo0ZH2rZoZZ3tlmRGDuhGTykTjlStJx7CEJIPiXV9ozmB5RUP hnpGiWp9aHpqwhBydUhewalPBTHBW6iqz+ABpWSDULXIZA9Ronm/iFbiha0lRTf/s+iw CZNw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to; bh=FAX338PBVktqHAY6EO8GgqEUKWMhokqOvia2GEG1fSg=; b=tHl/0Xl5jWhVG5/6gXE2DtgoKjdjSEsLgd4a2erpYsv6+Euy890BP+HbFal5HsymJM sYOE1+JGVnbcWkcegJUvffeCriFeZL5+2uUkPe3n/ZglWyk3V02K/g5mXCDXMvEUXK2G QFadrVl8R+RP5tz7tmB7VYaoEMVunRhziD5ZLalciimxLWrhq1cKSzSPJoIfZ1mVUw8P yd7zUgIx6HpKlo+S4coTDskulcFCWX0V34IDNq5cqLsm/psJddcziqxpCz5bJh0bvM19 73nrIGMD0PRaLetpEU55N/klfG1OopV0/KlPkDG4gyQ1tutU359A8BQRelZotveH+QiP YjSw== X-Gm-Message-State: APt69E3DeYUbn9KoF3IIvWlUQ8tYnBNzsAgGLoDclon7vLZwdsZvLbyb qUyXip6C5x5GHzHazXtzItEEUghOHiIR/DJ1ONYM+CsE X-Received: by 2002:a1c:16ca:: with SMTP id 193-v6mr1024044wmw.37.1527809196076; Thu, 31 May 2018 16:26:36 -0700 (PDT) MIME-Version: 1.0 References: <20180529223940.138092-1-isasi@rodete-desktop-imager.corp.google.com> <20180531211348.GU4859@michaelspb> In-Reply-To: From: Sasi Inguva Date: Thu, 31 May 2018 16:26:24 -0700 Message-ID: To: FFmpeg development discussions and patches X-Content-Filtered-By: Mailman/MimeDel 2.1.20 Subject: Re: [FFmpeg-devel] [PATCH] lavf/mov.c: Set st->start_time for video streams explicitly. 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 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" Pls find attached, the correctly signed patch Thanks. On Thu, May 31, 2018 at 4:14 PM Sasi Inguva wrote: > Sorry. Forgot to attach the file. Pls find it attached. Also resending the > patch signed with correct email address > > On Thu, May 31, 2018 at 2:14 PM Michael Niedermayer > wrote: > >> On Tue, May 29, 2018 at 03:39:40PM -0700, Sasi Inguva wrote: >> > If start_time is not set, ffmpeg takes the duration from the global >> > movie instead of the per stream duration. >> > Signed-off-by: Sasi Inguva > > >> > --- >> > libavformat/mov.c | 20 +++++++++--- >> > tests/fate/mov.mak | 4 +++ >> > tests/ref/fate/mov-neg-firstpts-discard | 2 +- >> > tests/ref/fate/mov-stream-shorter-than-movie | 33 ++++++++++++++++++++ >> > 4 files changed, 54 insertions(+), 5 deletions(-) >> > create mode 100644 tests/ref/fate/mov-stream-shorter-than-movie >> >> i may have missed a link to a sample file >> >> fate-suite//mov/mov_stream_shorter_than_movie.mov: No such file or >> directory >> make: *** [fate-mov-stream-shorter-than-movie] Error 1 >> >> >> >> >> [...] >> -- >> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB >> >> It is dangerous to be right in matters on which the established >> authorities >> are wrong. -- Voltaire >> _______________________________________________ >> ffmpeg-devel mailing list >> ffmpeg-devel@ffmpeg.org >> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel >> > From ba2feb04ef1ca94f7e1972e23c84c2acde93bf68 Mon Sep 17 00:00:00 2001 From: Sasi Inguva Date: Tue, 29 May 2018 15:36:07 -0700 Subject: [PATCH] lavf/mov.c: Set st->start_time for video streams explicitly. If start_time is not set, ffmpeg takes the duration from the global movie instead of the per stream duration. Signed-off-by: Sasi Inguva --- libavformat/mov.c | 20 +++++++++--- tests/fate/mov.mak | 4 +++ tests/ref/fate/mov-neg-firstpts-discard | 2 +- tests/ref/fate/mov-stream-shorter-than-movie | 33 ++++++++++++++++++++ 4 files changed, 54 insertions(+), 5 deletions(-) create mode 100644 tests/ref/fate/mov-stream-shorter-than-movie diff --git a/libavformat/mov.c b/libavformat/mov.c index f2a540ad50..1915be5fb5 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -3672,11 +3672,15 @@ static void mov_fix_index(MOVContext *mov, AVStream *st) // If the minimum pts turns out to be greater than zero after fixing the index, then we subtract the // dts by that amount to make the first pts zero. - if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && msc->min_corrected_pts > 0) { - av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by %"PRId64" to make first pts zero.\n", msc->min_corrected_pts); - for (i = 0; i < st->nb_index_entries; ++i) { - st->index_entries[i].timestamp -= msc->min_corrected_pts; + if (st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO) { + if (msc->min_corrected_pts > 0) { + av_log(mov->fc, AV_LOG_DEBUG, "Offset DTS by %"PRId64" to make first pts zero.\n", msc->min_corrected_pts); + for (i = 0; i < st->nb_index_entries; ++i) { + st->index_entries[i].timestamp -= msc->min_corrected_pts; + } } + // Start time should be equal to zero or the duration of any empty edits. + st->start_time = empty_edits_sum_duration; } // Update av stream length, if it ends up shorter than the track's media duration @@ -4012,6 +4016,14 @@ static void mov_build_index(MOVContext *mov, AVStream *st) mov_fix_index(mov, st); } + // Update start time of the stream. + if (st->start_time == AV_NOPTS_VALUE && st->codecpar->codec_type == AVMEDIA_TYPE_VIDEO && st->nb_index_entries > 0) { + st->start_time = st->index_entries[0].timestamp + sc->dts_shift; + if (sc->ctts_data) { + st->start_time += sc->ctts_data[0].duration; + } + } + mov_estimate_video_delay(mov, st); } diff --git a/tests/fate/mov.mak b/tests/fate/mov.mak index eadee3abfa..c1d399e5c0 100644 --- a/tests/fate/mov.mak +++ b/tests/fate/mov.mak @@ -16,6 +16,7 @@ FATE_MOV = fate-mov-3elist \ fate-mov-frag-overlap \ fate-mov-bbi-elst-starts-b \ fate-mov-neg-firstpts-discard-frames \ + fate-mov-stream-shorter-than-movie \ FATE_MOV_FFPROBE = fate-mov-neg-firstpts-discard \ fate-mov-aac-2048-priming \ @@ -88,6 +89,9 @@ fate-mov-neg-firstpts-discard: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_entri # Makes sure that expected frames are generated for mov_neg_first_pts_discard.mov with -vsync 1 fate-mov-neg-firstpts-discard-frames: CMD = framemd5 -flags +bitexact -i $(TARGET_SAMPLES)/mov/mov_neg_first_pts_discard.mov -vsync 1 +# Makes sure that no frame is dropped/duplicated with fps filter due to start_time / duration miscalculations. +fate-mov-stream-shorter-than-movie: CMD = framemd5 -flags +bitexact -i $(TARGET_SAMPLES)/mov/mov_stream_shorter_than_movie.mov -vf fps=fps=24 -an + fate-mov-aac-2048-priming: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_packets -print_format compact $(TARGET_SAMPLES)/mov/aac-2048-priming.mov fate-mov-zombie: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -show_streams -show_packets -show_frames -bitexact -print_format compact $(TARGET_SAMPLES)/mov/white_zombie_scrunch-part.mov diff --git a/tests/ref/fate/mov-neg-firstpts-discard b/tests/ref/fate/mov-neg-firstpts-discard index 7c982d3ffe..2e295e3b68 100644 --- a/tests/ref/fate/mov-neg-firstpts-discard +++ b/tests/ref/fate/mov-neg-firstpts-discard @@ -1,3 +1,3 @@ [STREAM] -start_time=N/A +start_time=0.000000 [/STREAM] diff --git a/tests/ref/fate/mov-stream-shorter-than-movie b/tests/ref/fate/mov-stream-shorter-than-movie new file mode 100644 index 0000000000..28f3ef378c --- /dev/null +++ b/tests/ref/fate/mov-stream-shorter-than-movie @@ -0,0 +1,33 @@ +#format: frame checksums +#version: 2 +#hash: MD5 +#tb 0: 1/24 +#media_type 0: video +#codec_id 0: rawvideo +#dimensions 0: 640x480 +#sar 0: 0/1 +#stream#, dts, pts, duration, size, hash +0, 0, 0, 1, 460800, 3a26ddfa53f09d535c701138027e49dc +0, 1, 1, 1, 460800, f09fe0d079ee81eb7db617b48ab5eecf +0, 2, 2, 1, 460800, 40a165b074c7f4d34a41f320400737fc +0, 3, 3, 1, 460800, 8ba73359c89ebc51e29847ef0e27f7c3 +0, 4, 4, 1, 460800, 0d783fcf3d37b99e7b41c0450e28f905 +0, 5, 5, 1, 460800, 7251de6f3e2ebccc2183aa7090dd59fb +0, 6, 6, 1, 460800, 5d2ab26df00d2ef9adf763480f9c0493 +0, 7, 7, 1, 460800, b545f2623d4f4b3bc5ba28ca842cb00e +0, 8, 8, 1, 460800, b3132e721028d0ccd0a734ef44fec5ff +0, 9, 9, 1, 460800, 354af9e99c0d5b9cb910b468e8afc89e +0, 10, 10, 1, 460800, 55452405c3cf6c44365d2dbe6cf37be3 +0, 11, 11, 1, 460800, 8ad58d19a00acc37536054706e235868 +0, 12, 12, 1, 460800, 833295be0a52fc2cf8dc7ae0375fd4f1 +0, 13, 13, 1, 460800, 3a943976671337231b962c659bb70f5c +0, 14, 14, 1, 460800, 1dddc5aae4adb42b582565bc19f3f464 +0, 15, 15, 1, 460800, 0562a855137f84269cbfaa94e7d0f623 +0, 16, 16, 1, 460800, e4a89894c47c7142fbc0b9122a7c0561 +0, 17, 17, 1, 460800, 31f4354cc10c6a9d3fc35c0123710528 +0, 18, 18, 1, 460800, c4cfbb24b55d09be1a9b6f1f3fe3ae33 +0, 19, 19, 1, 460800, 0643e1e9cf7e3a4494ad4b425e7dcce7 +0, 20, 20, 1, 460800, 1caf065c1fcb1541e5625d9d5e9d0944 +0, 21, 21, 1, 460800, f519db6dcb739a494e4b57bff2c3b021 +0, 22, 22, 1, 460800, 5bcd1c762ff8edf2b9a4e489be97f18d +0, 23, 23, 1, 460800, a818d6d3a94270294d6cf9432b19daa5 -- 2.17.0.921.gf22659ad46-goog