Opus audio codec: choose settings for speech, music, transport, and storage
Opus compresses both speech and music, but its codec, transport, and container are separate choices. Learn how SILK/CELT modes, frame duration, RTP timing, and Ogg pre-skip affect setup and playback.
Opus audio codec: choose settings for speech, music, transport, and storage
Opus is a lossy audio codec that compresses both speech and music, with adjustable bandwidth, bitrate, and frame duration for real-time communication and streaming. It uses SILK for speech, CELT for music and low-delay use, and a hybrid mode in some conditions. The codec itself is neither a transport protocol nor a file container, so RTP for live communication and Ogg Opus for storage also require the right packetization or container timing rules.
How Opus encodes audio
RFC 6716 specifies the Opus bitstream and decoder behavior. Its three broad coding modes are:
**SILK** is suited to speech at lower bitrates and covers narrowband through wideband.
**Hybrid** combines SILK for lower frequencies with CELT for higher frequencies, for super-wideband or fullband speech.
**CELT** can serve low-delay speech transmission as well as music.
An encoder can choose or switch modes, channel count, and audio bandwidth based on content and target bitrate. This flexibility helps across network and content types, but “encoded with Opus” alone does not determine quality or delay. Consider the input, encoder settings and implementation, bitrate, frame duration, packetization, and network together.
RFC 6716 defines frame durations of 2.5, 5, 10, 20, 40, and 60 ms. Short frames can reduce packetization wait but may increase per-packet header overhead. Bundling multiple frames in one packet can reduce transport overhead, while increasing the audio interval affected by one lost packet and potentially adding wait time. Algorithmic codec delay (about 5 to 65.2 ms depending on mode) is not the same as end-to-end call latency; capture, buffering, packet transport, jitter buffering, and playback add more.
Separate codec, transport, and container
A codec turns PCM audio into a compressed bitstream and reconstructs it. RTP carries that bitstream in real-time packets with timing and sequence information. RFC 7587 uses a 48 kHz RTP clock for all Opus modes and input sample rates. This is the RTP timestamp rule, not a statement about the original PCM sample rate or the decoder output rate used for playback.
Ogg Opus places Opus in a container used for files and streaming (RFC 7845). The Ogg Opus header includes channel count, the number of pre-skip samples to discard at decoder startup, and information about the original encoder input rate. The original-rate field is not the playback rate, and lossy coding does not preserve the original sampling rate exactly. Ignoring pre-skip can expose encoder delay at the start or misalign duration and synchronization.
Choose settings for the use case
**Live conversation:** Set acceptable end-to-end latency and network-loss conditions first. Short frames, short packets, or low bitrate are not automatically best. Evaluate bandwidth, quality, loss recovery, and CPU use on the actual connection.
**Music streaming:** Consider stereo, target quality, bitrate, and playback environment, and check the encoder’s audio/CELT behavior. At the same bitrate, results vary with content and encoder.
**File distribution:** Check Ogg Opus support in target players and preserve metadata. If archiving or later editing matters, do not keep only a lossy encode as the master.
**RTP integration:** Follow RFC 7587’s payload format and SDP parameters. Review frame duration, total audio time per packet, receiver jitter buffering, and packet-loss handling.
Troubleshoot playback and timing
If playback is cut off at the start or synchronization is wrong, check that the Ogg Opus parser handles pre-skip and granule positions.
If RTP timing drifts, distinguish the PCM input rate, the 48 kHz RTP clock, and timestamp increments.
If speech endings are cut off or latency is high, compare shorter frame or packet durations, while measuring packet loss and overhead too.
If quality differs from expectation, record encoder/decoder implementation, channels, bitrate, bandwidth mode, and source rather than comparing only the codec name.
For a fair comparison, report codec implementation and version, input and sample rate, channel count, bitrate mode, frame and packet duration, container or transport, loss/jitter conditions, and measurement method. Opus is flexible when the format and tools are chosen carefully, but it does not guarantee the best quality or lowest delay for every audio condition.
References
[RFC 6716: Definition of the Opus Audio Codec](https://www.rfc-editor.org/rfc/rfc6716.html)
[RFC 7587: RTP Payload Format for Opus](https://www.rfc-editor.org/rfc/rfc7587.html)
[RFC 7845: Ogg Encapsulation for Opus](https://www.rfc-editor.org/rfc/rfc7845.html)