[FFmpeg-devel] [PATCH 11/36] fftools/ffmpeg_demux: disallow using disabled input streams

Anton Khirnov anton at khirnov.net
Wed May 17 13:20:04 EEST 2023


This is less ad-hoc than checking explicitly in every place that binds
an input stream to a filter or output.
---
 fftools/ffmpeg_demux.c  | 6 ++++++
 fftools/ffmpeg_filter.c | 5 -----
 2 files changed, 6 insertions(+), 5 deletions(-)

diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index ae2133bdbf..df87e0f30a 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -848,6 +848,12 @@ static int ist_use(InputStream *ist, int decoding_needed)
 {
     DemuxStream *ds = ds_from_ist(ist);
 
+    if (ist->user_set_discard == AVDISCARD_ALL) {
+        av_log(ist, AV_LOG_ERROR, "Cannot %s a disabled input stream\n",
+               decoding_needed ? "decode" : "streamcopy");
+        return AVERROR(EINVAL);
+    }
+
     ist->discard          = 0;
     ist->st->discard      = ist->user_set_discard;
     ist->decoding_needed |= decoding_needed;
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index ca43b4803a..2c3e2a96f7 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -417,11 +417,6 @@ static void init_input_filter(FilterGraph *fg, AVFilterInOut *in)
             exit_program(1);
         }
         ist = input_files[file_idx]->streams[st->index];
-        if (ist->user_set_discard == AVDISCARD_ALL) {
-            av_log(NULL, AV_LOG_FATAL, "Stream specifier '%s' in filtergraph description %s "
-                   "matches a disabled input stream.\n", p, fgp->graph_desc);
-            exit_program(1);
-        }
     } else {
         ist = ist_find_unused(type);
         if (!ist) {
-- 
2.39.2



More information about the ffmpeg-devel mailing list