What Demuxing, Filtering, Encoding, and Muxing Mean in Video Processing

Updated

Demuxing, filtering, encoding, and muxing are the four stages of a typical video processing pipeline, and they run in that order: demux splits a container into separate audio/video/subtitle streams, filter modifies those streams (resize, crop, denoise, etc.), encode compresses them into a target codec, and mux repackages the results into a new container. The Encoding Guide (encoding-guide.neocities.org), a site about filtering and encoding video, organizes its content around exactly this structure — Demux, Filtration/Encoding/Muxing, and Extras — which reflects how the steps relate in practice.

The four stages at a glance

Stage Input What happens Output
Demux Container file (MKV, MP4, etc.) Container is split into individual streams (video, audio, subtitles) Raw elementary streams
Filter Decoded frames or audio samples Frames/samples are altered: scaling, cropping, deinterlacing, denoising, color adjustment Modified frames/samples
Encode Filtered frames/samples Compression into a target codec (e.g., H.264, H.265, AV1) at chosen quality/size Encoded video/audio stream
Mux Encoded streams Streams are combined into a container with sync info and metadata Final playable file

Why the order matters

Each stage depends on the previous one. You cannot filter frames that haven't been demuxed from their container, and you cannot mux a stream that hasn't been encoded (or extracted). Skipping or reordering steps usually means either an error or a quality loss.

A concrete example: you have a 4 GB MKV with a 1080p video track and two audio tracks, and you want a smaller 720p MP4 with one audio track.

  1. Demux — separate the video, audio 1, and audio 2 streams from the MKV.
  2. Filter — scale the video from 1080p to 720p; optionally apply denoise or crop.
  3. Encode — compress the scaled video with your chosen codec and settings; re-encode or copy the audio you keep.
  4. Mux — combine the new video stream and the kept audio stream into an MP4 container.

If you only wanted to change the container (MKV → MP4) without touching quality, you would demux and then mux with stream copy, skipping filtering and encoding entirely.

Common points of confusion

  • Demux vs. decode. Demuxing only separates streams; decoding turns compressed frames into viewable images. Filtering usually requires decoding first.
  • Encode vs. mux. Encoding changes the data itself (and is lossy unless using a lossless codec); muxing only changes the wrapper. Remuxing is fast and lossless; re-encoding is slow and lossy.
  • Filter placement. Some filters (like cropping or scaling) must run before encoding because they change frame dimensions; others (like certain audio normalization) can apply at different points depending on the tool.
  • Stream copy. When you don't need filtering or re-encoding, "copy" tells the encoder to pass the stream through untouched — useful for fast remuxes.

How to use this in practice

Most tools (FFmpeg, HandBrake, and similar) expose these stages either as explicit steps or as a single command that chains them internally. The Encoding Guide's own navigation — Demux, then Filtration/Encoding/Muxing, then Extras — mirrors the pipeline, so you can read each section as the corresponding stage.

To decide what you actually need:

  • Only changing container format? Demux + mux (stream copy). No quality loss.
  • Changing resolution, cropping, or cleaning up the image? Add filtering before encoding.
  • Reducing file size or changing codec? Full pipeline: demux → filter (if needed) → encode → mux.
  • Extracting just the audio or subtitles? Demux only.

The site was last updated on 16 March 2025, so its tool recommendations and examples reflect that point in time.