Audio codecs overview
New to audio coding? Start with the intro. Otherwise, this is the short version of what to pick.
Which codec should I use?
Section titled “Which codec should I use?”| You want | Use | Notes |
|---|---|---|
| Lossy audio for most things — music, speech, video soundtracks | Opus | Best quality per bit across the whole range, from low-bitrate speech to near-transparent music. Ogg, WebM, Matroska, MP4. |
| Lossy audio that has to play on everything, including hardware players, TVs and old phones | AAC in MP4/M4A | The safe choice for MP4 video and streaming. |
| Lossy audio for really old devices | MP3 | Needs more bitrate than AAC or Opus for the same quality, but plays on anything. |
| Lossless archive or lossless delivery | FLAC | Open, fast, supported nearly everywhere. |
| Lossless in an Apple-only library | ALAC | Same idea as FLAC; Apple’s ecosystem prefers it. |
| Lossless with a lossy-plus-correction hybrid mode | WavPack | Niche; the hybrid mode is its selling point. |
| Surround on Blu-ray, TVs and receivers | Dolby (AC-3, E-AC-3, TrueHD) | Keep the original track when remuxing; re-encoding costs quality. |
| Object-based or immersive audio | Spatial audio | Atmos, MPEG-H, IAMF and so on are metadata systems on top of codecs. |
Vorbis and Speex are both superseded by Opus. Keep them only for existing files or devices that require them.
Comparison
Section titled “Comparison”| Codec | Type | Typical channels | Containers | Encoders |
|---|---|---|---|---|
| Opus | Lossy | Mono and stereo; multichannel via channel mapping families | Ogg, WebM, Matroska, MP4 | libopus (opusenc, FFmpeg libopus) |
| AAC | Lossy | Up to 5.1 and 7.1 in common profiles | MP4/M4A, MPEG-TS, ADTS, Matroska | Apple, Fraunhofer FDK, FFmpeg native |
| MP3 | Lossy | Mono and stereo only | Raw MP3, Matroska, MP4 | LAME |
| Vorbis | Lossy | 1–255 | Ogg, WebM, Matroska | libvorbis |
| FLAC | Lossless | 1–8 | Native FLAC, Ogg, Matroska | flac, FFmpeg |
| ALAC | Lossless | 1–8 | MP4/M4A, MOV | Apple, FFmpeg |
| WavPack | Lossless or hybrid | Many (hundreds supported) | Native WavPack, Matroska | wavpack, FFmpeg |
| Speex | Lossy, speech only | Mono and stereo | Ogg | speexenc |
FLAC stores 4–32-bit integer PCM. ALAC stores 16, 20, 24 and 32-bit integer PCM, though FFmpeg’s encoder writes only 16 and 24-bit. WavPack also stores 32-bit float and DSD.
Browser support
Section titled “Browser support”MP3, AAC in MP4 and FLAC play in every current browser. Opus and Vorbis in Ogg or WebM play in Chrome, Edge and Firefox, and Safari 18.4 added Ogg Opus and Vorbis on recent Apple operating systems. ALAC is effectively Safari-only, AC-3 and E-AC-3 play only where the operating system supplies a licensed decoder (Apple platforms, some Windows and TV browsers), and Speex and WavPack need an application-supplied decoder. The image and audio support guide has the detection code.
Channels versus spatial audio
Section titled “Channels versus spatial audio”More channels is not the same as spatial audio. Immersive systems describe objects, scenes and speaker layouts in metadata that a renderer interprets; the actual samples are carried by an ordinary codec. See spatial and immersive audio.