[FFmpeg-devel] [PATCH] lavf: let av_find_best_stream use bitrate info if available

Marton Balint cus at passwd.hu
Sat Nov 17 14:15:00 CET 2012



On Sat, 17 Nov 2012, Michael Niedermayer wrote:

> On Sat, Nov 17, 2012 at 12:39:26AM +0100, Marton Balint wrote:
>> I guess the user expects to see the stream with the highest bitrate, not with
>> the most frames, this is especially useful for multi bitrate streams.
>>
>> This patch changes av_find_best_stream to select the stream with the highest
>> bitrate which has at least one frame.
>
> this will fail with streams that have no frame (but a incorrect high
> bitrate possibly)

That should not be a problem, because of this:

+        count = st->codec_info_nb_frames;
+        bitrate = count ? avctx->bit_rate : 0;

We reset the bitrate to 0, if frame count is 0.

> or just one frame like an jpeg/png

You mean files with e.g. cover art and a the real video? If I change the 
bitrate check to reset the bitrate if frame count is less than 2, that 
fixes this as well, right?

Thanks,
Marton


More information about the ffmpeg-devel mailing list