aboutsummaryrefslogtreecommitdiffstats
path: root/fftools
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-07-14 18:18:57 +0200
committerAnton Khirnov <anton@khirnov.net>2023-07-20 20:47:46 +0200
commit2f155b18a10fec84163b3546efb41a8d64bb7c22 (patch)
tree27aafec449b0860ac3e3139c44c211100775e00b /fftools
parenteda1fac27afdaaf646d9c84e6f2cea407764fbf2 (diff)
downloadffmpeg-2f155b18a10fec84163b3546efb41a8d64bb7c22.tar.gz
fftools/ffmpeg: return an error from assert_avoptions() instead of aborting
Rename it to check_avoptions().
Diffstat (limited to 'fftools')
-rw-r--r--fftools/ffmpeg.c6
-rw-r--r--fftools/ffmpeg.h2
-rw-r--r--fftools/ffmpeg_dec.c5
-rw-r--r--fftools/ffmpeg_demux.c5
-rw-r--r--fftools/ffmpeg_enc.c5
5 files changed, 17 insertions, 6 deletions
diff --git a/fftools/ffmpeg.c b/fftools/ffmpeg.c
index 50d6658472..ecb3f89f85 100644
--- a/fftools/ffmpeg.c
+++ b/fftools/ffmpeg.c
@@ -457,13 +457,15 @@ void remove_avoptions(AVDictionary **a, AVDictionary *b)
}
}
-void assert_avoptions(AVDictionary *m)
+int check_avoptions(AVDictionary *m)
{
const AVDictionaryEntry *t;
if ((t = av_dict_get(m, "", NULL, AV_DICT_IGNORE_SUFFIX))) {
av_log(NULL, AV_LOG_FATAL, "Option %s not found.\n", t->key);
- exit_program(1);
+ return AVERROR_OPTION_NOT_FOUND;
}
+
+ return 0;
}
void update_benchmark(const char *fmt, ...)
diff --git a/fftools/ffmpeg.h b/fftools/ffmpeg.h
index 67a6bcbc8b..82439dc5e3 100644
--- a/fftools/ffmpeg.h
+++ b/fftools/ffmpeg.h
@@ -704,7 +704,7 @@ void term_exit(void);
void show_usage(void);
void remove_avoptions(AVDictionary **a, AVDictionary *b);
-void assert_avoptions(AVDictionary *m);
+int check_avoptions(AVDictionary *m);
int assert_file_overwrite(const char *filename);
char *file_read(const char *filename);
diff --git a/fftools/ffmpeg_dec.c b/fftools/ffmpeg_dec.c
index 62c1baf287..8a3b52fd7e 100644
--- a/fftools/ffmpeg_dec.c
+++ b/fftools/ffmpeg_dec.c
@@ -1119,7 +1119,10 @@ int dec_open(InputStream *ist)
av_err2str(ret));
return ret;
}
- assert_avoptions(ist->decoder_opts);
+
+ ret = check_avoptions(ist->decoder_opts);
+ if (ret < 0)
+ return ret;
ret = dec_thread_start(ist);
if (ret < 0) {
diff --git a/fftools/ffmpeg_demux.c b/fftools/ffmpeg_demux.c
index d612c5f434..48edbd7f6b 100644
--- a/fftools/ffmpeg_demux.c
+++ b/fftools/ffmpeg_demux.c
@@ -1511,7 +1511,10 @@ int ifile_open(const OptionsContext *o, const char *filename)
if (scan_all_pmts_set)
av_dict_set(&o->g->format_opts, "scan_all_pmts", NULL, AV_DICT_MATCH_CASE);
remove_avoptions(&o->g->format_opts, o->g->codec_opts);
- assert_avoptions(o->g->format_opts);
+
+ ret = check_avoptions(o->g->format_opts);
+ if (ret < 0)
+ return ret;
/* apply forced codec ids */
for (i = 0; i < ic->nb_streams; i++) {
diff --git a/fftools/ffmpeg_enc.c b/fftools/ffmpeg_enc.c
index d842bc7df4..96424272bf 100644
--- a/fftools/ffmpeg_enc.c
+++ b/fftools/ffmpeg_enc.c
@@ -407,7 +407,10 @@ int enc_open(OutputStream *ost, AVFrame *frame)
ost->sq_idx_encode, ost->enc_ctx->frame_size);
}
- assert_avoptions(ost->encoder_opts);
+ ret = check_avoptions(ost->encoder_opts);
+ if (ret < 0)
+ return ret;
+
if (ost->enc_ctx->bit_rate && ost->enc_ctx->bit_rate < 1000 &&
ost->enc_ctx->codec_id != AV_CODEC_ID_CODEC2 /* don't complain about 700 bit/s modes */)
av_log(ost, AV_LOG_WARNING, "The bitrate parameter is set too low."