Muxing
Muxing (Multiplexing Streams)
The process of combining separate video, audio, subtitle, and metadata streams into a single container file, or the reverse operation of extracting individual streams from a container (demuxing).
技術的詳細
Multiplexing interleaves data from multiple streams into a single file, managing synchronization timestamps, stream identification, and index/seek tables. The muxer assigns each stream a track ID, writes headers, interleaves data packets by presentation timestamp (PTS), and builds the container's index structure (moov atom for MP4, Cues for MKV). Remuxing (changing container without re-encoding) is fast since only the wrapper changes. FFmpeg handles muxing/demuxing: ffmpeg -i video.h264 -i audio.aac -c copy output.mp4 combines raw streams into MP4. Common operations include adding an audio track to a video, extracting audio from a video, and adding subtitles as a separate stream.
例
```html <!-- Muxing: HTML5 video with format fallback --> <video controls preload="metadata"> <source src="video.webm" type="video/webm; codecs=vp9,opus"> <source src="video.mp4" type="video/mp4"> Your browser does not support HTML5 video. </video> ```