[FFmpeg-devel] [PATCH 2/2] avformat/utils: If scan_all_pmts is explicitly disabled then skip streams outside programs in avformat_find_stream_info()

Michael Niedermayer michaelni at gmx.at
Sat Feb 14 04:04:46 CET 2015


This reduces the startup delay if such streams exist and never get fully analyzed

Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
 libavformat/utils.c |    6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/libavformat/utils.c b/libavformat/utils.c
index fb79ecd..bcfadef 100644
--- a/libavformat/utils.c
+++ b/libavformat/utils.c
@@ -3013,6 +3013,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
     int64_t max_analyze_duration = ic->max_analyze_duration2;
     int64_t max_stream_analyze_duration;
     int64_t probesize = ic->probesize2;
+    int64_t scan_all_pmts = -1;
 
     if (!max_analyze_duration)
         max_analyze_duration = ic->max_analyze_duration;
@@ -3021,6 +3022,7 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
     flush_codecs = probesize > 0;
 
     av_opt_set(ic, "skip_clear", "1", AV_OPT_SEARCH_CHILDREN);
+    av_opt_get_int(ic, "scan_all_pmts", AV_OPT_SEARCH_CHILDREN, &scan_all_pmts);
 
     max_stream_analyze_duration = max_analyze_duration;
     if (!max_analyze_duration) {
@@ -3112,6 +3114,10 @@ int avformat_find_stream_info(AVFormatContext *ic, AVDictionary **options)
             int fps_analyze_framecount = 20;
 
             st = ic->streams[i];
+
+            if (ic->nb_programs && !scan_all_pmts && !av_find_program_from_stream(ic, NULL, i))
+                continue;
+
             if (!has_codec_parameters(st, NULL))
                 break;
             /* If the timebase is coarse (like the usual millisecond precision
-- 
1.7.9.5



More information about the ffmpeg-devel mailing list