Demuxing, short for demultiplexing, is the process of reading a container file or transport stream and separating its interleaved tracks into individual elementary streams, such as a video stream, one or more audio streams, subtitles and metadata. In video containers and formats, demuxing is the counterpart of muxing: a muxer packs streams into a container such as MP4, MOV, MKV or MPEG-TS, and a demuxer unpacks them again.
Every media player, editor and transcoder performs demuxing before it can decode anything, because codecs work on elementary streams, not on containers. Demuxing on its own does not decode or re-encode the content: the compressed data is extracted bit for bit, which makes it fast and lossless.
How demuxing separates streams in a container
A container stores several streams interleaved in small chunks, so that video and audio for the same moment sit close together in the file. A demuxer reads the container’s index and headers, identifies each track with its codec, timing and language, and then routes every packet to the correct output stream.
Timing is the most delicate part of the job. Each packet carries timestamps, typically a presentation timestamp (PTS) and often a decoding timestamp (DTS). The demuxer must preserve these values, because they tell the decoder when to display each frame and how to keep audio and video in sync. Losing or rewriting timestamps incorrectly is the main cause of drift after extraction.
The demuxer’s output can be passed directly to decoders, as in a media player, or written to separate files. Written streams are either kept in a raw elementary form, such as an .h264 or .aac file, or remuxed into a new container with a single track. The compressed data itself remains identical.
How container structure affects demuxing
Each container organizes its streams differently, which changes how a demuxer finds and extracts data. The table summarizes the main formats in this topic.
| Container | Internal structure | Demuxing characteristics |
|---|---|---|
| MP4 | ISO base media file format with boxes | Uses a sample table index; fast seeking |
| MOV | QuickTime atoms, closely related to MP4 | Same principles as MP4, more legacy track types |
| MKV | Matroska elements based on EBML | Flexible tracks, rich subtitle and chapter support |
| MPEG-TS | Fixed 188-byte packets with PIDs | Streamable, resilient to errors, no global index |
| MXF | Professional KLV-coded structure | Used in broadcast; may store tracks in separate files |
In MPEG-TS, each stream is identified by a packet identifier (PID), and the program tables PAT and PMT describe which PIDs belong to which program. A demuxer can start reading a transport stream at any point, which is why it is used in broadcasting and live streaming. In MP4 and MOV, the moov box holds the index; if it is missing or placed at an unreadable position after an interrupted recording, demuxing fails until the file is repaired.
Demuxing compared with related operations
Demuxing is frequently confused with transcoding, but the two operate at different layers. Demuxing works on the container; transcoding works on the encoded content.
| Operation | What changes | Quality impact | Speed |
|---|---|---|---|
| Demuxing | Streams are separated from the container | None, lossless | Very fast, limited by disk speed |
| Muxing | Streams are combined into a container | None, lossless | Very fast |
| Remuxing | Streams move to a different container | None, lossless | Very fast |
| Decoding | Compressed data becomes raw frames or samples | None by itself | Processor-intensive |
| Transcoding | Content is decoded and encoded again | Generation loss possible | Slow, processor-intensive |
Because demuxing and remuxing keep the original compressed data, they are the preferred way to change containers when the target device supports the existing codec. Transcoding should be reserved for cases in which the codec itself must change, for example when a device cannot play H.265 or a broadcaster requires a different format.
Practical uses of demuxing
Demuxing appears throughout video production and delivery, often invisibly. Typical tasks include the following.
| Task | Typical input | Result |
|---|---|---|
| Extracting audio for mixing | MOV from a camera | Separate WAV or AAC track for the sound editor |
| Pulling subtitles | MKV with several subtitle tracks | SRT or ASS files for translation |
| Repairing sync problems | Recording with drifting audio | Streams realigned and remuxed |
| Adaptive streaming packaging | Muxed MP4 master | Separate video and audio renditions |
| Broadcast monitoring | MPEG-TS from a satellite feed | Individual programs and audio languages |
Command-line tools such as FFmpeg perform demuxing with stream copy options, for example selecting a single track and copying it without re-encoding. Graphical tools for Matroska and MP4 offer the same operation through track lists. In adaptive streaming formats such as HLS and MPEG-DASH, packaging often keeps video and audio in separate segments, so players fetch only the tracks they need.
Common problems when demuxing
Most demuxing problems come from incompatible codecs, lost timing information or damaged files, rather than from the operation itself.
- Raw streams without timing: extracting H.264 to an elementary file discards container timestamps, so variable frame rate footage can play at the wrong speed.
- Audio offset after extraction: edit lists or start offsets in MP4 and MOV may not be carried over, shifting sync by a few frames.
- Codec not allowed in the target container: some subtitle and audio formats cannot be remuxed into MP4 without conversion.
- Damaged index: interrupted recordings without a valid moov box cannot be demuxed until repaired.
- Assuming demuxing converts formats: it never changes the codec; a separate transcode step is needed.
A plain-language summary
A video file is like a box that holds several things packed together: the picture, one or more soundtracks and often subtitles. Demuxing means opening the box and taking each item out separately, without changing any of them.
Every video player does this quietly before it can show anything. Editors and technicians do it on purpose when they need only the sound, only the subtitles or want to place the same picture in a different box. Nothing is re-recorded, so nothing loses quality.
An example from practice
A video editor receives a two-hour MKV file of a recorded panel discussion containing H.264 video, two AAC audio tracks in English and German, and an English subtitle track. The client needs a German version for a platform that accepts only MP4, plus the subtitles as a separate file for review.
Instead of transcoding, the editor demuxes the streams with stream copy, selecting the video track and the German audio track and remuxing them into a new MP4. The subtitle track is extracted to an SRT file. The whole operation takes only a few minutes, a fraction of the time a full re-encode of two hours of video would need, and the picture remains bit-identical to the original. A quick check of the first and last minutes confirms that audio sync is intact.