[Libav-user] Handling of 24 bit audio in libav* and libswresample
Paul B Mahol
onemda at gmail.com
Tue Jun 11 12:26:46 CEST 2013
On 6/11/13, Hendrik Schreiber <hs at tagtraum.com> wrote:
>> Note that dithering should be done when doing 32bit to 24bit case
>> and source audio have >24bits used.
> Yes - definitely.
>>> Dithering is only necessary, when converting the data somewhere in
>>> (e.g. changing the sample rate while it's in 32bit format), as the code
>>> pcm.c (macro ENCODE) simply shifts the 32bit representation by 8bit,
>>> essentially just dropping the last 8bits.
>> Because last 8bits are always zero for that particular case.
> Thanks, Paul, for adding the extra clarifications for the more general
> I saw that you added some more documentation for output_sample_bits
> Unfortunately, I'm still not entirely sure how to use the parameter - a
> simple example would be great.
> Let's say I want to convert 32bit audio to 24bit.
> The input AVSampleFormat is AV_SAMPLE_FMT_S32, the output sample format as
> But, when writing the result to a file, I want to use AV_CODEC_ID_PCM_S24LE,
> i.e. the least significant byte is cut off.
> Therefore, for SWR, I'm calling:
> av_opt_set_int(swr_context, "dither_method", SWR_DITHER_TRIANGULAR, 0);
> av_opt_set_int(swr_context, "output_sample_bits", ???, 0);
> What should I set ??? to?
> 24, since I'm only using 24bit?
Dunno, but if it does not work try to set dither_scale too.
If it doesn't work feel free to open bug ticket, and/or bump this thread.
> Libav-user mailing list
> Libav-user at ffmpeg.org
More information about the Libav-user