Op 18 jan 2009, om 00:54 heeft Franco Amato het volgende geschreven:

> Hi to all,
> I have a problem that I can not solve.
> In my encoder I'm encoding video and audio, the problem comes with  
> the audio
> part.
> My original audio raw samples are pcm float  -1/+1 stereo. So I have  
> 4 bytes
> (2 for the L channel and 2 for the R channel TOTAL = 4 bytes).

floats are in fact 4 bytes -> 32bit
for a second of audio stored using float with a sample rate of 48Khz,  
you would need 48000 * 2 chan * 4 bytes = 384000 bytes.

>
> To encode an audio frame and use the avcodec_encode_audio ffmpeg  
> need the
> samples to be
> signed short (2 bytes - 1 for the L channel and 1 for the R channel  
> TOTAL =
> 2 bytes) so to use this routine I need to convert my original raw  
> samples
> from float to signed short.
> I use this simple algorithm
>
> sample_signed_short = (signed short) sample_float * 32767; // this  
> for every
> sample I have
>
> Doing this I'm sure I loose lots of quality because 1 byte can not  
> store the
> information that 2 bytes contains right? In fact the quality of the  
> audio of
> my produced mpeg is very bad.

you should probably check if you are actually converting samples or  
just parts of them..
There should be no audiable loss when converting from 32- to 16bit  
samples under standard conditions.
You may run into trouble when the source of audio is recorded on very  
low levels (only using the lowest bits)

- Arjan

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to