[Libav-user] AC3 -> LPCM -> MPEG2 PES

Pavel Sokolov pavel at sokolov.me
Fri Feb 24 17:00:29 CET 2012

24.02.2012 18:12, Andrey Utkin пишет:
> 2012/2/24 Pavel Sokolov<pavel at sokolov.me>:
>> Hi All!
>> I need to get LPCM data from ac3, to add it later to MPEG2 PES packet.
>> I'm using "avcodec_decode_audio4" to decode ac3 packet.
>> In which format the resulting AVFrame structure stores data?
> The decoded audio data format can be checked in AVFrame.format, and
> also AVCodecContext.sample_fmt. For audio, check it with enum
> AVSampleFormat. Sample rate is in AVCodecContext.sample_rate.
>> Is it in LPCM
>> format or something else format?
> The most widely used is AV_SAMPLE_FMT_S16, which stands for signed
> 16bit samples. So the answer is practically yes.

How can I obtain raw data from audio AVFrame?
It is array of AV_NUM_DATA_POINTERS:
typedef struct AVFrame {
uint8_t *data[AV_NUM_DATA_POINTERS];
int linesize[AV_NUM_DATA_POINTERS];

Should I use data all array items, something like this?
for (int i=0; i<AV_NUM_DATA_POINTERS;i++){
uint8_t* currdata=frame.data[i];
int dataSize=frame.linesize[i];

More information about the Libav-user mailing list