A codec is the technology that compresses media for storage or streaming, then decodes it for playback.
Core concept

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.

Codec = coder/decoder. | It makes media smaller. | Different codecs balance quality, file size, and compatibility.
Simple first • More detail below

TL;DR

A codec is the technology that turns big raw media into smaller playable files.

MP3, AAC, FLAC, Opus, H.264, H.265, and AV1 are all codec-related names.

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.

TypeWhat it doesExamples
Lossy codecRemoves some data to create smaller filesMP3, AAC, Opus
Lossless codecCompresses without throwing away original dataFLAC, ALAC
Uncompressed formatStores audio with little or no compressionWAV, AIFF

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:

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.

TermPlain-English meaningExample
CodecThe method used to encode and decode audio or videoAAC, Opus, H.264, AV1
ContainerThe wrapper file that holds media streams and metadataMP4, MKV, MOV, WebM
FormatA broad word people use for codec, container, or file type depending on contextMP3, 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?

GoalGood starting pointWhy
Maximum audio compatibilityMP3Works almost everywhere.
Modern music streamingAACEfficient and broadly supported.
Archiving musicFLAC or ALACKeeps the original audio data.
General video compatibilityH.264The most widely supported video codec.
Efficient modern videoH.265 or AV1Smaller 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

Related audio guide

For the bigger picture, see Audio quality explained: what actually matters?