diff mbox series

[FFmpeg-devel,15/33] fftools/ffmpeg_mux_init: return error codes from validate_enc_avopt() instead of aborting

Message ID 20230713105553.21052-15-anton@khirnov.net
State Accepted
Commit fd401971709b57dd946eb7fd1810e3d4b9bad61f
Headers show
Series [FFmpeg-devel,01/33] fftools/ffmpeg_mux_init: return errors from of_open() instead of aborting | expand

Checks

Context Check Description
yinshiyou/make_loongarch64 success Make finished
yinshiyou/make_fate_loongarch64 success Make fate finished
andriy/make_x86 success Make finished
andriy/make_fate_x86 success Make fate finished

Commit Message

Anton Khirnov July 13, 2023, 10:55 a.m. UTC
---
 fftools/ffmpeg_mux_init.c | 10 +++++++---
 1 file changed, 7 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/fftools/ffmpeg_mux_init.c b/fftools/ffmpeg_mux_init.c
index 7a8c935795..3a327048bb 100644
--- a/fftools/ffmpeg_mux_init.c
+++ b/fftools/ffmpeg_mux_init.c
@@ -2342,7 +2342,7 @@  static int process_forced_keyframes(Muxer *mux, const OptionsContext *o)
     return 0;
 }
 
-static void validate_enc_avopt(Muxer *mux, const AVDictionary *codec_avopt)
+static int validate_enc_avopt(Muxer *mux, const AVDictionary *codec_avopt)
 {
     const AVClass *class  = avcodec_get_class();
     const AVClass *fclass = avformat_get_class();
@@ -2370,7 +2370,7 @@  static void validate_enc_avopt(Muxer *mux, const AVDictionary *codec_avopt)
         if (!(option->flags & AV_OPT_FLAG_ENCODING_PARAM)) {
             av_log(mux, AV_LOG_ERROR, "Codec AVOption %s (%s) is not an "
                    "encoding option.\n", e->key, option->help ? option->help : "");
-            exit_program(1);
+            return AVERROR(EINVAL);
         }
 
         // gop_timecode is injected by generic code but not always used
@@ -2384,6 +2384,8 @@  static void validate_enc_avopt(Muxer *mux, const AVDictionary *codec_avopt)
                "any stream.\n", e->key, option->help ? option->help : "");
     }
     av_dict_free(&unused_opts);
+
+    return 0;
 }
 
 static int init_output_stream_nofilter(OutputStream *ost)
@@ -2502,7 +2504,9 @@  int of_open(const OptionsContext *o, const char *filename)
         return err;
 
     /* check if all codec options have been used */
-    validate_enc_avopt(mux, o->g->codec_opts);
+    err = validate_enc_avopt(mux, o->g->codec_opts);
+    if (err < 0)
+        return err;
 
     /* check filename in case of an image number is expected */
     if (oc->oformat->flags & AVFMT_NEEDNUMBER && !av_filename_number_test(oc->url)) {