What is a Codec?
A codec compresses audio or video so it can be stored, streamed, or shared, then decodes it again when you play it.
Simple explanation
A codec is a tool used to compress and decompress audio or video data.
The word codec comes from coder-decoder. The coder part turns raw media into a smaller, more practical stream. The decoder part turns that stream back into sound or pictures when you press play.
Without codecs, music, movies, online video, podcasts, and voice calls would require much more storage and bandwidth.
Think of a codec like packing a suitcase
Raw audio and video are like a pile of clothes spread across the floor. They contain everything, but they take up a lot of space.
A codec packs that information more efficiently. Some codecs pack carefully and keep everything. Others throw away less important details to make the file much smaller.
Why codecs are needed
Digital media can be huge. Uncompressed audio takes far more space than an MP3 or AAC file, and raw video can be enormous compared with a streamed video file.
Codecs make modern media practical by helping with:
- Streaming: smaller data streams are easier to send over the internet.
- Storage: compressed files take up less space on phones, laptops, and servers.
- Sharing: smaller files upload, download, and transfer more easily.
- Compatibility: common codecs make playback work across many devices.
How a codec works, step by step
1. Encoding
The codec analyzes the original audio or video and turns it into a compressed stream.
2. Storage or streaming
The compressed data is saved in a file or sent over the internet using less space and bandwidth.
3. Decoding
Your phone, browser, app, player, TV, or DAC decodes the stream so you can hear or see it.
For everyday users, the important part is not the math. It is the trade-off: codecs decide how much quality you keep, how small the file becomes, and how widely it will play.
Codec vs format vs container
This is where the terminology gets confusing. People often use these words loosely, but they are not always the same thing.
| Term | Plain-English meaning | Example |
|---|---|---|
| Codec | The method used to encode and decode audio or video | AAC, Opus, H.264, AV1 |
| Container | The wrapper file that holds media streams and metadata | MP4, MKV, MOV, WebM |
| Format | A broad word people use for codec, container, or file type depending on context | MP3, WAV, FLAC, MP4 |
For a deeper breakdown, read codec vs format vs standard and what is a container format?
Audio codec examples
MP3
The classic lossy audio format. Still popular because it works almost everywhere.
AAC
A more modern lossy audio codec used widely in streaming and Apple devices.
FLAC and ALAC
Lossless audio formats that preserve the original audio data while reducing file size.
Video codec examples
H.264
The safe compatibility choice for video. It plays on a huge range of devices.
H.265 / HEVC
More efficient than H.264, but compatibility can be more complicated.
AV1
A newer open codec designed for efficient streaming, especially at lower bitrates.
What codec should you use?
| Goal | Good starting point | Why |
|---|---|---|
| Maximum audio compatibility | MP3 | Works almost everywhere. |
| Modern music streaming | AAC | Efficient and broadly supported. |
| Archiving music | FLAC or ALAC | Keeps the original audio data. |
| General video compatibility | H.264 | The most widely supported video codec. |
| Efficient modern video | H.265 or AV1 | Smaller files at similar quality, depending on device support. |
Common codec questions
Is a codec the same as a file extension?
No. A file extension such as .mp4, .mkv, or .mov often describes the container. The codec is the method used for the audio or video inside.
Can two files with the same extension use different codecs?
Yes. For example, two MP4 files may look similar, but one could contain H.264 video while another contains H.265 video.
Why does one file play and another does not?
Your device may support the container but not the codec inside it. This is why codec support matters more than the file extension alone.
Learn more
Next beginner pages
Popular comparisons
Related audio guide
For the bigger picture, see Audio quality explained: what actually matters?