[FFmpeg-cvslog] fftools/ffmpeg_filter: return error codes from ofilter_bind_ost() instead of aborting

Anton Khirnov git at videolan.org
Thu Jul 20 21:56:50 EEST 2023


ffmpeg | branch: master | Anton Khirnov <anton at khirnov.net> | Thu Jul 13 15:11:07 2023 +0200| [ab16e324eae9f0eded14f8486fe44ad97ef613c8] | committer: Anton Khirnov

fftools/ffmpeg_filter: return error codes from ofilter_bind_ost() instead of aborting

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ab16e324eae9f0eded14f8486fe44ad97ef613c8
---

 fftools/ffmpeg.h          |  2 +-
 fftools/ffmpeg_filter.c   | 12 ++++++++----
 fftools/ffmpeg_mux_init.c |  4 +++-
 3 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 36e8867fd5..878f8e87d5 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -743,7 +743,7 @@ void ifilter_sub2video_heartbeat(InputFilter *ifilter, int64_t pts, AVRational t
  */
 int ifilter_parameters_from_dec(InputFilter *ifilter, const AVCodecContext *dec);
 
-void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost);
+int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost);
 
 /**
  * Create a new filtergraph in the global filtergraph list.
diff --git a/fftools/ffmpeg_filter.c b/fftools/ffmpeg_filter.c
index d373d8c002..cdf5610620 100644
--- a/fftools/ffmpeg_filter.c
+++ b/fftools/ffmpeg_filter.c
@@ -624,7 +624,7 @@ static void set_channel_layout(OutputFilterPriv *f, OutputStream *ost)
     av_channel_layout_default(&f->ch_layout, ost->enc_ctx->ch_layout.nb_channels);
 }
 
-void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost)
+int ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost)
 {
     OutputFilterPriv *ofp = ofp_from_ofilter(ofilter);
     FilterGraph  *fg = ofilter->graph;
@@ -699,15 +699,17 @@ void ofilter_bind_ost(OutputFilter *ofilter, OutputStream *ost)
 
         for (int i = 0; i < fg->nb_outputs; i++)
             if (!fg->outputs[i]->ost)
-                return;
+                return 0;
 
         ret = configure_filtergraph(fg);
         if (ret < 0) {
             av_log(fg, AV_LOG_ERROR, "Error configuring filter graph: %s\n",
                    av_err2str(ret));
-            exit_program(1);
+            return ret;
         }
     }
+
+    return 0;
 }
 
 static InputFilter *ifilter_alloc(FilterGraph *fg)
@@ -899,7 +901,9 @@ int init_simple_filtergraph(InputStream *ist, OutputStream *ost,
     if (ret < 0)
         return ret;
 
-    ofilter_bind_ost(fg->outputs[0], ost);
+    ret = ofilter_bind_ost(fg->outputs[0], ost);
+    if (ret < 0)
+        return ret;
 
     return 0;
 }
diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index d6ae154ad9..4580f4af41 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -1382,7 +1382,9 @@ static int ost_add(Muxer *mux, const OptionsContext *o, enum AVMediaType type,
         (type == AVMEDIA_TYPE_VIDEO || type == AVMEDIA_TYPE_AUDIO)) {
         if (ofilter) {
             ost->filter       = ofilter;
-            ofilter_bind_ost(ofilter, ost);
+            ret = ofilter_bind_ost(ofilter, ost);
+            if (ret < 0)
+                return ret;
         } else {
             ret = init_simple_filtergraph(ost->ist, ost, filters);
             if (ret < 0) {



More information about the ffmpeg-cvslog mailing list