[FFmpeg-devel] [PATCH 4/4] ffmpeg: set format_option_for_user() callback
Michael Niedermayer
michaelni at gmx.at
Mon May 11 03:18:19 CEST 2015
Signed-off-by: Michael Niedermayer <michaelni at gmx.at>
---
cmdutils.c | 6 ++++++
cmdutils.h | 2 ++
ffmpeg.c | 3 +++
ffmpeg_opt.c | 2 ++
4 files changed, 13 insertions(+)
diff --git a/cmdutils.c b/cmdutils.c
index db89256..f24f65d 100644
--- a/cmdutils.c
+++ b/cmdutils.c
@@ -2111,6 +2111,12 @@ double get_rotation(AVStream *st)
return theta;
}
+const char* format_option_for_user(void *obj, const char* name, const char* value, char *tmp, int tmp_len)
+{
+ snprintf(tmp, tmp_len, "add '-%s %s'", name, value);
+ return tmp;
+}
+
#if CONFIG_AVDEVICE
static int print_device_sources(AVInputFormat *fmt, AVDictionary *opts)
{
diff --git a/cmdutils.h b/cmdutils.h
index a21ce35..47d1042 100644
--- a/cmdutils.h
+++ b/cmdutils.h
@@ -599,4 +599,6 @@ void *grow_array(void *array, int elem_size, int *size, int new_size);
double get_rotation(AVStream *st);
+const char* format_option_for_user(void *obj, const char* name, const char* value, char *tmp, int tmp_len);
+
#endif /* CMDUTILS_H */
diff --git a/ffmpeg.c b/ffmpeg.c
index 8c288ae..aec7f13 100644
--- a/ffmpeg.c
+++ b/ffmpeg.c
@@ -2419,6 +2419,7 @@ static int init_input_stream(int ist_index, char *error, int error_len)
ist->dec_ctx->get_format = get_format;
ist->dec_ctx->get_buffer2 = get_buffer;
ist->dec_ctx->thread_safe_callbacks = 1;
+ av_set_format_option_for_user_func(ist->dec_ctx, format_option_for_user);
av_opt_set_int(ist->dec_ctx, "refcounted_frames", 1, 0);
if (ist->dec_ctx->codec_id == AV_CODEC_ID_DVB_SUBTITLE &&
@@ -3050,6 +3051,8 @@ static int transcode_init(void)
av_dict_set(&ost->encoder_opts, "threads", "auto", 0);
av_dict_set(&ost->encoder_opts, "side_data_only_packets", "1", 0);
+ av_set_format_option_for_user_func(ost->enc_ctx, format_option_for_user);
+
if ((ret = avcodec_open2(ost->enc_ctx, codec, &ost->encoder_opts)) < 0) {
if (ret == AVERROR_EXPERIMENTAL)
abort_codec_experimental(codec, 1);
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 240f727..bf297f0 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -901,6 +901,8 @@ static int open_input_file(OptionsContext *o, const char *filename)
remove_avoptions(&o->g->format_opts, o->g->codec_opts);
assert_avoptions(o->g->format_opts);
+ av_set_format_option_for_user_func(ic, format_option_for_user);
+
/* apply forced codec ids */
for (i = 0; i < ic->nb_streams; i++)
choose_decoder(o, ic, ic->streams[i]);
--
1.7.9.5
More information about the ffmpeg-devel
mailing list