What is Muxing?
Muxing combines encoded video, audio, subtitles, and timing information into a synchronized container. It packages existing streams without necessarily decoding or recompressing their media content.
How Muxing works
Media muxing interleaves already encoded elementary streams and writes the indexes, timestamps, and descriptive metadata required by a chosen container. The muxer must translate each stream’s timing into the container’s time bases and obey its codec-specific framing rules. Because compressed samples can usually pass through unchanged, this operation is faster and lossless compared with re-encoding. It occupies the packaging step after encoding and before storage or delivery, with demuxing performing the reverse separation.
Key facts
- A muxer may need codec configuration records outside normal samples, such as decoder initialization data, even when it copies every compressed frame unchanged.
- Non-monotonic or missing timestamps can cause rejected samples, broken seeking, or audio/video drift despite both elementary streams decoding correctly.
- Changing MP4 to MPEG-TS is a remux only when the target container accepts the existing codecs and metadata can be represented without recoding.
When Muxing matters
Mux compatible H.264 video and AAC audio into MP4 when only their packaging needs to change. If timestamps, codecs, or container constraints conflict, remuxing may fail and transcoding may be necessary.