What is it?
Opus is a completely free audio format that was recently approved for publication as a standards-track RFC by the IETF. Opus files can play in Firefox Beta today.
Opus offers these benefits:
- Better compression than MP3, Ogg, or AAC formats
- Good for both music and speech
- Dynamically adjustable bitrate, audio bandwidth, and coding delay
- Support for both interactive and pre-recorded applications
Why Should I care?
First, Opus is free software, free for everyone, for any purpose. It’s also an IETF standard. Both the encoder and decoder are free, including the fixed-point implementation (for mobile devices). These aren’t toy demos. They’re the best we could make, ready for serious use.
We think Opus is an incredible new format for web audio. We’re working hard to convince other browsers to adopt it, to break the logjam over a common <audio> format.
The codec is a collaboration between members of the IETF Internet Wideband Audio Codec working group, including Mozilla, Microsoft, Xiph.Org, Broadcom, Octasic, and others.
We designed it for high-quality, interactive audio (VoIP, teleconference) and will use it in the upcoming WebRTC standard. Opus is also best-in-class for live streaming and static file playback. In fact, it is the first audio codec to be well-suited for both interactive and non-interactive applications.
Opus is as good or better than basically all existing lossy audio codecs, when competing against them in their sweet spots, including:
- General audio codecs (high latency, high quality)
- AAC (all flavors)
- Speech codecs (low latency, low quality)
- AMR-WB (G.722.2)
- G.722.1 (all variants)
And none of those codecs have the versatility to support all the use cases that Opus does.
Listening tests show that:
- At 64 kbps, Opus sounds better than both HE-AAC and Vorbis.
- A 64 kbps Opus file sounds as good as a 96 kbps MP3 file.
That’s a lot of bandwidth saved. It’s also much more flexible.
Opus can stream:
- narrowband speech at bitrates as low as 6 kbps
- fullband music at rates of 256 kbps per channel
At the higher of those rates, it is perceptually lossless. It also scales between these two extremes dynamically, depending on the network bandwidth available.
Opus compresses speech especially well. Those same test results (slide 19) show that for fullband mono speech, Opus is almost transparent at 32 kbps. For audio books and podcasts, it’s a real win.
Opus is also great for short files (like game sound effects) and startup latency, because unlike Vorbis, it doesn’t require several kilobytes of codebooks at the start of each file. This makes streaming easier, too, since the server doesn’t have to keep extra data around to send to clients who join mid-stream. Instead, it can send them a tiny, generic header constructed on the fly.
How do I use it in a web page?
Opus works with the <audio> element just like any other audio format.
<audio src="ehren-paper_lights-64.opus" controls>
This code in a web page displays an embedded player like this:
Paper Lights by Ehren Starks
(Requires Firefox 15 or later)
For now, the best way to create Opus files is to use the
opusenc tool. You can get source code, along with Mac and Windows binaries, from:
While Firefox 15 is the first browser with native Opus support, playback is coming to gstreamer, libavcodec, foobar2000, and other media players.
Live streaming applications benefit greatly from Opus’s flexibility. You don’t have to decide up front whether you want low bandwidth or high quality, to optimize for voice or music, etc. Streaming servers can adapt the encoding as conditions change—without breaking the stream to the player.
Pre-encoded files can stream from a normal web server. The popular Icecast streaming media server can relay a single, live Opus stream, generated on the fly, to thousands of connected listeners. Opus is supported by the current development version of Icecast.