Signed-off-by: Lukasz Marek <lukasz.m.lu...@gmail.com> --- ffmpeg_opt.c | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-)
diff --git a/ffmpeg_opt.c b/ffmpeg_opt.c index 77ef0c4..1b3f73a 100644 --- a/ffmpeg_opt.c +++ b/ffmpeg_opt.c @@ -1036,11 +1036,12 @@ static int get_preset_file_2(const char *preset_name, const char *codec_name, AV return ret; } -static void choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost) +static void choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream *ost, const AVCodec *forced_codec) { - char *codec_name = NULL; + const char *codec_name = forced_codec ? forced_codec->name : NULL; - MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); + if (!codec_name) + MATCH_PER_STREAM_OPT(codec_names, str, codec_name, s, ost->st); if (!codec_name) { ost->st->codec->codec_id = av_guess_codec(s->oformat, NULL, s->filename, NULL, ost->st->codec->codec_type); @@ -1053,7 +1054,7 @@ static void choose_encoder(OptionsContext *o, AVFormatContext *s, OutputStream * } } -static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index) +static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, enum AVMediaType type, int source_index, const AVCodec *forced_codec) { OutputStream *ost; AVStream *st = avformat_new_stream(oc, NULL); @@ -1080,7 +1081,7 @@ static OutputStream *new_output_stream(OptionsContext *o, AVFormatContext *oc, e ost->index = idx; ost->st = st; st->codec->codec_type = type; - choose_encoder(o, oc, ost); + choose_encoder(o, oc, ost, forced_codec); ost->enc_ctx = avcodec_alloc_context3(ost->enc); if (!ost->enc_ctx) { @@ -1276,7 +1277,7 @@ static OutputStream *new_video_stream(OptionsContext *o, AVFormatContext *oc, in AVCodecContext *video_enc; char *frame_rate = NULL, *frame_aspect_ratio = NULL; - ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index); + ost = new_output_stream(o, oc, AVMEDIA_TYPE_VIDEO, source_index, NULL); st = ost->st; video_enc = ost->enc_ctx; @@ -1437,7 +1438,7 @@ static OutputStream *new_audio_stream(OptionsContext *o, AVFormatContext *oc, in OutputStream *ost; AVCodecContext *audio_enc; - ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index); + ost = new_output_stream(o, oc, AVMEDIA_TYPE_AUDIO, source_index, NULL); st = ost->st; audio_enc = ost->enc_ctx; @@ -1507,7 +1508,7 @@ static OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc, int { OutputStream *ost; - ost = new_output_stream(o, oc, AVMEDIA_TYPE_DATA, source_index); + ost = new_output_stream(o, oc, AVMEDIA_TYPE_DATA, source_index, NULL); if (!ost->stream_copy) { av_log(NULL, AV_LOG_FATAL, "Data stream encoding not supported yet (only streamcopy)\n"); exit_program(1); @@ -1518,7 +1519,7 @@ static OutputStream *new_data_stream(OptionsContext *o, AVFormatContext *oc, int static OutputStream *new_attachment_stream(OptionsContext *o, AVFormatContext *oc, int source_index) { - OutputStream *ost = new_output_stream(o, oc, AVMEDIA_TYPE_ATTACHMENT, source_index); + OutputStream *ost = new_output_stream(o, oc, AVMEDIA_TYPE_ATTACHMENT, source_index, NULL); ost->stream_copy = 1; ost->finished = 1; return ost; @@ -1530,7 +1531,7 @@ static OutputStream *new_subtitle_stream(OptionsContext *o, AVFormatContext *oc, OutputStream *ost; AVCodecContext *subtitle_enc; - ost = new_output_stream(o, oc, AVMEDIA_TYPE_SUBTITLE, source_index); + ost = new_output_stream(o, oc, AVMEDIA_TYPE_SUBTITLE, source_index, NULL); st = ost->st; subtitle_enc = ost->enc_ctx; @@ -1638,7 +1639,7 @@ static int read_ffserver_streams(OptionsContext *o, AVFormatContext *s, const ch av_log(s, AV_LOG_ERROR, "no encoder found for codec id %i\n", ic->streams[i]->codec->codec_id); return AVERROR(EINVAL); } - ost = new_output_stream(o, s, codec->type, -1); + ost = new_output_stream(o, s, codec->type, -1, NULL); st = ost->st; avctx = st->codec; ost->enc = codec; -- 1.9.1 _______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel