[Ffmpeg-devel] Audio bitrate

Michel Bardiaux mbardiaux
Mon Nov 6 19:17:09 CET 2006


Michael Niedermayer wrote:
> Hi
> 
> On Mon, Nov 06, 2006 at 06:07:53PM +0100, Michel Bardiaux wrote:
>> Michael Niedermayer wrote:
>>> Hi
>>>
>>> On Mon, Nov 06, 2006 at 05:28:24PM +0100, Michel Bardiaux wrote:
>>>> Michael Niedermayer wrote:
>>>>> Hi
>>>>>
>>>>> On Mon, Nov 06, 2006 at 04:49:46PM +0100, Michel Bardiaux wrote:
>>>>>> Seems wrong in some cases:
>>>>>>
>>>>>> ffmpeg -i utc_1434.mpg -vn -acodec adpcm_ms -y -ar 8000 msadpcm.wav
>>>>>> FFmpeg version SVN-r6917, Copyright (c) 2000-2006 Fabrice Bellard, et 
>>>>>> al.
>>>>>> configuration:
>>>>>> libavutil version: 49.0.2
>>>>>> libavcodec version: 51.24.0
>>>>>> libavformat version: 51.6.0
>>>>>> built on Nov  6 2006 16:13:12, gcc: 3.3.5 (Debian 1:3.3.5-13)
>>>>>> Input #0, mpeg, from 'utc_1434.mpg':
>>>>>> Duration: 00:00:57.0, start: 92564.370489, bitrate: 668 kb/s
>>>>>> Stream #0.0[0x1e0]: Video: mpeg1video, yuv420p, 352x288, 104857 kb/s, 
>>>>>> 25.00 fps(r)
>>>>>> Stream #0.1[0x1c0]: Audio: mp2, 48000 Hz, mono, 32 kb/s
>>>>>> Output #0, wav, to 'msadpcm.wav':
>>>>>> Stream #0.0: Audio: adpcm_ms, 8000 Hz, mono, 64 kb/s
>>>>>> Stream mapping:
>>>>>> Stream #0.1 -> #0.0
>>>>>> Press [q] to stop encoding
>>>>>> size=     235kB time=59.8 bitrate=  32.2kbits/s
>>>>>> video:0kB audio:235kB global headers:0kB muxing overhead 0.018285%
>>>>>>
>>>>>> Should be 32kbits in the 0.0 line.
>>>>>>
>>>>>> With pcm_s16le, the bitrate is correct. But I dont see at once where it 
>>>>>> is set. "Use the source, Luke", all right, but if somebody just 
>>>>>> *knows*...
>>>>> ffmpeg.c audio_bit_rate default i guess
>>>>> changing that of course wont help ...
>>>> No. And after a bit of grepping, it appears that the only reason the 
>>>> message is right when pcm is used, is because avcodec_string 
>>>> deliberately ignores bitrate in the codec and recomputes. So, even 
>>>> though the output is right, the internal state is *not*. Which is rotten 
>>>> for those using the libs instead of the command line.
>>>>
>>>>> you could try to set AVCodecContext.bitrate in adpcm.c to the correct 
>>>>> value
>>>>> but iam not sure if this is free of sideeffects
>>>> IMHO the init method of a codec with a fixed bitrate, should force the 
>>>> correct value. Unfortunately, the init method is called LONG after 
>>>> avcodec_string is used. Maybe we need to add a method for codecs; one 
>>>> that should be called to change desired bitrate, framerate, number of 
>>>> channels, or to retrieve bitrate.
>>> add a list to AVCodec similar to supported_framerates
>>>
>>> [...]
>> And how would that help?
> 
> ffmpeg.c could select a default bitrate which is one of the supported
> ones before init, similar to the framerate and pix_fmt
> 
That would not help lib users. Having wrong bitrates in AVCodec is 
simply, well, wrong. I'm sure you would not accept new code like that!

The consequence is that there is code all over the place that computes 
various things independently of ctx->bit_rate (like avcodec_string, 
wav_put_header,...). Most of this code would not be be needed if 
bit_rate were correct.

To have it correct, it should begin correct, and remain so. That means 
an API to change parameters affecting bit_rate. I'll have to think about it.

In the meantime, I wont care that the displayed bitrate is wrong, 
because msgsm would not be the only one...

-- 
Michel Bardiaux
R&D Director
T +32 [0] 2 790 29 41
F +32 [0] 2 790 29 02
E mailto:mbardiaux at mediaxim.be

Mediaxim NV/SA
Vorstlaan 191 Boulevard du Souverain
Brussel 1160 Bruxelles
http://www.mediaxim.com/




More information about the ffmpeg-devel mailing list