From 33f3239be85086acbe88f61ab467997593c02ba0 Mon Sep 17 00:00:00 2001 From: Dan Dennedy Date: Sun, 6 Dec 2009 23:02:46 -0800 Subject: [PATCH] Fix crash in x264 on second pass of multi-threaded encoding. --- src/modules/avformat/consumer_avformat.c | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/src/modules/avformat/consumer_avformat.c b/src/modules/avformat/consumer_avformat.c index 2bef35b4..e2c264b9 100644 --- a/src/modules/avformat/consumer_avformat.c +++ b/src/modules/avformat/consumer_avformat.c @@ -1316,8 +1316,15 @@ static void *consumer_thread( void *arg ) } #endif + // XXX ugly hack to prevent x264 from crashing on second pass of multi-threaded encoding + int pass = mlt_properties_get_int( properties, "pass" ); + int thread_count = mlt_properties_get_int( properties, "threads" ); + if ( thread_count == 0 && getenv( "MLT_AVFORMAT_THREADS" ) ) + thread_count = atoi( getenv( "MLT_AVFORMAT_THREADS" ) ); + int multithreaded_x264 = ( video_codec_id == CODEC_ID_H264 && pass == 2 && thread_count > 1 ); + // close each codec - if (video_st) + if ( video_st && !multithreaded_x264 ) close_video(oc, video_st); if (audio_st) close_audio(oc, audio_st); @@ -1354,7 +1361,7 @@ static void *consumer_thread( void *arg ) mlt_consumer_stopped( this ); - if ( mlt_properties_get_int( properties, "pass" ) == 2 ) + if ( pass == 2 ) { // Remove the dual pass log file if ( mlt_properties_get( properties, "_logfilename" ) ) -- 2.39.2