From patchwork Tue May 2 01:42:18 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodger Combs X-Patchwork-Id: 3543 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp1659601vsd; Mon, 1 May 2017 18:48:44 -0700 (PDT) X-Received: by 10.223.131.67 with SMTP id 61mr16022927wrd.37.1493689724376; Mon, 01 May 2017 18:48:44 -0700 (PDT) Return-Path: Received: from ffbox0-bg.mplayerhq.hu (ffbox0-bg.ffmpeg.org. [79.124.17.100]) by mx.google.com with ESMTP id f9si2606680wrc.274.2017.05.01.18.48.43; Mon, 01 May 2017 18:48:44 -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; 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=NONE 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 2AC89689753; Tue, 2 May 2017 04:48:38 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-io0-f196.google.com (mail-io0-f196.google.com [209.85.223.196]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 5B4036882E2 for ; Tue, 2 May 2017 04:48:32 +0300 (EEST) Received: by mail-io0-f196.google.com with SMTP id o22so1364496iod.0 for ; Mon, 01 May 2017 18:48:36 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id:in-reply-to:references; bh=/wiqHS3MsTDq48MZpqRoAFBkqkkdTYK7U2PtIAd+Zj4=; b=vImmz6FT7AAjfUo17PBaqHjBGVPhVnYg1p/G5JhvMHpSSv1mqEStEmMiRw+sWa1I44 OdXGvBfVBv9Gte+W5uKffKIbnxV6JyAVS7ko3lEzz24EhtAzm9J5Dr63+CmQ6y9TFZX6 J79yc5wB8rUmVsNU/2JftpggjuSMgLRKjmUQACIsM9yE4FSIQtHngWqzRbUjBOFmGeZM dZKJZ+D/xVBCWi7x2BBlkS29tyz2kxkQoBU14aUu09JWr5gpEWIsJ6xyJxLqJfaO08Oe ORYBsp1H92byLjT+3j3riK7cEAaT71YdxcOREABduDC7KMGrBkPpyn3CaU7BhsnnGM9j C0qQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:subject:date:message-id:in-reply-to :references; bh=/wiqHS3MsTDq48MZpqRoAFBkqkkdTYK7U2PtIAd+Zj4=; b=T+dbjX9Gj5D6S2cwpgBb+vyCIJjXe/jZaENWVX81K/QoVt/lmRo6blMRtLLqAf8Byx p0P45cSeIEU7+3qZwyS+3DXtG+fyZGF7xA0hJFLNHUKCdLuTeu5ag4Saye10OGsZbSUM nE9sRHoE7jJUGzrmS+vEsG+m9uZ1WCeApt+HybMMICwXd4I4KtEygyeMUHn51fxdwya6 iQZdSdQ7WlmfxPyE+ouNcCZHQjetBwynh5UZzYLtpEMo65mVV3ryEKDM8THGk81X3wvn 7N76IFZuiLksIuDxt9kbkSbsnYrEvuOwEUgmGWY7zKk7WHx8zQi/m5pku5xPFv2mZZ+q SZcw== X-Gm-Message-State: AN3rC/6kJYvKEKmpPSDh7PoRgBh0DF0y11cMEmCgBsvACPCTX8QMXm6g YNldnlXfbVzDLoK6EYg= X-Received: by 10.107.33.135 with SMTP id h129mr26208080ioh.57.1493689343384; Mon, 01 May 2017 18:42:23 -0700 (PDT) Received: from Rodgers-MacBook-Pro.local.net (c-73-110-121-59.hsd1.il.comcast.net. [73.110.121.59]) by smtp.gmail.com with ESMTPSA id c82sm7277863ioe.62.2017.05.01.18.42.22 for (version=TLS1 cipher=AES128-SHA bits=128/128); Mon, 01 May 2017 18:42:22 -0700 (PDT) From: Rodger Combs To: ffmpeg-devel@ffmpeg.org Date: Mon, 1 May 2017 20:42:18 -0500 Message-Id: <20170502014218.83855-2-rodger.combs@gmail.com> X-Mailer: git-send-email 2.11.1 In-Reply-To: <20170502014218.83855-1-rodger.combs@gmail.com> References: <20170502014218.83855-1-rodger.combs@gmail.com> Subject: [FFmpeg-devel] [PATCH 2/2] lavf/utils: bail early if we don't see any packets in an MPEGTS stream 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 MIME-Version: 1.0 Errors-To: ffmpeg-devel-bounces@ffmpeg.org Sender: "ffmpeg-devel" --- libavformat/utils.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index ba82a766dc..4028d8dbcb 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -3505,6 +3505,8 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) int64_t max_analyze_duration = ic->max_analyze_duration; int64_t max_stream_analyze_duration; int64_t max_subtitle_analyze_duration; + int64_t max_empty_analyze_duration; + int skip_empty_streams = 0; int64_t probesize = ic->probesize; int eof_reached = 0; int *missing_streams = av_opt_ptr(ic->iformat->priv_class, ic->priv_data, "missing_streams"); @@ -3515,14 +3517,18 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options) max_stream_analyze_duration = max_analyze_duration; max_subtitle_analyze_duration = max_analyze_duration; + max_empty_analyze_duration = max_analyze_duration; if (!max_analyze_duration) { + max_empty_analyze_duration = max_stream_analyze_duration = max_analyze_duration = 5*AV_TIME_BASE; max_subtitle_analyze_duration = 30*AV_TIME_BASE; if (!strcmp(ic->iformat->name, "flv")) max_stream_analyze_duration = 90*AV_TIME_BASE; - if (!strcmp(ic->iformat->name, "mpeg") || !strcmp(ic->iformat->name, "mpegts")) + if (!strcmp(ic->iformat->name, "mpeg") || !strcmp(ic->iformat->name, "mpegts")) { max_stream_analyze_duration = 7*AV_TIME_BASE; + max_empty_analyze_duration = 2*AV_TIME_BASE; + } } if (ic->pb) @@ -3628,6 +3634,12 @@ FF_ENABLE_DEPRECATION_WARNINGS int fps_analyze_framecount = 20; st = ic->streams[i]; + + if (st->codec_info_nb_frames == 0 && + st->codecpar->codec_type != AVMEDIA_TYPE_SUBTITLE && + skip_empty_streams) + continue; + if (!has_codec_parameters(st, NULL)) break; /* If the timebase is coarse (like the usual millisecond precision @@ -3791,6 +3803,10 @@ FF_ENABLE_DEPRECATION_WARNINGS av_packet_unref(pkt); break; } + + if (t >= max_empty_analyze_duration) + skip_empty_streams = 1; + if (pkt->duration) { if (avctx->codec_type == AVMEDIA_TYPE_SUBTITLE && pkt->pts != AV_NOPTS_VALUE && pkt->pts >= st->start_time) { st->info->codec_info_duration = FFMIN(pkt->pts - st->start_time, st->info->codec_info_duration + pkt->duration);