What is a Codec

A codec is a piece of software that compresses and decompresses (or codes and decodes) digital media files, such as audio and video. The name “codec” is a combination of the two words: coder and decoder.

Why are Codecs Needed?

Raw, uncompressed video and audio files are enormous. For example, just one minute of uncompressed high-definition video can take up gigabytes of space. Codecs solve this problem by using algorithms to shrink the file size, making them small enough to be easily stored on your device or streamed over the internet.

How They Work: Coder & Decoder

A codec has two parts that work together:

  • The Coder (or Encoder) 🗜️: When you create or save a video, the coder compresses the raw data into a smaller, manageable file. It intelligently removes information that the human eye or ear is unlikely to notice to achieve smaller sizes.
  • The Decoder ▶️: When you want to play that video, the decoder unpacks and reconstructs the compressed data so you can watch and hear it on your screen. Your media player (like VLC or YouTube) uses a decoder to play the file.

Codec vs. Container (File Format)

It’s common to confuse codecs with container formats like .mp4, .mkv, or .mov.

  • A container is like a box or a wrapper that holds all the different parts of a media file together. 📦
  • The codecs are what were used to prepare the contents inside that box (e.g., the encoded video stream and the encoded audio stream).

A single .mp4 file could contain video encoded with the H.264 codec and audio encoded with the AAC codec.

Common Examples

  • Video Codecs: H.264 (AVC), H.265 (HEVC), AV1, VP9
  • Audio Codecs: AAC, MP3, FLAC, Opus

Guides