--- 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); -- 2.11.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel