Log in

View Full Version : What does muxing do?


Krokodil
19th January 2008, 23:31
This is a technical question, but I'm hoping someone can give me a fairly simple answer or direct me to somewhere where I can learn more about this without reading MPlayers source code.

When you mux an audio stream and a video stream together into a container, what exactly happens?

Does it create chunks that contain both audio and video data or does it split the two streams into smaller chunks and combine them like a clothing zip or do the streams simply huddle next to each other inside the container. Does it depend on the container?

I'm mostly interested in AVI and Matroska, but other info on other containers would also be interesting.

dstarfire
20th January 2008, 01:28
I'm pretty sure the audio tracks are stored as a seperate file in the container (i.e. segments 1-15 are video, 16-19 are audio 1, etc.).

Combining them together as a stream would seriously increase the processing load to decode the data, and, even worse, decrease efficiency of the compression algorithm.

Even in analog devices, the audo data is placed in a seperate stream alongside the video stream, usually on an adjacent frequency, or media band.

Krokodil
20th January 2008, 10:24
I'm pretty sure the audio tracks are stored as a seperate file in the container (i.e. segments 1-15 are video, 16-19 are audio 1, etc.).

<snip>

Even in analog devices, the audo data is placed in a seperate stream alongside the video stream, usually on an adjacent frequency, or media band.

Right, like the audio track on film. Makes sense.

What are the segments you're talking about?

setarip_old
20th January 2008, 16:32
@Krokodil

You might want to read the information contained at the following link:

http://209.85.173.104/search?q=cache:GH_DLZP3wDUJ:en.wikipedia.org/wiki/Multiplexing+%22multiplex%22+and+%22video%22+and+%22audio%22+and+%22definition%22&hl=en&ct=clnk&cd=1&gl=us

It includes the following:Video processing
In video editing and processing systems, multiplexing refers to the process of interleaving audio and video into one coherent transport stream (time-division multiplexing).

In digital video, such a transport stream is normally a feature of a container format which may include metadata and other information, such as subtitles. Software that produces such a transport stream and/or container is commonly called a muxer. A demuxer is software that extracts or otherwise makes available for separate processing the components of such a stream or container.

Krokodil
21st January 2008, 08:42
[Color=Blue]@Krokodil

You might want to read the information contained at the following link:


Thanks, I have read that before my original post, but either I'm missing something or it doesn't explain what I am looking for. ie. In an AVI containing a MPEG-4 Pt. 2 video stream and MP3 audio stream, are there actually just two separate files and the AVI header explains what to do with them, or have they been combined in some way?

Is the process of muxing simply identifying and copying the streams into one file and slapping a header on top, or is it more complicated?

Another way of asking is my question is, can I extract the video or audio stream from an AVI simply by lopping off the ends of an AVI, or do I need to read the header and extract little chunks from throughout the file and then combine them again. (Note: I know there are programs that do this, I'm just after the theory).

setarip_old
21st January 2008, 17:37
You are asking about "interleaving". Read the following:

http://72.14.253.104/search?q=cache:xBsnCarbUvIJ:forum.doom9.org/archive/index.php/t-93469.html+%22interleaving%22+and+%22video%22+and+%22audio%22&hl=en&ct=clnk&cd=3&gl=us

dstarfire
23rd January 2008, 03:59
Right, like the audio track on film. Makes sense.

What are the segments you're talking about?

Segments are similarly sized chunks of data, arranged in some sort of meaningful sequence. Here's an ascii drawing for the visually inclined.
|Segment 1 Data |--->|Segment 2 Data|--->|Segment 3 Data|...

Krokodil
4th February 2008, 21:56
You are asking about "interleaving". Read the following:

http://72.14.253.104/search?q=cache:xBsnCarbUvIJ:forum.doom9.org/archive/index.php/t-93469.html+%22interleaving%22+and+%22video%22+and+%22audio%22&hl=en&ct=clnk&cd=3&gl=us

Thanks, that helped alot.

setarip_old
4th February 2008, 23:03
Thanks, that helped alot.As always, my pleasure ;>}