Codec

Opus Codec: What It Is, How It Works, and When to Use It

13 min read
Opus codec audio encoding represented by an audio mixing console
Reading Time: 9 minutes

Every time you hop on a Discord call, join a Google Meet, or talk to someone through a browser-based video app, there’s a good chance the audio is encoded with the Opus codec. It powers most real-time voice on the internet, yet most developers never think about it until they hit a compatibility wall or a quality complaint.

The Opus codec is unusual because it handles two jobs that older formats kept separate: crystal-clear music and low-latency speech, both inside a single encoder. It ranges from 6 kbps phone-quality voice up to 510 kbps stereo music, switches modes on the fly, and ships royalty-free. That combination is why the IETF made it a mandatory codec for WebRTC.

This guide explains what the Opus codec is, how its SILK and CELT engines work together, how its bitrate and latency settings behave, how it compares to AAC and MP3, and how to actually use it in your own streaming or communication app.

What Is the Opus Codec?

The Opus codec is a free, open, lossy audio codec standardized by the Internet Engineering Task Force (IETF) in 2012 as RFC 6716. It was designed for interactive, real-time audio over the internet — voice calls, conferencing, game chat, and live streaming — where low delay matters as much as sound quality.

What sets Opus apart is its range. A single Opus encoder can compress narrowband telephone speech at 6 kbps and full-resolution stereo music at 510 kbps, adjusting itself continuously in between. It supports sample rates from 8 kHz up to 48 kHz, mono and stereo (and up to 255 channels), and frame sizes from 2.5 ms to 60 ms.

Opus was built collaboratively. It merges two earlier projects: SILK, the speech codec developed by Skype, and CELT, the music-focused codec from the Xiph.Org Foundation. The IETF codec working group combined them into one standard so that a single format could replace the patchwork of speech and music codecs developers used to juggle.

Here’s a quick reference of its core specifications:

Attribute Opus specification
Standard RFC 6716 (2012), updated by RFC 8251
Type Lossy audio codec
Bitrate range 6 kbps to 510 kbps
Sample rates 8, 12, 16, 24, 48 kHz
Frame sizes 2.5 ms to 60 ms
Default latency ~26.5 ms (down to 5 ms)
Channels Mono, stereo, up to 255
Licensing Royalty-free, BSD-licensed reference
Common containers Ogg (.opus), WebM, MP4, Matroska, CAF

SILK vs CELT vs Hybrid: The Three Operating Modes

To understand the Opus codec, you need to understand that it isn’t really one algorithm — it’s three operating modes, and it can switch between them packet by packet without any audible seam.

SILK mode (speech)

SILK is a linear predictive coding (LPC) algorithm, the same family of techniques used in most telephone and VoIP codecs. It models the human vocal tract, which makes it efficient at compressing voice down to very low bitrates. Opus uses SILK for speech-dominant content at narrowband through wideband sample rates (up to 8 kHz audio bandwidth).

CELT mode (music)

CELT (Constrained Energy Lapped Transform) is a Modified Discrete Cosine Transform (MDCT) codec, closer in spirit to AAC or Vorbis. It excels at general audio — music, ambient sound, anything with rich frequency content. CELT also runs at very short frame sizes, which is what gives Opus its low-latency capability.

Hybrid mode

For super-wideband and fullband content, Opus runs both at once: SILK handles the lower frequencies while CELT covers the high end. This hybrid mode is what lets a single stream carry a clear voice and background music together without choosing one codec over the other.

Mode Engine Best for Audio bandwidth
SILK LPC Speech, low bitrate Up to 8 kHz
Hybrid SILK + CELT Voice + music, conferencing Up to 12 kHz
CELT MDCT Music, general audio Up to 20 kHz

The encoder picks the mode based on the target bitrate, sample rate, and content, and the decoder follows along automatically. As a developer, you usually just set a bitrate and an application type, and Opus handles the rest.

How the Opus Codec Works

When audio flows into an Opus encoder, it moves through a sequence of steps that compress it for transport and then reconstruct it on the other side.

  1. Sampling and framing. Incoming audio is divided into frames of 2.5 to 60 ms. A 20 ms frame is the default and the sweet spot for most real-time use.
  2. Mode selection. The encoder analyzes the content and target bitrate, then chooses SILK, CELT, or hybrid mode for that frame.
  3. Compression. SILK applies linear prediction for speech; CELT applies the MDCT transform for music. Bits are allocated where they matter most perceptually.
  4. Packetization. Each compressed frame becomes a packet, ready to send over the network — typically over RTP for real-time transport.
  5. Forward error correction. Opus can embed a low-bitrate copy of the previous frame inside the current packet, so a single lost packet can be reconstructed without retransmission.
  6. Decoding. The receiver decompresses each packet, applies packet loss concealment when data is missing, and outputs the audio.

That forward error correction (FEC) and packet loss concealment is a big reason Opus sounds stable on bad networks. Instead of dropping out when packets are lost, it fills the gaps intelligently — important for any app where audio rides the same unpredictable connection as your video.

Opus Bitrate and Quality

Because the Opus codec spans such a wide bitrate range, picking the right setting matters more than with fixed-rate formats. Higher bitrates mean better quality but more bandwidth. Here are practical bitrate bands and what each is good for:

  • 6–12 kbps: Narrowband speech, similar to a landline phone call. Usable for low-bandwidth voice.
  • 16–24 kbps: Wideband speech, comparable to HD voice calls. Clear and natural for conversation.
  • 32–64 kbps: Fullband speech and acceptable music. This is where most VoIP and conferencing apps operate.
  • 64–96 kbps: Good stereo music quality, fine for podcasts and casual listening.
  • 96–128 kbps: High-quality stereo music, approaching transparency for most listeners.
  • 128–256 kbps: Near-transparent to transparent music for critical listening.

In public listening tests, Opus consistently scores higher than AAC, MP3, and Vorbis at the same bitrate, especially in the 32–96 kbps range where the quality gap is widest. The practical takeaway: you can often cut your audio bitrate by 20–30% versus AAC and keep the same perceived quality, which lowers your delivery and storage costs.

If you’re tuning audio inside a video pipeline, the same bitrate trade-offs apply — spend bits where listeners notice, save them where they don’t.

Opus Latency: Why It Wins for Real-Time Audio

Latency is where the Opus codec separates itself from music-only formats like MP3 and AAC. With its default 20 ms frame size, Opus adds about 26.5 ms of algorithmic delay. In restricted low-delay mode with the shortest frames, that drops to around 5 ms.

For comparison, AAC’s algorithmic delay typically runs over 100 ms, which is fine for streaming a recorded file but unacceptable for a live conversation where people start talking over each other. Anything above roughly 150–200 ms of round-trip delay makes natural back-and-forth feel awkward.

That low codec delay is one piece of the broader video latency budget. When you’re building anything interactive — calls, auctions, live shopping, two-way events — every millisecond in the encoder counts toward the total. Opus keeps its slice of that budget small, which is exactly why it pairs so well with ultra low latency streaming architectures.

Opus Codec vs Other Audio Codecs

How does Opus stack up against the codecs you’re most likely to compare it with? Here’s a side-by-side look at the formats developers evaluate for streaming and communication.

Codec Type Latency Bitrate range Royalty-free Best for
Opus Speech + music ~5–26.5 ms 6–510 kbps Yes Real-time voice, WebRTC, streaming
AAC Music 100+ ms 8–320 kbps No (licensed) VOD, HLS, broad device support
MP3 Music 100+ ms 32–320 kbps Expired patents Legacy compatibility
Vorbis Music ~100 ms 45–500 kbps Yes Older open-source media
Speex Speech Low 2–44 kbps Yes Deprecated; replaced by Opus

A few takeaways:

  • Opus vs AAC: Opus wins on latency, licensing, and low-bitrate quality. AAC still wins on universal hardware support, which is why HLS and most on-demand video stick with it.
  • Opus vs MP3: Opus beats MP3 on quality at every bitrate and adds real-time features MP3 never had. MP3’s only edge is that it plays on almost anything.
  • Opus vs Speex/Vorbis: Opus was designed to replace both. The Xiph.Org Foundation that maintains Vorbis now recommends Opus for nearly all new projects.

If you’re choosing audio for a video codec pipeline, the rule of thumb is simple: Opus for anything interactive or WebRTC-based, AAC for on-demand video that needs to play on TVs and older phones.

Where the Opus Codec Is Used

Opus isn’t a niche format — it’s behind a huge share of the audio you stream every day. Its main use cases include:

  • WebRTC: Opus is a mandatory codec in the WebRTC spec, so every compliant browser supports it. Any browser-based call or WebRTC live streaming app uses it by default.
  • VoIP and messaging: Discord, WhatsApp, Signal, and Telegram use Opus for voice. Its packet loss resilience keeps calls intelligible on weak mobile networks.
  • Video conferencing: Google Meet, Zoom, and similar tools rely on Opus for audio, which is why a video conferencing API almost always lists Opus support.
  • Streaming platforms: YouTube serves Opus audio for many videos, and SoundCloud uses it for playback. It’s common in WebM and MP4 containers.
  • Game audio and in-game chat: The low latency and small frame sizes make Opus a natural fit for real-time multiplayer voice.

This range is what makes Opus genuinely general-purpose. The same codec that carries a 12 kbps voice note can deliver a stereo music livestream, which simplifies your stack — you don’t need separate speech and music codecs.

Browser, Device, and Container Support

Opus support is broad on the software side and improving on hardware:

  • Browsers: Chrome, Firefox, Edge, and Opera have supported Opus for years. Safari added support in version 11+, and full WebM/Opus playback landed around macOS Big Sur and iOS 17.
  • Operating systems: Android has decoded Opus since 5.0 (Lollipop). Windows 10 and modern macOS handle it natively or through standard media frameworks.
  • Containers: Opus most often lives in an Ogg container with the .opus extension, but it’s also carried inside WebM, MP4/ISOBMFF, Matroska (MKV), MPEG-TS, and Core Audio Format (CAF).
  • Hardware: Many Bluetooth devices, VoIP phones, and embedded systems now include Opus decoders, though hardware support still lags AAC on older consumer electronics.

The main gap to watch is legacy hardware — set-top boxes, older smart TVs, and aging phones may not decode Opus. For those targets, you’ll still want an AAC fallback, which is one reason HLS delivery to TVs typically uses AAC rather than Opus.

Before moving from theory to practice, the key thing to remember is that Opus gives you elite real-time audio with minimal licensing friction — but only if your delivery infrastructure encodes, packages, and serves it correctly across every device your users carry.

How to Use the Opus Codec

Getting Opus into your application usually happens at one of two layers: the command line for file and stream encoding, or the WebRTC layer for real-time browser audio.

Encode audio to Opus with FFmpeg

The most common way to create Opus audio is with FFmpeg using the libopus encoder. To convert a file to a 96 kbps Opus stream in an Ogg container:

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

For voice-optimized encoding, tell Opus the application type and frame duration:

ffmpeg -i voice.wav -c:a libopus -b:a 24k \
  -application voip -frame_duration 20 voice.opus

The -application flag accepts voip, audio, or lowdelay, which nudges the encoder toward speech, general audio, or minimum-latency behavior.

Use Opus in WebRTC

In WebRTC you rarely encode Opus by hand — the browser does it. But you can prefer or tune it by editing the Session Description Protocol (SDP) offer. To request stereo and a target bitrate, you set fmtp parameters on the Opus payload:

a=fmtp:111 minptime=10;useinbandfec=1;stereo=1;maxaveragebitrate=128000

Here useinbandfec=1 turns on forward error correction, and maxaveragebitrate caps the rate. Browsers negotiate Opus automatically, so most of your work is choosing whether to favor it and how to configure FEC and bitrate for your network conditions. If you’re standing up the signaling and media path yourself, you’ll also need a WebRTC server to route those streams.

Let your streaming infrastructure handle it

Encoding and packaging audio across every codec, container, and device is a lot to maintain. This is where a managed platform helps. LiveAPI handles video encoding and packaging for you, including audio-only streams when you don’t need video at all. You send your source, and LiveAPI transcodes and delivers it with adaptive bitrate output over multiple CDNs — so you focus on your app instead of codec plumbing.

For interactive use cases, Opus pairs naturally with the kind of low latency streaming LiveAPI is built for, while AAC handles broad on-demand delivery through HLS.

Is the Opus Codec Right for Your Project?

Use this quick checklist to decide whether Opus belongs in your stack:

  • You’re building real-time audio (calls, conferencing, game chat). Opus is the clear choice — low latency, FEC, and WebRTC support make it the default.
  • You’re shipping a browser or mobile app with two-way audio. Opus is already supported; lean into it.
  • You want lower bandwidth without losing quality. Opus saves 20–30% over AAC at comparable quality.
  • You’re delivering on-demand video to TVs and old devices. Stick with AAC for compatibility; Opus support is thinner on legacy hardware.
  • You need a royalty-free codec. Opus has no licensing fees, unlike AAC.

For most modern, interactive, browser-first applications, Opus is the right audio codec. For traditional VOD delivery to the broadest possible device set, AAC still wins on reach.

Opus Codec FAQ

Is Opus better than MP3?

Yes, in almost every measurable way. Opus delivers better audio quality than MP3 at the same bitrate, adds low-latency and packet-loss features MP3 lacks, and is fully royalty-free. MP3’s only advantage is near-universal playback on old devices.

Is the Opus codec royalty-free?

Yes. All known patents covering Opus are licensed under royalty-free terms, and the reference implementation uses a BSD license. You can ship Opus in commercial products without paying licensing fees, unlike AAC.

Can iPhones and Safari play Opus?

Modern ones can. Safari added Opus support in version 11, and full WebM/Opus playback works on iOS 17 and recent macOS versions. Older iPhones may need the audio served in a supported container or transcoded to AAC.

What’s the difference between Opus and AAC?

Opus offers far lower latency (~5–26.5 ms vs 100+ ms), is royalty-free, and beats AAC at low bitrates. AAC has wider hardware support and is the standard audio codec for HLS and on-demand video. Use Opus for real-time, AAC for broad VOD compatibility.

Does MP4 support the Opus codec?

Yes. Opus can be stored in MP4/ISOBMFF containers, though the more common containers are Ogg (.opus) and WebM. Some older players and TVs don’t decode Opus inside MP4, so test your target devices.

What bitrate should I use for Opus?

For speech, 16–24 kbps is clear; most VoIP and conferencing apps use 24–64 kbps. For music, 96–128 kbps is near-transparent for most listeners. Start there and adjust based on your bandwidth and quality needs.

Why is Opus mandatory in WebRTC?

The IETF required Opus (alongside G.711) because it covers the full range of real-time audio needs: low latency, wide bitrate flexibility, built-in forward error correction, and the ability to handle both speech and music. Every WebRTC-compliant browser ships an Opus encoder and decoder.

Bringing Opus Into Your Streaming Stack

The Opus codec earned its place as the default real-time audio format on the internet by doing what older codecs couldn’t: combining speech and music in one royalty-free encoder with latency low enough for live conversation. If you’re building anything interactive — calls, conferencing, game chat, or low-latency live events — Opus should be your starting point, with AAC as the fallback for legacy device reach.

The harder part is everything around the codec: transcoding source audio, packaging it for every device, adding adaptive bitrate, and delivering it reliably worldwide. That’s what LiveAPI takes off your plate. Its APIs handle encoding, audio-only and full video streaming, multiple CDNs, and HLS output so you can launch streaming features in days instead of months. Get started with LiveAPI and build your audio and video pipeline on infrastructure that’s ready for real-time.

Join 200,000+ satisfied streamers

Still on the fence? Take a sneak peek and see what you can do with Castr.

No Castr Branding

No Castr Branding

We do not include our branding on your videos.

No Commitment

No Commitment

No contracts. Cancel or change your plans anytime.

24/7 Support

24/7 Support

Highly skilled in-house engineers ready to help.

  • Check Free 7-day trial
  • CheckCancel anytime
  • CheckNo credit card required