X-Git-Url: https://git.sesse.net/?a=blobdiff_plain;f=src%2Fmodules%2Favformat%2Fconsumer_avformat.c;h=d9215d23ac1a0e91e136de80bc8f5fccf937bfc4;hb=fb83cd55e7111826cc45ede380198daaff7ac60f;hp=6a4982c3b9293b5f6ec309d80c6396b10eb436cf;hpb=47eef7b244ffae6a4ae3405c6bcb3805998b20ac;p=mlt diff --git a/src/modules/avformat/consumer_avformat.c b/src/modules/avformat/consumer_avformat.c index 6a4982c3..d9215d23 100644 --- a/src/modules/avformat/consumer_avformat.c +++ b/src/modules/avformat/consumer_avformat.c @@ -1178,7 +1178,7 @@ static void *consumer_thread( void *arg ) int count = 0; // Allocate the context - AVFormatContext *oc = avformat_alloc_context( ); + AVFormatContext *oc = NULL; // Streams AVStream *video_st = NULL; @@ -1232,6 +1232,22 @@ static void *consumer_thread( void *arg ) if ( filename == NULL || !strcmp( filename, "" ) ) filename = "pipe:"; +#if LIBAVUTIL_VERSION_INT >= ((53<<16)+(2<<8)+0) + avformat_alloc_output_context2( &oc, fmt, format, filename ); +#else + oc = avformat_alloc_context( ); + oc->oformat = fmt; + snprintf( oc->filename, sizeof(oc->filename), "%s", filename ); + + if ( oc->oformat && oc->oformat->priv_class && !oc->priv_data && oc->oformat->priv_data_size ) { + oc->priv_data = av_mallocz( oc->oformat->priv_data_size ); + if ( oc->priv_data ) { + *(const AVClass**)oc->priv_data = oc->oformat->priv_class; + av_opt_set_defaults( oc->priv_data ); + } + } +#endif + // Get the codec ids selected audio_codec_id = fmt->audio_codec; video_codec_id = fmt->video_codec; @@ -1310,9 +1326,6 @@ static void *consumer_thread( void *arg ) } } - oc->oformat = fmt; - snprintf( oc->filename, sizeof(oc->filename), "%s", filename ); - // Get a frame now, so we can set some AVOptions from properties. frame = mlt_consumer_rt_frame( consumer );