Audio Modification FFmpeg AVFrame

I am trying to understand how FFmpeg stores data in AVFrameafter the sound has been decoded.

Basically, if I print data in an array AVFrame->data[], I get several unsigned 8-bit integers that are audio in raw format.

From what I can understand from FFmpeg doxygen, the data format is expressed in enum AVSampleFormatand there are two main categories: alternating and flat. In an alternating type, data is stored in the first line of an array AVFrame->datawith a size AVFrame->linesize[0], while in a planar type, each channel of an audio file is stored in a separate line in the array AVFrame->data, and the arrays are sized AVFrame->linesize[0].

Is there a manual / tutorial that explains what the numbers in the array mean for each of the formats?

+4
source share
1 answer

The values ​​in each array data(plane) are actual audio samples in accordance with the specified format. For instance. if the format AV_SAMPLE_FMT_S16Pmeans the arrays dataare actually int16_tPCM data arrays . If we are dealing with a monophonic signal - valid only data[0]if it is stereo - data[0]and data[1], and so on.

I’m not sure that there is a guide that will help you explain each specific case, but in any case the described approach is quite simple and easy to understand. You should just play around a bit with this, and the thing should be clear.

+2
source

Source: https://habr.com/ru/post/1653679/


All Articles