audioffmpeglibavlibavcodeclibavformat

Is raw audio in AVFrame->data the same as LPCM?


In the ffmpeg documentation for an AVFrame it says

This structure describes decoded (raw) audio or video data.

In the case of audio data, what format are the samples within an AVFrame in? Do they basically look like raw LPCM samples? If you decode audio data into an AVFrame (i.e. via avcodec_send_packet() ... avcodec_receive_frame()) does the audio data of the packet look the same, regardless of what encoding it was originally in in the packet (assuming the same sample rate, sample format, etc)?

Based on the question How is decoded audio data stored in ffmpeg AVFrame? it seems like this is the case, but I want to know if this is the same as LPCM, regardless of what encoding the audio data was in before?

Bonus question: If it is the same as LPCM, why would you use a PCM encoder (e.g. ""pcm_f32le") to encode the frame data to AVPackets? Does the internal data look the same? Is it just in order to use functions that take AVPackets like av_interleaved_write_frame()


Solution

  • In theory, it can be whatever the audio decoder outputs e.g. DSD, but ffmpeg raw audio is expected to be LPCM by other components e.g. filters, encoders.

    You would use a PCM encoder because the output PCM format or endianess may be different.