Opus Recommended Settings: Difference between revisions

From XiphWiki
Jump to navigation Jump to search
(→‎Bandwidth Transition Thresholds: give rough guestimates instead of code thresholds)
Line 70: Line 70:


== Bandwidth Transition Thresholds ==
== Bandwidth Transition Thresholds ==
The following table shows where Opus decides to switch between its different '''[https://tools.ietf.org/html/rfc6716#section-2 audio frequency bandwidths]'''. This could be useful if you are encoding audio that has already been bandpassed, or should go through a bandpass filter (e.g. VoIP speech).
The following table shows rough bitrates that you might want to use to encode audio that has '''[https://tools.ietf.org/html/rfc6716#section-2 limited frequency bandwidths]'''.
 
This could be useful if your audio has already been bandpassed, or should go through a bandpass filter (e.g. VoIP speech).
The table was copied from the '''[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L121 opus_encoder.c]''' source file.


{| class="wikitable" style="text-align:center"
{| class="wikitable" style="text-align:center"
Line 80: Line 79:
!colspan="2"|Stereo
!colspan="2"|Stereo
|-
|-
! Voice
!Voice
! Music
!Music
! Voice
!Voice
! Music
!Music
|-
|-
!<abbr title="NarrowBand (3-4000&nbsp;Hz)">NB</abbr> ↔ <abbr title="MediumBand (3-6000&nbsp;Hz)">MB</abbr>
!<abbr title="(3-4000&nbsp;Hz)">NarrowBand</abbr>
|10 ± 1
|12
|10 ± 1
|15
|10 ± 1
|?
|10 ± 1
|?
|-
|-
!MB ↔ <abbr title="WideBand (3-8000&nbsp;Hz)">WB</abbr>
!<abbr title="(3-6000&nbsp;Hz)">MediumBand</abbr>
|11 ± 1
|15
|11 ± 1
|18-22
|11 ± 1
|?
|11 ± 1
|?
|-
|-
!WB ↔ <abbr title="SuperWideBand (3-12000&nbsp;Hz))">SWB</abbr>
!<abbr title="(3-8000&nbsp;Hz)">WideBand</abbr>
|13.5 ± 1
|16-20
|13.5 ± 1
|22-28
|13.5 ± 1
|?
|13.5 ± 1
|?
|-
|-
!SWB ↔ <abbr title="FullBand (3-20000&nbsp;Hz)">FB</abbr>
!<abbr title="(3-12000&nbsp;Hz)">SuperWideBand</abbr>
|14 ± 2
|24-28
|14 ± 2
|28-32
|14 ± 2
|?
|14 ± 2
|?
|-
!<abbr title="(3-20000&nbsp;Hz)">FullBand</abbr>
|28-40
|32-64
|32-64
|64-128
|}
|}
The details of Opus' bandpass thresholds can be found in the '''[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L121 opus_encoder.c]''' source file.


The '''[http://wiki.hydrogenaud.io/index.php?title=Opus HydrogenAudio]''' wiki also has some great information on Opus and its usage.
The '''[http://wiki.hydrogenaud.io/index.php?title=Opus HydrogenAudio]''' wiki also has some great information on Opus and its usage.

Revision as of 01:36, 4 August 2016

Depending on what kinds of sounds you want to encode with Opus, you should use different bitrate (quality) settings.

The settings in the table below are meant to start you off with a decent tradeoff between good quality and small filesize (or bitrate usage, if you're streaming).

You should test the suggested bitrate by actually listening to your encoded audio and then tweaking the bitrate:

  • down if you think the quality is good, but the filesize (or bitrate) is too big
  • up if you think the quality is bad, and you can afford having bigger files (or bitrate)
Use Case Channels Bitrate (Kb/s) Notes
Ham radio 1 (mono) use Codec 2 Opus only supports bitrates down to 6 Kb/s. Codec 2 handles speech from 0.7 to 3.2 Kb/s.
VoIP 1 10-24 10 Kb/s will deliver narrowband most of the time, 24 Kb/s should give fullband.
More details in the relevant table further down this page.
Audiobooks / Podcasts 1 24 bitrates from here on up tend to deliver fullband audio.
2 (stereo) 32
Music Streaming / Radio 2 64-96 Opus has better quality than MP3, AAC and Vorbis at these rates.
(test results here and here)
Music Storage 2 96-128 Opus at 128 KB/s (VBR) is pretty much transparent
6 (5.1 surround) 128-256 for surround sound, Opus uses surround-sound bitrate allocation
8 (7.1 surround) 256-450
Music Archiving any use FLAC if you are archiving audio, use a lossless audio format to prevent generation loss

Technical Details

For the more technical Opus users, here are some details to help you fine-tune your decision on which bitrate best fits your needs.

Mono or Stereo

Opus tends to start downmixing stereo inputs to mono from roughly 24 Kb/s and lower. You can check the details in the opus_encoder.c source file.

You can force downmixing at any bitrate by using the following command-line parameters:

--downmix-mono - downmixes input channels to mono

--downmix-stereo - downmixes input channels to stereo (if there are more than 2 e.g. if your input is surround sound)

Bandwidth Transition Thresholds

The following table shows rough bitrates that you might want to use to encode audio that has limited frequency bandwidths. This could be useful if your audio has already been bandpassed, or should go through a bandpass filter (e.g. VoIP speech).

(bitrates in Kb/s) Mono Stereo
Voice Music Voice Music
NarrowBand 12 15 ? ?
MediumBand 15 18-22 ? ?
WideBand 16-20 22-28 ? ?
SuperWideBand 24-28 28-32 ? ?
FullBand 28-40 32-64 32-64 64-128

The details of Opus' bandpass thresholds can be found in the opus_encoder.c source file.

The HydrogenAudio wiki also has some great information on Opus and its usage.

Framesize Tweaking

Opus uses a 20 ms frame size by default, as it gives a decent mix of low latency and good quality.