What Is an Audio Codec?
Codec stands for coder-decoder. It is the algorithm that compresses audio into a specific format and decompresses it for playback. MP3 is a codec. AAC is a codec. FLAC is a codec. Understanding codecs helps you choose the right format.
Codec Basics
An encoder compresses raw audio into a smaller format. A decoder reads that format and turns it back into audio your speakers can play. Together they form a codec. Different codecs use different algorithms. Some throw away data (lossy). Some preserve everything (lossless). The codec determines the quality, file size, and compatibility of your audio. Choosing a codec is the most important audio format decision you make.
Lossy Codecs
MP3 (MPEG-1 Audio Layer III): Oldest mainstream lossy codec. Universal support. Good quality at 192+ kbps. AAC (Advanced Audio Coding): Better than MP3 at equivalent bitrates. Used by Apple, YouTube, Spotify. Vorbis: Open-source. Great quality. Popular in gaming. Opus: The best lossy codec available. Excellent at all bitrates from 6 kbps to 510 kbps. Works for both speech and music. Growing adoption. WMA: Microsoft's codec. Largely obsolete.
Lossless Codecs
FLAC: Free, open, widely supported. The standard for lossless audio. ALAC: Apple's lossless codec. Open-source since 2011. Equivalent to FLAC in quality and compression. Native Apple device support. WavPack: Supports a unique hybrid mode. Niche but capable. PCM: Technically not compressed at all — raw audio samples. Used in WAV and AIFF containers. No encoding or decoding needed, just reading the numbers directly.
Codecs vs Containers
This distinction confuses many people. A codec is the compression algorithm. A container is the file wrapper. OGG is a container that can hold Vorbis, Opus, or FLAC codecs. M4A is a container that holds AAC or ALAC codecs. WAV is a container that holds PCM (or rarely other codecs). The file extension usually tells you the container, not the codec. Two M4A files might use completely different codecs inside.
Choosing the Right Codec
For maximum compatibility: MP3. Every device plays it. For Apple ecosystem: AAC in M4A container. For gaming and open-source: Vorbis in OGG. For voice and real-time: Opus. For lossless storage: FLAC. For lossless on Apple: ALAC. For professional editing: PCM in WAV. Start with your use case and work backward to the right codec.