Nghĩa Trương Thanh
Nghĩa Trương Thanh

Reputation: 23

FFMPEG audio sample data

I'm beginner to FFMPEG API and I need to process audio sample. I see that audio sample data stored in AVFrame->data[0], but I don't know how audio sample stored in FFMPEG AVFrame.

For example: There are 2 channels,

frame->nb_samples = 64, 
frame->linesize[0] = 256.

I don't know how audio sample data stored in frame->data[0]. Thanks,

Upvotes: 2

Views: 1019

Answers (1)

Gordon Childs
Gordon Childs

Reputation: 36072

The audio samples are pointed to by

frame->data[0]
frame->data[1]

and they're frame->linesize[0] bytes long

The sample_fmt of your AVCodecContext will tell you the format of the samples, which will be one of the following:

AV_SAMPLE_FMT_FLTP
AV_SAMPLE_FMT_FLT
AV_SAMPLE_FMT_S16P
AV_SAMPLE_FMT_S16

For FLT you cast the pointers to float* and for S16 you cast to int16_t*

Upvotes: 1

Related Questions