Back to Blog
Audio Codecs Compared: AAC, MP3, Opus, and FLAC for Digital Media
Dilip NayakMay 14, 202615 min readAudio Engineering

Public media guide

Audio Codecs Compared: AAC, MP3, Opus, and FLAC for Digital Media

Comprehensive comparison of digital audio codecs: Advanced Audio Coding (AAC), MP3, Opus, and Free Lossless Audio Codec (FLAC). Analysis of psychoacoustic modeling, bitrates, latency, and frequency response.

While video captures visual attention, audio quality often determines whether audiences perceive a media experience as professional or amateur. In bandwidth-constrained environments, modern audio compression standards achieve extraordinary fidelity at a fraction of raw uncompressed PCM bitrates.

Audio codecs operate via psychoacoustics—the study of human auditory perception. By modeling simultaneous masking (loud sounds drowning out quiet tones in adjacent frequency bands) and absolute threshold of hearing curves, lossy codecs discard spectral data undetectable to human ears.

From the legacy ubiquity of MP3 to the studio dominance of AAC, the ultra-low-latency efficiency of Opus, and the bit-perfect preservation of FLAC, choosing the correct audio format is a foundational engineering decision.

This comparative guide evaluates codec algorithms, frequency response cutoffs, latency metrics, and optimal production parameters.

1. Psychoacoustic Masking & Quantization

Raw uncompressed 16-bit 44.1 kHz stereo audio requires 1,411 kbps of bandwidth. Lossy codecs compress this down to 96–160 kbps using Modified Discrete Cosine Transforms (MDCT) and psychoacoustic perceptual models.

  • Simultaneous Masking: A loud 1 kHz tone prevents the human ear from hearing a quieter 1.1 kHz tone. The codec calculates this masking threshold and quantizes the masked band with fewer bits.
  • Temporal Masking: Pre-masking and post-masking occur when loud transient sounds (like drum snare hits) temporarily deafen human perception for several milliseconds before and after the transient event.
  • Pre-echo Artifacts: Poorly tuned encoders suffer from pre-echo ringing prior to sudden percussive transients due to windowing limitations.

2. The Opus Architecture: Merging SILK and CELT

Standardized by the IETF in 2012 (RFC 6716), Opus unified two radically different compression algorithms into a single adaptive framework.

  • SILK Engine: Developed by Skype for human voice, utilizing linear predictive coding (LPC) to compress speech down to 8 kbps with stellar intelligibility.
  • CELT Engine: Developed by Xiph.Org for high-fidelity music, using MDCT transforms for full-bandwidth 20 Hz – 20 kHz acoustic reproduction.
  • Dynamic Adaptation: Opus can seamlessly switch between voice mode, music mode, and hybrid mode on a frame-by-frame basis without interrupting playback.

3. Lossless Compression with FLAC

Unlike lossy codecs that discard inaudible information, Free Lossless Audio Codec (FLAC) is mathematically lossless. It employs linear prediction to estimate incoming audio samples and encodes the prediction residuals using variable-length Golomb-Rice codes.

  • Bit-for-Bit Identity: Decoding a FLAC file yields the identical bit sequence of the original studio WAV or AIFF master.
  • Standard of Archival: FLAC is supported across all modern operating systems and web browsers for high-resolution 24-bit 96 kHz/192 kHz audio streams.

Format & Use Table

FeatureMP3 (MPEG-1 Layer III)AAC-LC (MPEG-4 Part 3)Opus (IETF RFC 6716)FLAC (Xiph.Org)
TypeLossyLossyLossy (Speech + Music)Mathematically Lossless
Standardized Year1993199720122001
Transparent Bitrate~256 - 320 kbps~128 - 192 kbps~96 - 128 kbpsN/A (Lossless ~700-1000 kbps)
Algorithmic Latency~100 - 200 ms~100 ms5 - 26.5 ms (WebRTC ideal)Low (~10-20 ms)
Frequency Cutoff (128k)Often 16 kHz low-passFull 20 kHz bandFull 20 kHz bandFull spectrum (up to 96+ kHz)
Licensing & PatentsPatents Expired (2017)Patent Pool (Via Licensing)100% Royalty-Free100% Royalty-Free Open Source

Step-by-Step Workflow

01

Inspect audio stream parameters: ffprobe -v error -select_streams a:0 -show_entries stream=codec_name,bit_rate,sample_rate,channels file.mp4

02

Encode pristine stereo Opus at 128 kbps: ffmpeg -i input.wav -c:a libopus -b:a 128k -vbr on output.opus

03

Encode broadcast-standard AAC: ffmpeg -i input.wav -c:a aac -b:a 192k output.m4a

04

Convert master to bit-perfect FLAC: ffmpeg -i input.wav -c:a flac -compression_level 8 output.flac

05

Extract audio without re-encoding: ffmpeg -i video.mp4 -vn -c:a copy extracted_audio.m4a

Frequently Asked Questions

Is 320 kbps MP3 as good as FLAC for everyday listening?

In double-blind ABX listening tests, over 99% of human listeners cannot reliably distinguish between a 320 kbps MP3 or 160 kbps Opus file and a lossless FLAC master on consumer hardware. FLAC is primarily critical for audio editing, archival, and repeated multi-generation transcoding.

Why is Opus preferred over AAC for Discord and WebRTC?

Opus features extremely low algorithmic latency (down to 5ms), exceptional packet loss concealment (PLC), and dynamic bandwidth scaling, making it far superior to AAC for interactive bidirectional voice.

Does AAC support 5.1 surround sound?

Yes. AAC natively supports up to 48 discrete audio channels, making it standard for 5.1 and 7.1 surround tracks in MP4 streaming.

#audio codecs#AAC#Opus#MP3#FLAC#psychoacoustics#lossless audio#audio engineering