Re: [FFmpeg-devel] [PATCH] avformat/util: change av_find_default_stream_index() to use a score based system
On Fri, Aug 01, 2014 at 10:29:25PM +0200, Michael Niedermayer wrote: Disfavor video streams with unknown resolution and no packets Fixes seeking in audio-only-speex.flv Signed-off-by: Michael Niedermayer michae...@gmx.at --- libavformat/utils.c | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) applied [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB The worst form of inequality is to try to make unequal things equal. -- Aristotle signature.asc Description: Digital signature ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
[FFmpeg-devel] [PATCH] avformat/util: change av_find_default_stream_index() to use a score based system
Disfavor video streams with unknown resolution and no packets Fixes seeking in audio-only-speex.flv Signed-off-by: Michael Niedermayer michae...@gmx.at --- libavformat/utils.c | 20 ++-- 1 file changed, 14 insertions(+), 6 deletions(-) diff --git a/libavformat/utils.c b/libavformat/utils.c index 4cfebf2..6d94672 100644 --- a/libavformat/utils.c +++ b/libavformat/utils.c @@ -1531,23 +1531,31 @@ static void flush_packet_queue(AVFormatContext *s) int av_find_default_stream_index(AVFormatContext *s) { -int first_audio_index = -1; int i; AVStream *st; +int best_stream = 0; +int best_score = -1; if (s-nb_streams = 0) return -1; for (i = 0; i s-nb_streams; i++) { +int score = 0; st = s-streams[i]; if (st-codec-codec_type == AVMEDIA_TYPE_VIDEO !(st-disposition AV_DISPOSITION_ATTACHED_PIC)) { -return i; +score += 100; +if (!st-codec-width !st-codec-height !st-codec_info_nb_frames) +score -= 75; +} +if (st-codec-codec_type == AVMEDIA_TYPE_AUDIO) +score += 50; + +if (score best_score) { +best_score = score; +best_stream = i; } -if (first_audio_index 0 -st-codec-codec_type == AVMEDIA_TYPE_AUDIO) -first_audio_index = i; } -return first_audio_index = 0 ? first_audio_index : 0; +return best_stream; } /** Flush the frame reader. */ -- 1.7.9.5 ___ ffmpeg-devel mailing list ffmpeg-devel@ffmpeg.org http://ffmpeg.org/mailman/listinfo/ffmpeg-devel