Compression & Formats

What Is an Audio Codec?

Quick answer

A codec is the algorithm that encodes audio into a compressed format when saving, and decodes it back into sound during playback. Every compressed audio file — MP3, AAC, FLAC, Opus — was created by a codec. Without a matching decoder, the file is unreadable.

Where the word comes from

Codec is a portmanteau of coder and decoder — or sometimescompression/decompression. Both meanings point to the same thing: a two-way process. Something goes in, gets compressed into a smaller representation, then gets expanded back into its original form (or as close to it as the codec allows).

The word is worth knowing because it explains the job. A codec isn't a file format or a container. It's the specific algorithm — the set of rules — that decides how audio data is transformed when it gets written to disk and how it gets restored when played back.

What a codec actually does

When you record audio, the raw data is enormous. A single minute of uncompressed stereo audio at CD quality is about 10 megabytes. A codec's job is to represent that same audio using less data — ideally much less.

Think of it like a translator who specialises in concise summaries. The original conversation (raw audio) is long and detailed. The summary (encoded file) captures the important parts in a fraction of the space. When someone reads the summary later (playback), the decoder reconstructs the conversation as faithfully as the summary allows.

Encoding happens when you export, convert, or save. Decoding happens in your media player, phone, browser, or anywhere else the audio plays back. Your device needs the correct decoder for the codec used. If it doesn't have it, the file either won't play or plays back incorrectly.

Raw audio→ encoder →Compressed file→ decoder →Playback

How lossy codecs work — and why they differ

Lossy codecs all use psychoacoustic models to decide what to discard — the specific mechanics are covered in detail on the What Is Lossy Audio page. What's worth understanding here is that different lossy codecs make different decisions, which is why they perform differently at the same bitrate.

AAC, developed after MP3, improves on MP3's psychoacoustic model. It achieves better audio quality at the same bitrate — typically 128 kbps AAC is considered comparable to 192 kbps MP3 for most listeners. Opus is designed for both speech and music at extremely low bitrates (as low as 6 kbps for speech), using a more sophisticated combined model. The codec's design determines where it allocates bits most effectively.

The practical upshot: if you're encoding for streaming or voice calls and file size matters, codec choice affects quality per kilobit more than bitrate alone. At 128 kbps, AAC beats MP3. At 32 kbps voice, Opus beats everything else.

How lossless codecs work

Lossless codecs — FLAC, ALAC, APE — don't discard anything. Instead, they find more efficient ways to represent the same data. The ZIP file analogy is a good one: a ZIP archive is smaller than the original files, but extracting it gives you back every byte, unchanged.

FLAC uses a prediction algorithm — it looks at the audio waveform and predicts what comes next, then only stores the difference between the prediction and reality. Those differences are typically much smaller than the raw audio data, so the file shrinks. When you decode it, the prediction runs again and the differences are added back, reconstructing the original audio exactly.

The result: FLAC files are typically 40–60% smaller than WAV, and the decoded audio is bit-for-bit identical to the original. Not "sounds the same" — mathematically identical.

Common audio codecs

CodecTypeCommon containersTypical use
MP3Lossy.mp3Music, podcasts, general distribution
AACLossy.m4a, .mp4, .aacApple ecosystem, streaming, YouTube
OGG VorbisLossy.oggOpen-source, games, Spotify (internally)
OpusLossy.opus, .ogg, .webmVoice calls, streaming, low-latency audio
FLACLossless.flacArchiving, hi-fi listening, masters
ALACLossless.m4a, .cafApple devices, iTunes
PCMUncompressed.wav, .aiffProfessional editing, broadcast
WMALossy.wmaWindows Media — legacy

Codec vs format: a common confusion

"MP3" can refer to the codec (MPEG-1 Audio Layer III, the compression algorithm) or the file format (the .mp3 container that typically holds that codec). They happen to share a name, which causes a lot of confusion.

M4A is different — it's purely a container format. The audio inside an M4A file is almost always AAC codec. The file extension tells you the container; you need to look inside to know the codec. This is why you can have an MP4 video file where the audio track uses the AAC codec, the OGG codec, or even MP3.

The distinction matters practically: changing the container (say, from MP4 to M4A for an AAC audio track) requires no re-encoding — it's just reorganising the wrapper. Changing the codec (say, from AAC to MP3) requires full re-encoding, which can affect quality if both are lossy.

What this means when you convert

Every conversion that changes the codec is called transcoding. If you convert a FLAC to MP3, you're decoding FLAC (lossless decode, perfect) and re-encoding as MP3 (lossy encode, one-time quality reduction). That's acceptable when done intentionally.

If you convert MP3 to AAC — two lossy codecs — you decode the MP3 (getting back slightly degraded audio) and then encode it again as AAC (introducing a second round of degradation). The quality loss is cumulative. The file ends up smaller, but the audio is noticeably worse than the original MP3.

The safest approach: keep lossless masters, and encode to lossy only once — for the final distribution copy.

Last updated: March 28, 2026