From patchwork Wed May 3 03:14:35 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Rodger Combs X-Patchwork-Id: 3564 Delivered-To: ffmpegpatchwork@gmail.com Received: by 10.103.3.129 with SMTP id 123csp2180998vsd; Tue, 2 May 2017 20:14:58 -0700 (PDT) X-Received: by 10.223.164.81 with SMTP id e17mr20444972wra.133.1493781298170; Tue, 02 May 2017 20:14:58 -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 v20si17280950wrd.243.2017.05.02.20.14.57; Tue, 02 May 2017 20:14:58 -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 16E476882B0; Wed, 3 May 2017 06:14:51 +0300 (EEST) X-Original-To: ffmpeg-devel@ffmpeg.org Delivered-To: ffmpeg-devel@ffmpeg.org Received: from mail-it0-f50.google.com (mail-it0-f50.google.com [209.85.214.50]) by ffbox0-bg.mplayerhq.hu (Postfix) with ESMTPS id 02A2B68090C for ; Wed, 3 May 2017 06:14:45 +0300 (EEST) Received: by mail-it0-f50.google.com with SMTP id w68so5866978itc.0 for ; Tue, 02 May 2017 20:14:49 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:subject:date:message-id; bh=J46G4svBB7nM7DCeFIIMVmAkRO42KJL4sIIyqKT7GF8=; b=mi7lm52QXM1i9ce+TxTIr5ePgt1rKZQoXpoYKV2LdfqwZtsOAkVIn9rQLePXwRZEDk mvGdlPOxut8s6NkGrBDAl4BumgYEsS1CrArdnNQnkyLfYeU8MbTkmnO26rIeBXMbqlgg wwbxoPSOEp0pP87ypkpfN00FeyoA4TpGtV1eLf5WZFe/XSliO3yVvM+6d0DdUphL01Jr tCW/Kxl/aUT7ST9Q5gcHPpnRsY5pVmoJ9wYwYiSxnj1jah2mzDy3v8d1YTn6bUZbafxm cPXytgXTUGlSDTAWXG1/5TWmSR7niEbhILYRbkVE3gjLej/2F16c1YTNfTQpqd258ECr vxrQ== 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; bh=J46G4svBB7nM7DCeFIIMVmAkRO42KJL4sIIyqKT7GF8=; b=ca0LtpxtMheATZvwpVGWgO3X9/CkAi+6ZsbDX/2za745aERsEDt4A+4DvRwtNz9Uy/ WFi330tEUonV8wZsc8tWRt7pxdrxsIn1jERCGkl4QmER14ZgK3SgDgFusbUz+MByBz/5 27aDvOt40jXNADIAM12u6m0ez4g4XdgcwY5e36f2PPkA1Ll3D9B26pDAhDgJbKDbPSaA sHR+zCNx7vHZmADdUd1RYb3riuZj/9ubGdE1HrL+UWtlTqZL9UtC2jHzZFCv3lsxPKOH 3v7gvq4VITh7jGOpA5QYjYov2pRTDHae5I600LdvNDDzAX77ojWGt2AZ9rbltAXPgn5c KD3g== X-Gm-Message-State: AN3rC/7kH2ehM/Tj3Jh4JkK3t5Yuh1ldnegHco9axBMNbcjJTrra4jZr v3YJvCCDPaoVa5Bdqjw= X-Received: by 10.36.94.138 with SMTP id h132mr16277445itb.104.1493781287509; Tue, 02 May 2017 20:14:47 -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 93sm8812622ioj.58.2017.05.02.20.14.46 for (version=TLS1 cipher=AES128-SHA bits=128/128); Tue, 02 May 2017 20:14:47 -0700 (PDT) From: Rodger Combs To: ffmpeg-devel@ffmpeg.org Date: Tue, 2 May 2017 22:14:35 -0500 Message-Id: <20170503031435.91300-1-rodger.combs@gmail.com> X-Mailer: git-send-email 2.11.1 Subject: [FFmpeg-devel] [PATCH] 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 | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index ba82a766dc..80895b31f0 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,20 @@ 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")) + if (!strcmp(ic->iformat->name, "flv")) { + max_empty_analyze_duration = 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 +3636,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 +3805,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);