diff -uNrp src/input/ffms.c src.new/input/ffms.c --- src/input/ffms.c 2013-08-26 14:10:46 +0300 +++ src.new/input/ffms.c 2013-08-26 19:38:55 +0300 @@ -125,7 +125,7 @@ static int open_file( char *psz_filename int trackno = FFMS_GetFirstTrackOfType( idx, FFMS_TYPE_VIDEO, &e ); FAIL_IF_ERROR( trackno < 0, "could not find video track\n" ) - h->video_source = FFMS_CreateVideoSource( src_filename, trackno, idx, 1, seekmode, &e ); + h->video_source = FFMS_CreateVideoSource( psz_filename, trackno, idx, opt->demuxer_threads, seekmode, &e ); FAIL_IF_ERROR( !h->video_source, "could not create video source\n" ) h->track = FFMS_GetTrackFromVideo( h->video_source ); diff -uNrp src/input/input.h src.new/input/input.h --- src/input/input.h 2013-01-10 12:18:26 +0300 +++ src.new/input/input.h 2013-08-26 19:39:10 +0300 @@ -44,6 +44,7 @@ typedef struct int output_csp; /* convert to this csp, if applicable */ int output_range; /* user desired output range */ int input_range; /* user override input range */ + int demuxer_threads; } cli_input_opt_t; /* properties of the source given by the demuxer */ diff -uNrp src/input/lavf.c src.new/input/lavf.c --- src/input/lavf.c 2013-04-26 14:54:10 +0300 +++ src.new/input/lavf.c 2013-08-26 19:39:26 +0300 @@ -190,6 +190,7 @@ static int open_file( char *psz_filename /* lavf is thread unsafe as calling av_read_frame invalidates previously read AVPackets */ info->thread_safe = 0; h->vfr_input = info->vfr; + c->thread_count = opt->demuxer_threads; FAIL_IF_ERROR( avcodec_open2( c, avcodec_find_decoder( c->codec_id ), NULL ), "could not find decoder for video stream\n" ) diff -uNrp src/x264.c src.new/x264.c --- src/x264.c 2013-08-26 19:37:44 +0300 +++ src.new/x264.c 2013-08-26 19:40:55 +0300 @@ -895,6 +895,7 @@ static void help( x264_param_t *defaults H1( " --ssim Enable SSIM computation\n" ); H1( " --threads Force a specific number of threads\n" ); H2( " --lookahead-threads Force a specific number of lookahead threads\n" ); + H2( " --demuxer-threads Force a specific number of threads for demuxer (lavf, ffms)\n" ); H2( " --sliced-threads Low-latency but lower-efficiency threading\n" ); H2( " --thread-input Run Avisynth in its own thread\n" ); H2( " --sync-lookahead Number of buffer frames for threaded lookahead\n" ); @@ -955,6 +956,7 @@ typedef enum OPT_TIMEBASE, OPT_PULLDOWN, OPT_LOG_LEVEL, + OPT_DEMUXER_THREADS, OPT_VIDEO_FILTER, OPT_INPUT_FMT, OPT_INPUT_RES, @@ -1071,6 +1073,7 @@ static struct option long_options[] = { "qpfile", required_argument, NULL, OPT_QPFILE }, { "threads", required_argument, NULL, 0 }, { "lookahead-threads", required_argument, NULL, 0 }, + { "demuxer-threads", required_argument, NULL, OPT_DEMUXER_THREADS }, { "sliced-threads", no_argument, NULL, 0 }, { "no-sliced-threads", no_argument, NULL, 0 }, { "slice-max-size", required_argument, NULL, 0 }, @@ -1441,6 +1444,9 @@ static int parse( int argc, char **argv, case OPT_THREAD_INPUT: b_thread_input = 1; break; + case OPT_DEMUXER_THREADS: + input_opt.demuxer_threads = atoi( optarg ); + break; case OPT_QUIET: cli_log_level = param->i_log_level = X264_LOG_NONE; break; @@ -1597,6 +1603,7 @@ generic_option: input_opt.seek = opt->i_seek; input_opt.progress = opt->b_progress; input_opt.output_csp = output_csp; + input_opt.demuxer_threads = x264_clip3( input_opt.demuxer_threads, 1, X264_THREAD_MAX ); if( select_input( demuxer, demuxername, input_filename, &opt->hin, &info, &input_opt ) ) return -1;