aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorLukasz Marek <lukasz.m.luki2@gmail.com>2014-11-16 21:57:54 +0100
committerLukasz Marek <lukasz.m.luki2@gmail.com>2014-11-27 23:19:46 +0100
commit3ff39901049f430f82d252eab3f4c0800ef144e5 (patch)
treec961a4fbf0f4bbd5719c7390b25d85596a72d974
parent500d6088618a8a1b23d8190455430dcdd9230c9c (diff)
downloadffmpeg-3ff39901049f430f82d252eab3f4c0800ef144e5.tar.gz
ffmpeg_opt: make use of recommended encoder configuration
So far ffmpeg used recommended configuration only for codec priv options. ffmpeg will use now codec defaults and then apply recommended configuration for all options. Recommended configuration possibly contains minimal set of options to filful user configuration. Signed-off-by: Lukasz Marek <lukasz.m.luki2@gmail.com>
-rw-r--r--ffmpeg_opt.c41
1 files changed, 12 insertions, 29 deletions
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c
index 85466c78c1..03e049bd8d 100644
--- a/ffmpeg_opt.c
+++ b/ffmpeg_opt.c
@@ -1617,31 +1617,6 @@ static int copy_chapters(InputFile *ifile, OutputFile *ofile, int copy_metadata)
return 0;
}
-static int ffserver_streams_copy_context(AVCodecContext *dest, const AVCodecContext *src,
- const char *configuration)
-{
- int ret;
- if ((ret = avcodec_copy_context(dest, src)) < 0)
- return ret;
- dest->codec = avcodec_find_encoder(src->codec_id);
- if (!dest->codec)
- return AVERROR(EINVAL);
- if (!dest->codec->priv_class || !dest->codec->priv_data_size)
- return 0;
- if (!dest->priv_data) {
- dest->priv_data = av_mallocz(dest->codec->priv_data_size);
- if (!dest->priv_data)
- return AVERROR(ENOMEM);
- *(const AVClass**)dest->priv_data = dest->codec->priv_class;
- }
- av_opt_set_defaults(dest->priv_data);
- if (av_set_options_string(dest->priv_data, configuration, "=", ",") < 0) {
- av_log(dest, AV_LOG_WARNING, "Cannot copy private codec options. Using defaults.\n");
- av_opt_set_defaults(dest->priv_data);
- }
- return 0;
-}
-
static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const char *filename)
{
int i, err;
@@ -1656,6 +1631,7 @@ static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const ch
AVStream *st;
OutputStream *ost;
AVCodec *codec;
+ const char *enc_config;
codec = avcodec_find_encoder(ic->streams[i]->codec->codec_id);
if (!codec) {
@@ -1669,15 +1645,22 @@ static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const ch
ost = new_output_stream(o, s, codec->type, -1);
st = ost->st;
- ffserver_streams_copy_context(st->codec, ic->streams[i]->codec,
- av_stream_get_recommended_encoder_configuration(ic->streams[i]));
+ avcodec_get_context_defaults3(st->codec, codec);
+ enc_config = av_stream_get_recommended_encoder_configuration(ic->streams[i]);
+ if (enc_config) {
+ AVDictionary *opts = NULL;
+ av_dict_parse_string(&opts, enc_config, "=", ",", 0);
+ av_opt_set_dict2(st->codec, &opts, AV_OPT_SEARCH_CHILDREN);
+ av_dict_free(&opts);
+ }
if (st->codec->codec_type == AVMEDIA_TYPE_AUDIO && !ost->stream_copy)
choose_sample_fmt(st, codec);
else if (st->codec->codec_type == AVMEDIA_TYPE_VIDEO && !ost->stream_copy)
choose_pixel_fmt(st, st->codec, codec, st->codec->pix_fmt);
- ffserver_streams_copy_context(ost->enc_ctx, st->codec,
- av_stream_get_recommended_encoder_configuration(ic->streams[i]));
+ avcodec_copy_context(ost->enc_ctx, st->codec);
+ if (enc_config)
+ av_dict_parse_string(&ost->encoder_opts, enc_config, "=", ",", 0);
}
avformat_close_input(&ic);