]> git.sesse.net Git - mlt/commitdiff
Fix setting muxer-specific options (SF-197).
authorDan Dennedy <dan@dennedy.org>
Thu, 4 Jul 2013 19:01:55 +0000 (12:01 -0700)
committerDan Dennedy <dan@dennedy.org>
Thu, 4 Jul 2013 19:01:55 +0000 (12:01 -0700)
Patch provided by Peter Egro <pegro@users.sf.net>

src/modules/avformat/consumer_avformat.c

index 6a4982c3b9293b5f6ec309d80c6396b10eb436cf..d9215d23ac1a0e91e136de80bc8f5fccf937bfc4 100644 (file)
@@ -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 );