From fb83cd55e7111826cc45ede380198daaff7ac60f Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Thu, 4 Jul 2013 12:01:55 -0700 Subject: [PATCH] Fix setting muxer-specific options (SF-197). Patch provided by Peter Egro --- src/modules/avformat/consumer_avformat.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) 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 ); -- 2.39.2