From 22ec6b738f1608e4b959fb655cf37c3343ec7e9f Mon Sep 17 00:00:00 2001 From: Balint Marton <cus@passwd.hu> Date: Wed, 16 Feb 2011 00:17:13 +0000 Subject: [PATCH] Fix av_find_best_stream when using a program The current implementation has a bug, it is returning the stream index in the found program, and not the stream index in the list of all streams. The attached patch fixes this issue. Signed-off-by: Mans Rullgard <mans@mansr.com> --- libavformat/utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 225b9f22da7..be4d6f78af7 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; -- GitLab