diff --git a/libavformat/utils.c b/libavformat/utils.c index 225b9f22da..be4d6f78af 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -2529,7 +2529,7 @@ int av_find_best_stream(AVFormatContext *ic, if (best_count >= st->codec_info_nb_frames) continue; best_count = st->codec_info_nb_frames; - ret = i; + ret = program ? program[i] : i; best_decoder = decoder; if (program && i == nb_streams - 1 && ret < 0) { program = NULL;