[Libav-user] Sample format questions

Paul B Mahol onemda at gmail.com
Tue Mar 26 19:25:19 CET 2013

On 3/26/13, Brad O'Hearne <brado at bighillsoftware.com> wrote:
> On Mar 26, 2013, at 10:29 AM, Paul B Mahol <onemda at gmail.com> wrote:
> Thx for the reply!
>> sample format is set by decoder to what sample format decoder outputs its
>> data,
>> similar apply for encoder input.
> Yes, I'm actually encoding, but point taken. Sample format is by the
> encoder, true. However, in my scenario I have an intermediate step prior to
> getting to the encoder. I am receiving a sample buffer from QTKit capture
> which is in a different sample format than the encoder is looking for. In my
> case, the audio encoder is adpm_swf (I am encoding video and audio to an FLV
> video file). adpm_swf is looking for a sample format of AV_SAMPLE_FMT_S16,
> which is not the format being received from capture. The format I am
> receiving from capture is
> Linear PCM, 32 bit little-endian floating point, 2 channels, 44100

Unless you are on big endian, FLT sample format should be fine.
Otherwise you need
to swap each 4 bytes.

> So I have to resample the decompressed audio sample received from capture so
> that it is in a format of AV_SAMPLE_FMT_S16 before passing it to the
> encoder. Coming in from QTKit, it obviously knows nothing about Libav
> constants. I have all of the necessary attributes on the sample buffer,
> which I want to use to have Libav deliver the proper sample format without
> me hardcoding it (which it is now, I'm using AV_SAMPLE_FMT_FLT). However,
> for some reason, the audio when encoded is garbage, so I'm trying to verify
> the entire processing pipeline, eliminating assumptions. One assumption I've
> made is the sample format, another is the endianness -- I'm interested in
> functions to return each. Does such a function exist for returning what
> sample format should be used, given linear/planar, bytes/endianness,
> channels, etc.?
>> any planar sample format with more than 1 channel is not interleaved.
> Does it follow then that any linear format with more than one channel IS
> interleaved?

Probably, I never worked with QTKit capture so I dunno. It could return
raw data or raw data with some headers.

>> As already mentioned data is always in native endian, its decoder
>> responsibility....
> Is there a function that returns what endianness the sample format is
> presently using (and I'm not looking for a function or doc that specifies
> something along the lines of "native" here -- I'm looking for the specific
> endianness so that I can verify that it is indeed native.

It is always native, eg. decoder gives native, encoder expects native input.

> Thanks,
> Brad
> _______________________________________________
> Libav-user mailing list
> Libav-user at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/libav-user

More information about the Libav-user mailing list