Thanh Nguyen
Thanh Nguyen

Reputation: 133

channel layout of audio

I have some question hoping you to answer.

I am using ffmpeg sdk to develop a new video player base on ffplay.c.

However,I don't understand some concept.

What is channel layout, channel of audio?

Upvotes: 3

Views: 5978

Answers (2)

Scott Stensland
Scott Stensland

Reputation: 28285

mono audio is one channel
stereo 2 channel
... additional channels are also accommodated

In the audio buffer for each sample the data for each channel is interleaved (only for packed sample formats which is typical) :

1st sample (typically 2 bytes for a bit depth of 16 bit CD quality audio)

two bytes ch a
two bytes ch b

2nd sample

two bytes ch a
two bytes ch b

with video this also includes interleaving video into the data stream ... different approaches as per video codec

Here is an excerpt from ffmpeg docs :

For planar sample formats, each audio channel is in a separate data plane, and linesize is the buffer size, in bytes, for a single plane. All data planes must be the same size. For packed sample formats, only the first data plane is used, and samples for each channel are interleaved. In this case, linesize is the buffer size, in bytes, for the 1 plane.

Upvotes: 4

Lihang Li
Lihang Li

Reputation: 361

Channel layout can be used to describe how your audio is organized, like Mono is just 1 channel, Stereo is 2 channel. You can think this way, how you hear the sound, there can be many sources (locations), right? Like front center, front left, front right, etc.

Each individual channel stand for a source, and a channel layout is just a combinations of channels.

See Manipulating audio channels with ffmpeg for more details:-)

Upvotes: 1

Related Questions