From patchwork Thu Apr 19 23:51:33 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aman Karmani X-Patchwork-Id: 8516 Delivered-To: ffmpegpatchwork@gmail.com Received: by 2002:a02:155:0:0:0:0:0 with SMTP id c82-v6csp37157jad; Thu, 19 Apr 2018 16:51:46 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+R6CyFKZsJsqkkI/qEWQPYfpA8HC33sSeFXo216yWiz4entzoXHz//SO/GVQDJx1JFYLIh X-Received: by 2002:adf:96c2:: with SMTP id u60-v6mr6258659wrb.204.1524181906663; Thu, 19 Apr 2018 16:51:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524181906; cv=none; d=google.com; s=arc-20160816; b=UZ0HviBoC8wrYIN5gzSyIgJNd/6wBIWkFCtewolfYnr0wIDCI97+gnDZxazf0JVP8d hpoEdxAX1Uj9tNFDKmwlpmxtRzpLG7pBjIBm85CPdeeB18s/om8KkmdtuQ2PymVlbH9q MlBIBck453AT+8yveWIYIa65Kjzrbn/JofZ83I7Ggb4YPmHCQ50G6nVwJBYfsi2gZW2B ih5pT5GGx1BCvK5MC89bWzdongNiOnGZv04evQgoD+uGYLSYpvetuv7ZjnWyOybt+q8l UT9b2PdgHWO7Z5GhVDyt3SyVujuB4xdF6ni6ABBO7kfIGjeUBxIbPR7LD1kkwvJ1/Sxp PADA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:content-transfer-encoding:mime-version:cc:reply-to :list-subscribe:list-help:list-post:list-archive:list-unsubscribe :list-id:precedence:subject:references:in-reply-to:message-id:date :to:from:dkim-signature:delivered-to:arc-authentication-results; bh=v+0t3AT0km6/NqdeZsEt9pBosGRKXe98sQTfcH3MzyE=; b=s9bHI29llGig1ijJLRvaVn06EA2kVCjcwjDSJA1WXQlmli4KT9MJBM6UTB1HFgnXeN Fw73MsH7kTHIEj84XMY0DbVquaz9PlzNtxFKtmQyqIEE+5+voMvpEfvVzS7TNJycDlHF n7txY0otOpEsNeIPRf754503Vz9Ww1u1p88YOhXjGqkxbVFgfEOVRKLX57TnyQ6rpgH2 JdY0o+21N4j1/XNho7YyVVGElC/stUm1IyhGkmBtJXcIpuWhxu13746fn9zhvPGli0P6 5tVIxwRGAOSqTylHGLxSotulya4TmT7ocD4RRwvJ0//LlnQBMKUNsWereLoR6AHOku5P CzmA== ARC-Authentication-Results: i=1; mx.google.com; dkim=neutral (body hash did not verify) header.i=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=RczLMD2v; 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 j68si180286wmg.145.2018.04.19.16.51.46; Thu, 19 Apr 2018 16:51:46 -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=@tmm1-net.20150623.gappssmtp.com header.s=20150623 header.b=RczLMD2v; 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 7E8DF68A0CE; Fri, 20 Apr 2018 02:51:17 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-pf0-f194.google.com (mail-pf0-f194.google.com [209.85.192.194]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id DE2AB6805BF for ; Fri, 20 Apr 2018 02:51:10 +0300 (EEST) Received: by mail-pf0-f194.google.com with SMTP id j11so3384412pff.10 for ; Thu, 19 Apr 2018 16:51:38 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tmm1-net.20150623.gappssmtp.com; s=20150623; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=LzZ0RRPDDwwxNiizwaZlO0alzCqZxrK5Qq1aQsdOj98=; b=RczLMD2vKVZ2ZdpRseybGGYwusXVNPmK8dUrpBMlJh3Xl4Wng4I3jX7FvuckUp6I2v olp64jIsBY0MGUxcCgdluw64JpnYh2c7RXoECPryp2ot/gW+7yM9O93VcrYP6zlxbTbD +TJMQ8++pSNXa8smTMQl9V4YULjkUv4i4qr9oOYsMe3wrzuY+IQp44sOMeMkR7yRAj1C oMtbWUh5qvGvccVRCb44U65ycImHgnjHN5IB7qwfJWarZ8QeHca0nLt2+0+BWNCdETdB HJGataO/TNxDMHC7SHgDUh4X2Fm6bv2THKt6cTob45Awx42f/nsHK9G2IiztyfeYmeTo Qjzg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=LzZ0RRPDDwwxNiizwaZlO0alzCqZxrK5Qq1aQsdOj98=; b=bzusGka+qc6iu/CdiZOPgmqdPmpe6HFAGmO2X2Nea3zrYk1EY5rCYlgv7yZHy7HIyv 0+50SP0z+VvNtwGoyp7GO1NfmZIoXwWGhVXcP0MHzQugI8Zp6XxoRc2z7jDn00A8dgEx t1P/LE1hmESVTJIapheSGdNnGCRMF3oVnB9C/s4baLhuPupa6BNROI0gErFhn7AeazFC DjQ7OesCO2cQmuMagqUtCMMii28L3TY1c9tAoJGbVXjiDH4hxNLowwFfJ7wLQlPTUZSe YlixAryawzPurbm+VVrGG9p20K/onvxxzOroTIvQTWcAEHyidSASLMJ11uVD+UmMFAX8 3cbw== X-Gm-Message-State: ALQs6tCEy6HgYjZNsheXiwM3SBlgh2cD2oklNMTKUbbL/EX028Sc4m7c +FAvEJEp9twyJMtgBNiGiSt5srQR X-Received: by 10.101.65.67 with SMTP id x3mr6656545pgp.425.1524181896799; Thu, 19 Apr 2018 16:51:36 -0700 (PDT) Received: from localhost.localdomain (c-69-181-54-242.hsd1.ca.comcast.net. [69.181.54.242]) by smtp.gmail.com with ESMTPSA id 67sm10361101pfp.122.2018.04.19.16.51.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 19 Apr 2018 16:51:36 -0700 (PDT) From: Aman Gupta To: ffmpeg-devel@ffmpeg.org Date: Thu, 19 Apr 2018 16:51:33 -0700 Message-Id: <20180419235134.76459-1-ffmpeg@tmm1.net> X-Mailer: git-send-email 2.14.2 In-Reply-To: <20180419234318.GW20131@michaelspb> References: <20180419234318.GW20131@michaelspb> Subject: [FFmpeg-devel] [PATCH v2 1/2] avformat/utils: ignore outlier durations on subtitle/data streams as well 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 Cc: michael@niedermayer.cc, Aman Gupta MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" From: Aman Gupta Similar to 4c9c4fe8b21, but for durations. This fixes #7151, where the report duration and bitrate on a mpegts stream is wildly off due to the dvb_teletext stream's timings. --- libavformat/utils.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index f2f2cc4239..705b79031d 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2618,7 +2618,7 @@ static int has_duration(AVFormatContext *ic) static void update_stream_timings(AVFormatContext *ic) { int64_t start_time, start_time1, start_time_text, end_time, end_time1, end_time_text; - int64_t duration, duration1, filesize; + int64_t duration, duration1, duration_text, filesize; int i; AVStream *st; AVProgram *p; @@ -2628,6 +2628,8 @@ static void update_stream_timings(AVFormatContext *ic) end_time = INT64_MIN; end_time_text = INT64_MIN; duration = INT64_MIN; + duration_text = INT64_MIN; + for (i = 0; i < ic->nb_streams; i++) { st = ic->streams[i]; if (st->start_time != AV_NOPTS_VALUE && st->time_base.den) { @@ -2658,7 +2660,10 @@ static void update_stream_timings(AVFormatContext *ic) if (st->duration != AV_NOPTS_VALUE) { duration1 = av_rescale_q(st->duration, st->time_base, AV_TIME_BASE_Q); - duration = FFMAX(duration, duration1); + if (st->codecpar->codec_type == AVMEDIA_TYPE_SUBTITLE || st->codecpar->codec_type == AVMEDIA_TYPE_DATA) + duration_text = FFMAX(duration_text, duration1); + else + duration = FFMAX(duration, duration1); } } if (start_time == INT64_MAX || (start_time > start_time_text && start_time - start_time_text < AV_TIME_BASE)) @@ -2672,6 +2677,11 @@ static void update_stream_timings(AVFormatContext *ic) av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream endtime %f\n", end_time_text / (float)AV_TIME_BASE); } + if (duration == INT64_MIN || (duration < duration_text && duration_text - duration < AV_TIME_BASE)) + duration = duration_text; + else if (duration < duration_text) + av_log(ic, AV_LOG_VERBOSE, "Ignoring outlier non primary stream duration %f\n", duration_text / (float)AV_TIME_BASE); + if (start_time != INT64_MAX) { ic->start_time = start_time; if (end_time != INT64_MIN) {