Skip to content
systemcoding.dev
Media

AAC vs Opus for Streaming and Voice Applications

Compare the AAC and Opus audio codecs for streaming, voice calls and music: delay, bitrate range, container and device support, licensing and FFmpeg commands.

6 min read
Summarize in AI
Flat illustration of two options weighed side by side, with the FFmpeg, GNU and C++ logos.

Two audio codecs cover most new projects: AAC, the codec of MP4 files, Apple devices and broadcast, and Opus, the codec of WebRTC calls, Discord, many game voice systems and a lot of web audio. Both give good sound at modest bitrates, and both are available in FFmpeg and in browsers. They are not interchangeable, because they were designed for different jobs. AAC was built to compress music and television sound efficiently for storage and broadcast. Opus was built to serve both interactive speech with very low delay and music in one codec. This post compares them on what decides a project: delay, quality at a given bitrate, bitrate range, container and platform support, and licensing, then ends with a decision table and the FFmpeg commands for each. Versions: FFmpeg 7.1, libopus 1.5 and the native FFmpeg AAC encoder.

What each codec is

AAC (Advanced Audio Coding) is defined in MPEG-4 Part 3 and MPEG-2 Part 7. It has several profiles. AAC-LC (Low Complexity) is the common one and what people usually mean by "AAC". HE-AAC (High Efficiency) adds spectral band replication to hold quality at low bitrates, and HE-AAC v2 adds parametric stereo for the very lowest. There are also low-delay variants, AAC-LD and AAC-ELD, used in some telephony and conferencing systems, with lower support.

Opus is an open codec standardised by the IETF as RFC 6716, with a further RFC 7845 for storing it in Ogg files and RFC 7587 for sending it over RTP. It combines two technologies, SILK for speech and CELT for music, and switches or mixes them according to the content and the bitrate. It is a single codec that scales from narrowband speech at a few kilobits per second to full-band stereo music at high bitrates, with a bitrate range of 6 to 510 kbit/s per the standard.

Delay: the biggest difference

For a voice call, delay matters more than anything else, since a delay of more than a few hundred milliseconds in total makes conversation awkward. A codec's contribution is its algorithmic delay: the frame it must collect before it can encode, plus look-ahead.

Opus supports frame sizes from 2.5 ms to 60 ms, with 20 ms the usual default. Its algorithmic delay can be as low as 5 ms with the smallest frames and the low-delay application mode, as stated in RFC 6716. This is why WebRTC chose it.

AAC-LC uses a frame of 1024 samples, which is about 21 ms at 48 kHz, and the encoder and decoder together add delay of that order plus more for overlap, typically cited in the tens of milliseconds. That is fine for streaming a concert and awkward for a call. The low-delay AAC variants reduce it, but device support for them is narrow.

For streaming a recorded or live broadcast where a few seconds of buffering is already normal, the codec's delay is not an issue.

Quality and bitrate

Neither codec has one quality figure, since it depends on the content, the encoder and the settings. Two statements can be made safely from the specifications and public listening tests, and they are worth checking with your own material:

  • At low bitrates, such as 24 to 64 kbit/s for stereo, Opus holds quality well, and HE-AAC is the AAC family's answer in that range.

  • At typical music bitrates, such as 128 to 192 kbit/s stereo, both are good enough that most listeners struggle to tell them from the source, and the choice should be made on other grounds.

For speech, Opus's SILK mode is tuned for voice and works at very low bitrates; AAC-LC is not a voice codec, and its speech efficiency at low rates is weaker.

Test with your own audio. Encode a sample of your content at each candidate bitrate and listen, since the result depends on the material more than on published comparisons.

Containers and platforms

Where a codec can live decides whether you can deliver it at all.

AACOpus
MP4 / M4Ayes, the native fityes, defined in the Opus-in-ISOBMFF spec; support is narrower than AAC
WebM / MKVin MKV; not allowed in WebMyes, WebM's default audio
Oggnot typicalyes, .opus files
MPEG-TS (HLS)yes, in ADTS or LATM framingpossible, with limited player support
RTP / WebRTCAAC possible; not a WebRTC baselinemandatory-to-implement in WebRTC
Browsersbroad <audio> and MSE supportbroad in modern browsers, strong in WebM and Ogg
Apple devicesnative everywheresupported in recent Apple operating systems in CAF and some containers
TVs and set-top boxesnear universalpatchy

The reliable rules are these. For files that must play on old or unknown devices, AAC in MP4 is the safest choice. For WebRTC, Opus is the default and often the only choice. For WebM output, Opus or Vorbis is required. For HLS to the widest range of players, AAC remains the standard. Check the current state on MDN's media format guide and caniuse before relying on any row, since support changes between releases.

Licensing

AAC is covered by patents licensed through a patent pool, and implementations in products pay royalties or rely on the platform's licensed decoder. FFmpeg's native AAC encoder and decoder are part of the LGPL code base, but that is a copyright statement and does not remove the patent question for a commercial product. Opus is royalty-free: its contributors have granted licences to their relevant patents under the terms of the IETF standard, and the reference implementation libopus has a permissive BSD licence. For a small project this difference rarely matters, and for a product shipped on millions of devices it can.

Commands for each

Encode a file to AAC-LC in an MP4 container with FFmpeg's native encoder:

Shell
ffmpeg -i input.wav -c:a aac -b:a 128k output.m4a

Encode to Opus in an Ogg file. The -application option chooses the mode: audio for music, voip for speech, lowdelay for the smallest delay.

Shell
ffmpeg -i input.wav -c:a libopus -b:a 96k -application audio output.opus

For a voice recording at a low bitrate, mono Opus is enough:

Shell
ffmpeg -i call.wav -ac 1 -c:a libopus -b:a 24k -application voip call.opus

Compare what you made with ffprobe:

Shell
ffprobe -hide_banner -show_entries stream=codec_name,sample_rate,channels,bit_rate -of default=nw=1 output.m4a
Text
codec_name=aac
sample_rate=44100
channels=2
bit_rate=128006

The exact bitrate varies slightly from the requested value because of how the encoder fills frames; the value is an example. Opus files always report a 48000 sample rate in the stream header, even if the input was 44.1 kHz, since Opus works internally at 48 kHz and the original rate is only metadata.

How to choose

If your audio is for real-time voice or interactive audio, choose Opus: it is the WebRTC standard, supports very small frames and has built-in packet-loss concealment and optional forward error correction. If you deliver on-demand or live video through HLS to the widest set of devices, choose AAC in MP4 or MPEG-TS, because every device decodes it. If you deliver web audio and WebM video and control the player, Opus gives better quality at low bitrates without royalties. If you archive music and want maximum compatibility, AAC in M4A or a lossless format such as FLAC are the usual picks, and Opus is excellent when file size matters and your players support it. If your target includes old TVs or hardware without Opus decoders, use AAC.

Many services keep both: AAC for compatibility and Opus where the client supports it, chosen per device at delivery time.

Share

Keep reading

Flat illustration of user space above the system call boundary, the kernel and the hardware, with the C, FreeBSD and Linux logos.
Systems Programming

How argc and argv Reach main in a C Program

The kernel copies argc and argv onto the new process's stack on execve, then startup code hands them to main. See the layout and measure it with a program.

6 min read

Get new posts by email

We send one email when a new post is published. No spam.

Unsubscribe in one click. No spam, ever.