On Tue, Dec 02, 2014 at 07:27:33PM +0100, Lukasz Marek wrote: > avcodec_copy_context make dest context unopened. > ffmpeg treats it as opened. > > Signed-off-by: Lukasz Marek <lukasz.m.lu...@gmail.com> > --- > ffmpeg.c | 29 ++++++++++++++++++++--------- > 1 file changed, 20 insertions(+), 9 deletions(-) > > diff --git a/ffmpeg.c b/ffmpeg.c > index b44401f..4fa9f1e 100644 > --- a/ffmpeg.c > +++ b/ffmpeg.c > @@ -2932,6 +2932,7 @@ static int transcode_init(void) > if (ost->encoding_needed) { > AVCodec *codec = ost->enc; > AVCodecContext *dec = NULL; > + AVDictionary *opt_copy = NULL; > > if ((ist = get_input_stream(ost))) > dec = ist->dec_ctx; > @@ -2949,13 +2950,24 @@ 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); > > - if ((ret = avcodec_open2(ost->enc_ctx, codec, > &ost->encoder_opts)) < 0) { > + ret = avcodec_copy_context(ost->st->codec, ost->enc_ctx); > + if (ret < 0) { > + av_log(NULL, AV_LOG_FATAL, > + "Error initializing the output stream codec > context.\n"); > + exit_program(1); > + } > + > + av_dict_copy(&opt_copy, ost->encoder_opts, 0); > + if ((ret = avcodec_open2(ost->enc_ctx, codec, > &ost->encoder_opts)) < 0 || > + (ret = avcodec_open2(ost->st->codec, codec, &opt_copy)) < 0) > {
if the encoder is opened twice it would print any info or warnings twice. libxvid would open 2pass files twice potentially i think maybe coded_frame could just be allocated somewhere before use in ffmpeg raw and leaving the copy as it is in ffmpeg ? [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The worst form of inequality is to try to make unequal things equal. -- Aristotle
signature.asc
Description: Digital signature
_______________________________________________ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel