Why a single codec for both?

Opus combines SILK (Skype's speech codec) for low frequencies and CELT (transform codec) for high frequencies. A scheduler inside the encoder picks which one to use per frame — speech-heavy regions use SILK, music regions use CELT, complex content uses both in a hybrid.

Advertisement

Frame sizes vs latency

Frame sizeLatencyUse case
2.5 msUltra-lowLive music sync
5 msVery lowGame voice
10 msLowWebRTC default
20 msStandardVoIP
40-60 msHigherStorage/streaming
Advertisement

Encoder config for voice

OpusEncoder *enc = opus_encoder_create(48000, 1, OPUS_APPLICATION_VOIP, &err);
opus_encoder_ctl(enc, OPUS_SET_BITRATE(24000));
opus_encoder_ctl(enc, OPUS_SET_VBR(1));               // variable bitrate
opus_encoder_ctl(enc, OPUS_SET_DTX(1));               // discontinuous tx in silence
opus_encoder_ctl(enc, OPUS_SET_PACKET_LOSS_PERC(10)); // robustness for lossy nets
opus_encoder_ctl(enc, OPUS_SET_FEC(1));               // forward error correction