aboutsummaryrefslogtreecommitdiffstats
path: root/fftools/ffmpeg_opt.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2023-07-13 17:36:57 +0200
committerAnton Khirnov <anton@khirnov.net>2023-07-20 20:40:26 +0200
commit26e1e80152beccb12919cc1078f5f42e3a6774c9 (patch)
tree9a7ad6b4ed5a88e87713219f00511b5bbb6c8ab9 /fftools/ffmpeg_opt.c
parent37abb3a41913a7f5b83c0f81acb6775f127c86c4 (diff)
downloadffmpeg-26e1e80152beccb12919cc1078f5f42e3a6774c9.tar.gz
fftools/ffmpeg_opt: reimplement -streamid using a dictionary
This does not require an arbitrary limit on the number of streams. Also, return error codes from opt_streamid() instead of aborting.
Diffstat (limited to 'fftools/ffmpeg_opt.c')
-rw-r--r--fftools/ffmpeg_opt.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/fftools/ffmpeg_opt.c b/fftools/ffmpeg_opt.c
index 25a1083366..7002986369 100644
--- a/fftools/ffmpeg_opt.c
+++ b/fftools/ffmpeg_opt.c
@@ -128,8 +128,9 @@ static void uninit_options(OptionsContext *o)
#if FFMPEG_OPT_MAP_CHANNEL
av_freep(&o->audio_channel_maps);
#endif
- av_freep(&o->streamid_map);
av_freep(&o->attachments);
+
+ av_dict_free(&o->streamid);
}
static void init_options(OptionsContext *o)
@@ -727,7 +728,6 @@ char *file_read(const char *filename)
static int opt_streamid(void *optctx, const char *opt, const char *arg)
{
OptionsContext *o = optctx;
- int idx;
char *p;
char idx_str[16];
@@ -737,13 +737,11 @@ static int opt_streamid(void *optctx, const char *opt, const char *arg)
av_log(NULL, AV_LOG_FATAL,
"Invalid value '%s' for option '%s', required syntax is 'index:value'\n",
arg, opt);
- exit_program(1);
+ return AVERROR(EINVAL);
}
*p++ = '\0';
- idx = parse_number_or_die(opt, idx_str, OPT_INT, 0, MAX_STREAMS-1);
- o->streamid_map = grow_array(o->streamid_map, sizeof(*o->streamid_map), &o->nb_streamid_map, idx+1);
- o->streamid_map[idx] = parse_number_or_die(opt, p, OPT_INT, 0, INT_MAX);
- return 0;
+
+ return av_dict_set(&o->streamid, idx_str, p, 0);
}
static int init_complex_filters(void)