AudioUtils
Audio Glossary

What Is an Audio Codec?

A codec ('coder-decoder') is the algorithm that compresses raw audio into a structured bitstream for storage or transmission and decompresses it back to PCM at playback. A container is the file wrapper that holds that bitstream alongside metadata. Conflating the two causes most audio-format confusion. This page is the reference card with the distinction made concrete.

Codec vs Container — Concrete Examples

Make the distinction concrete with examples. MP3 file (.mp3): MP3 codec inside a minimal MPEG-1 stream container — codec and container share the name, the only such case. M4A file (.m4a): MP4 container holding either AAC codec (lossy, the typical case) or ALAC codec (lossless). The .m4a extension tells you the container; ffprobe tells you the codec. MP4 file (.mp4): same MP4 container as M4A but typically carrying both video (H.264 or HEVC) and audio (AAC) streams. OGG file (.ogg): Ogg container holding Vorbis, Opus, FLAC, or Speex codecs. WAV file (.wav): RIFF container holding PCM (almost always) or rarely μ-law, A-law, or IMA ADPCM. AIFF (.aiff): Apple's IFF container with PCM. FLAC (.flac): FLAC codec with its own minimal container. The file extension is the container; the codec is what's inside.

Why Devices Reject Files (Codec, Container, or Both)

When a device says 'unsupported format', it may be refusing the container, the codec, or both. iPhones natively decode AAC, ALAC, MP3, WAV, AIFF, FLAC (since iOS 11), but reject the OGG container regardless of inner codec — even though iPhones can decode Vorbis-equivalent audio in other containers. Older car stereos handle MP3 and WMA from USB but choke on AAC even though the codec inside an MP4 container is otherwise universal. Smart TVs vary by year and brand: 2018+ models usually accept FLAC; pre-2016 do not. Knowing whether to remux (change container without re-encoding the audio, lossless) or transcode (re-encode the audio, lossy step) is the difference between 30 seconds and 10 minutes of work. See [container-vs-codec-explained](/blog/container-vs-codec-explained).

Lossy Codecs Reference

MP3 (MPEG-1 Audio Layer III): the universal lossy codec, 1993, patent-free since 2017. Bitrates 32-320 kbps. Best at 192-256 kbps for music. Universal hardware support. AAC (Advanced Audio Coding): 1997, in the MPEG-4 family. Better quality than MP3 at the same bitrate, especially below 128 kbps. The default codec on Apple devices, YouTube, and most streaming. Bitrates 8-320 kbps. Vorbis: open-source competitor to MP3, common in games and Linux. Quality at par with MP3 at the same bitrate. Wraps in OGG container. Opus: IETF standard 2012, jointly developed from SILK (Skype) and CELT (Xiph). The best lossy codec at every bitrate from 6 to 510 kbps. Excellent for both voice (low bitrates) and music (high bitrates). Used by WebRTC, Discord, WhatsApp. WMA: Microsoft's codec, largely legacy. See [what-is-wma](/guide/what-is-wma).

Lossless Codecs Reference

FLAC (Free Lossless Audio Codec): the de-facto open lossless standard. Compresses PCM by 40-60% with bit-perfect decode. Universally supported except in some Apple-only chains. ALAC (Apple Lossless Audio Codec): Apple's FLAC equivalent, open-source since 2011. Same compression efficiency as FLAC, native to every iOS and macOS device. WavPack: niche, supports a hybrid lossless+lossy mode where the lossy version is the file you distribute and the correction stream restores lossless on demand. Monkey's Audio (APE): legacy lossless codec, mostly Windows-only support. PCM in WAV/AIFF: technically uncompressed rather than 'compressed-losslessly', but the result is the same — bit-perfect reproduction. PCM has no encode-decode step, just reading samples. See [pcm-audio-explained](/blog/pcm-audio-explained) and [flac-vs-alac](/blog/flac-vs-alac).

Decision Table: Which Codec Where

Default lossy distribution: MP3 192 kbps. Universal device support. Apple ecosystem distribution: AAC in M4A at 256 kbps. Better quality than MP3 at the same bitrate, native iOS/macOS support. Voice-only delivery (podcasts, audiobooks): MP3 96-128 kbps mono CBR or AAC 64-96 kbps mono. Real-time voice (Discord, WebRTC): Opus 32-64 kbps. Music streaming archive (your own library): FLAC 16-bit / 44.1 kHz. Apple lossless library: ALAC. DAW editing master: PCM WAV 24-bit / 48 kHz. Game audio assets: WAV 16-bit mono for SFX (engine compresses at build time), Vorbis or Opus for music streamed from disc. Broadcast: BWF (PCM in WAV) 24-bit / 48 kHz. Cinema: PCM and Dolby Atmos object streams. The pattern: lossless for editing and archiving, lossy for distribution.

Generation Loss and Transcoding

Each lossy encode-decode cycle discards information. Going MP3 → WAV → MP3 again is two lossy generations: the first MP3 encode discarded data (gone forever), the WAV preserves what's left, the second MP3 encode discards more. Effects accumulate: harsh treble, swirling artefacts on cymbals, dulled transients. The rule: encode lossy formats only once, at the final delivery stage, from a lossless source. If you must transcode lossy-to-lossy (no original lossless available), use the highest output bitrate to minimise additional damage — MP3 320 kbps from a 256 kbps AAC source is acceptable; MP3 96 kbps from a 128 kbps MP3 source sounds noticeably worse. Convert via [MP3 to WAV](/mp3-to-wav) to a lossless intermediate before any further processing — work in WAV, encode to lossy at the end.

Codec Choice Affects Battery and CPU

Decoding cost matters for portable devices. Apple's hardware AAC decoder uses approximately 60% less battery than the software MP3 decoder on iPhones — the AAC chip is built into the SoC; MP3 runs on the general-purpose CPU. Android: hardware AAC decoders are common; MP3 decoder is also hardware-accelerated on most devices since Android 5. Opus is software-only on most consumer devices, slightly more expensive than AAC; Discord and WhatsApp's voice features cost noticeable battery on long calls partly because of this. FLAC and ALAC decode is cheap on any device — minimal arithmetic per sample. Lossless playback uses about the same battery as lossy on modern hardware; the disk-read difference is negligible. Practical takeaway: for an iPhone music library, AAC saves battery vs MP3; for cross-platform compatibility, MP3 stays the universal choice.