Audio Codecs Explained: Lossy vs Lossless

In short

A codec encodes audio into a compact form and decodes it for playback. Here is how lossy and lossless compression differ and how to choose.

What an audio codec does

A codec is a piece of software or hardware that encodes audio into a compact form and decodes it again for playback. The name comes from coder and decoder. Raw digital audio is large, because it stores a very large number of samples every second for every channel. Compression makes the data practical to store and send. A codec is not the same as a container. The codec describes how the sound data is compressed, while the container is the file wrapper that holds the data and often metadata such as titles.

How lossless compression works

Lossless codecs rebuild the original audio exactly after decoding, sample for sample. They do this by removing redundancy, in a way that is similar to zipping a file. The result is smaller than raw audio but usually larger than a lossy file of the same recording.

Common lossless formats

  • FLAC is an open format with wide support across players and devices.
  • ALAC is the lossless format associated with the Apple ecosystem.
  • WAV is usually uncompressed and is a useful reference point for what the original data looks like.

How lossy compression works

Lossy codecs discard information that people are unlikely to hear. They rely on psychoacoustics, the study of how we perceive sound. One example is masking: a loud sound can hide a quieter sound at a similar pitch, so the quiet one can be stored with less detail or dropped. Bitrate controls the trade-off, since a lower bitrate gives a smaller file but forces the codec to discard more.

Common lossy codecs

  • MP3 and AAC are long-standing choices that are supported almost everywhere.
  • Opus handles both speech and music and works well for real-time use such as calls.
  • When the bitrate is too low, typical artifacts include a watery or swirling sound, dull highs and smeared attacks on drums.

Lossy vs lossless: how to choose

Archiving and editing favor lossless, because you keep every detail and avoid quality loss between steps. Streaming, calls and mobile listening usually favor lossy, because small files save storage and bandwidth. Also consider device support and listening conditions, since a noisy commute hides differences that a quiet room would reveal. Avoid re-encoding lossy files repeatedly, because each pass discards more information and the artifacts add up.

Common myths

  • Lossless does not always sound audibly better, because a well-encoded lossy file can be hard to tell apart from the original.
  • Converting a lossy file to a lossless format does not restore what was discarded; it only stores the damaged audio in a bigger file.
  • A higher bitrate helps only up to a point, after which the gains are too small to hear.

Where to go next

Kodeec is an independent software magazine and knowledge base that explains audio and video codecs, from H.264 and AV1 to Opus. Developers and curious readers can explore the other codec guides on the site to go deeper into how each format works.

This article was prepared with AI assistance and checked by a person before it was published.