Back to roadmaps ffmpeg Course

Understanding Multimedia: Containers, Codecs, and FFmpeg

Before writing FFmpeg commands, you need to understand the two key components of every media file.


1. Container Formats vs Codecs

People often confuse file extensions like .mp4 or .mkv with the actual encoding format. In reality, these are two separate concepts:

  • Container Format (File Extension): The "wrapper" or "box" that holds audio, video, subtitles, and metadata tracks inside a single file. Examples: .mp4, .mkv, .webm, .mov.
  • Codec (Compressor/Decompressor): The algorithm used to encode and compress the actual audio or video stream data inside the container. Examples: H.264, H.265/HEVC, VP9, AAC, Opus.

A single container (like .mp4) can hold many different codec streams. For example, an .mp4 file might use the H.264 video codec and the AAC audio codec.


2. How FFmpeg Works

FFmpeg is a command-line tool that processes media files through a pipeline:

graph LR
    A[Input File] --> B[Demuxer: Unpack container]
    B --> C[Decoder: Decode raw frames]
    C --> D[Filter Graph: Transform frames]
    D --> E[Encoder: Re-encode frames]
    E --> F[Muxer: Pack into container]
    F --> G[Output File]

Understanding this pipeline helps you predict which steps will be slow (decoding and encoding) and which flags skip them (stream copy with -c copy).

Published on Last updated: