]> git.sesse.net Git - mlt/commitdiff
Fix regressions on libavformat v53 and failing on invalid file.
authorDan Dennedy <dan@dennedy.org>
Mon, 6 Jun 2011 01:31:11 +0000 (18:31 -0700)
committerDan Dennedy <dan@dennedy.org>
Mon, 6 Jun 2011 01:31:11 +0000 (18:31 -0700)
src/modules/avformat/producer_avformat.c

index 860ba9c3a36a67930ae91d30cc573f11d46226d4..62e3fe2e6e520e8daf90ee368cd105d9dc652e1b 100644 (file)
@@ -749,6 +749,7 @@ static int producer_open( producer_avformat self, mlt_profile profile, const cha
 
        // Now attempt to open the file or device with filename
 #if LIBAVFORMAT_VERSION_MAJOR > 52
+       self->video_format = avformat_alloc_context();
        self->video_format->flags |= AVFMT_FLAG_PRIV_OPT;
 #endif
        error = av_open_input_file( &self->video_format, filename, format, 0, &params ) < 0;
@@ -757,12 +758,20 @@ static int producer_open( producer_avformat self, mlt_profile profile, const cha
                error = av_open_input_file( &self->video_format, URL, format, 0, &params ) < 0;
 
        // Set MLT properties onto video AVFormatContext
-       apply_properties( self->video_format, properties, AV_OPT_FLAG_DECODING_PARAM );
+       if ( !error && self->video_format )
+       {
+               apply_properties( self->video_format, properties, AV_OPT_FLAG_DECODING_PARAM );
 #if LIBAVFORMAT_VERSION_MAJOR > 52
-       if ( self->video_format->iformat && self->video_format->iformat->priv_class && self->video_format->priv_data )
-               apply_properties( self->video_format->priv_data, properties, AV_OPT_FLAG_DECODING_PARAM );
-       av_demuxer_open( self->video_format, &params );
+               if ( self->video_format->iformat && self->video_format->iformat->priv_class && self->video_format->priv_data )
+                       apply_properties( self->video_format->priv_data, properties, AV_OPT_FLAG_DECODING_PARAM );
+               error = av_demuxer_open( self->video_format, &params );
+       }
+       else if ( self->video_format )
+       {
+               avformat_free_context( self->video_format );
+               self->video_format = NULL;
 #endif
+       }
 
        // Cleanup AVFormatParameters
        if ( params.standard )