From fc642311785058618e27a796fdb65cc315772f71 Mon Sep 17 00:00:00 2001 From: j-b-m Date: Mon, 27 Oct 2008 23:58:39 +0000 Subject: [PATCH] producer_avformat.c: Fix crash / corruption when changing audio or video index git-svn-id: https://mlt.svn.sourceforge.net/svnroot/mlt/trunk/mlt@1208 d19143bc-622f-0410-bfdd-b5b2a6649095 --- src/modules/avformat/producer_avformat.c | 7 +++++++ 1 files changed, 7 insertions(+), 0 deletions(-) diff --git a/src/modules/avformat/producer_avformat.c b/src/modules/avformat/producer_avformat.c index bf3654f..de5781c 100644 --- a/src/modules/avformat/producer_avformat.c +++ b/src/modules/avformat/producer_avformat.c @@ -719,6 +719,7 @@ static void producer_set_up_video( mlt_producer this, mlt_frame frame ) // Fetch the width, height and aspect ratio AVCodecContext *codec_context = context->streams[ index ]->codec; mlt_properties_set_int( properties, "_video_index", index ); + mlt_properties_set_data( properties, "video_codec", NULL, 0, NULL, NULL ); mlt_properties_set_int( properties, "width", codec_context->width ); mlt_properties_set_int( properties, "height", codec_context->height ); mlt_properties_set_double( properties, "aspect_ratio", av_q2d( codec_context->sample_aspect_ratio ) ); @@ -1098,6 +1099,12 @@ static void producer_set_up_audio( mlt_producer this, mlt_frame frame ) mlt_properties_set_int( properties, "audio_index", index ); } + // Update the audio properties if the index changed + if ( index > -1 && index != mlt_properties_get_int( properties, "_audio_index" ) ) { + mlt_properties_set_int( properties, "_audio_index", index ); + mlt_properties_set_data( properties, "audio_codec", NULL, 0, NULL, NULL ); + } + // Deal with audio context if ( context != NULL && index > -1 ) { -- 1.7.4.4