Opus Recommended Settings: Difference between revisions

From XiphWiki
Jump to navigation Jump to search
m (expand VoIP range to cover narrowband bitrates, link to detailed table)
No edit summary
(19 intermediate revisions by 2 users not shown)
Line 1: Line 1:
Depending on what kinds of sounds you want to encode with Opus, you should use different bitrate (quality) settings.
= Recommended Bitrates =
Depending on the kind of audio you want to encode with Opus, you may want to 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).
The settings in the table below are meant to '''start you off''' with a decent tradeoff between '''good quality''' and '''small file size''' (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:
You should test the suggested bitrate by actually '''listening''' to your encoded audio and then:
* '''down''' if you think the quality is good, but the filesize (or bitrate) is too big
* tweaking the bitrate '''down''' if you think the quality is good, but the file size (or bitrate) is too big,
* '''up''' if you think the quality is bad, and you can afford having bigger files (or bitrate)
* tweaking the bitrate '''up''' if you think the quality is bad, and you can afford having bigger files (or a larger streaming bitrate).


{| class="wikitable" style="text-align:center"
{| class="wikitable" style="text-align:center"
Line 14: Line 15:
!Notes
!Notes
|-
|-
|Ham radio
|Low bandwidth HF/VHF digital radio
|1 (mono)
|1 (mono)
|use '''[http://www.rowetel.com/blog/?page_id=452 Codec 2]'''
|Use '''[http://www.rowetel.com/?page_id=452 Codec 2]'''
|Opus only supports bitrates down to 6 Kb/s.
|Opus only supports bitrates '''down to 6&nbsp;Kb/s'''.<br>
Codec 2 handles ultra low bitrate speech at '''0.7&nbsp;-&nbsp;3.2&nbsp;Kb/s'''.
|-
|-
|VoIP
|VoIP
|1
|1
|10-24
|10&nbsp;-&nbsp;24
|10&nbsp;Kb/s will deliver narrowband most of the time, 24&nbsp;Kb/s should give fullband.<br>More details in '''[[Opus_Recommended_Settings#Bandwidth_Transition_Thresholds|the relevant table]]''' further down this page.
|10&nbsp;Kb/s will deliver narrowband most of the time, 24&nbsp;Kb/s should give fullband.<br>
More details in '''[[Opus_Recommended_Settings#Bandwidth_Transition_Thresholds|the relevant table]]''' further down this page.
|-
|-
|rowspan="2"|Audiobooks / Podcasts
|rowspan="2"|Audiobooks / Podcasts
|1
|1
|24
|24
|bitrates from here on up tend to deliver fullband audio.
|Bitrates from here on up tend to deliver fullband audio.
|-
|-
|2 (stereo)
|2 (stereo)
Line 35: Line 38:
|Music Streaming / Radio
|Music Streaming / Radio
|2
|2
|64-92
|64&nbsp;-&nbsp;96
|
|Opus has better quality than MP3, AAC and [[Vorbis]] at these rates.<br>
(listening test results: '''[http://listening-tests.hydrogenaud.io/igorc/results.html 64&nbsp;Kb/s]''', '''[http://listening-test.coresv.net/results.htm 96&nbsp;Kb/s]''')
|-
|-
|rowspan="3"|Music Storage
|rowspan="3"|Music Storage
|2
|2
|92-128
|96&nbsp;-&nbsp;128
|Opus at 128&nbsp;KB/s (VBR) is pretty much '''[https://en.wikipedia.org/wiki/Transparency_(data_compression) transparent]'''
|Opus at 128&nbsp;KB/s (VBR) is pretty much '''[https://en.wikipedia.org/wiki/Transparency_(data_compression) transparent]'''.
|-
|-
|6 (5.1 surround)
|6 (5.1 surround)
|128-256
|128&nbsp;-&nbsp;256
|rowspan="2"|for surround sound, Opus uses '''[https://xiph.org/~xiphmont/demo/opus/demo3.shtml surround-sound bitrate allocation]'''
|rowspan="2"|For surround sound, Opus uses '''[https://xiph.org/~xiphmont/demo/opus/demo3.shtml surround-sound bitrate allocation]'''.
|-
|-
|8 (7.1 surround)
|8 (7.1 surround)
|256-450
|256&nbsp;-&nbsp;450
|-
|-
|Music Archiving
|Music Archiving
|any
|1&nbsp;-&nbsp;8
|use '''[[FLAC]]'''
|Use '''[[FLAC]]'''
|if you are archiving audio, use a '''[https://en.wikipedia.org/wiki/Audio_file_format#Lossless_compressed_audio_format lossless audio format]''' to prevent '''[https://en.wikipedia.org/wiki/Generation_loss generation loss]'''
|If you are archiving audio, use a '''[https://en.wikipedia.org/wiki/Audio_file_format#Lossless_compressed_audio_format lossless audio format]''' to prevent '''[https://en.wikipedia.org/wiki/Generation_loss generation loss]'''.
|}
|}


Line 60: Line 64:


== Mono or Stereo ==
== Mono or Stereo ==
Opus tends to start '''downmixing stereo inputs to mono''' from roughly '''30&nbsp;Kb/s and lower'''.
Opus tends to start '''downmixing stereo inputs to mono''' from roughly '''24&nbsp;Kb/s and lower'''.
You can check the details in the '''[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L139 opus_encoder.c]''' source file.
You can check the details in the '''[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L148 opus_encoder.c]''' source file.


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


<code>--downmix-mono</code> - downmixes input channels to mono
<code>--downmix-mono</code> - downmixes all input channels to mono


<code>--downmix-stereo</code> - downmixes input channels to stereo (if there are more than 2 e.g. if your input is surround sound)
<code>--downmix-stereo</code> - downmixes all input channels to stereo (if there are more than 2 input channels, e.g. surround sound)


== 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#L112 opus_encoder.c]''' source file.


{| class="wikitable" style="text-align:center"
{| class="wikitable" style="text-align:center"
|-  
|-
|rowspan="2"|(bitrates in Kb/s)
!rowspan="3"|Bandpass Range (Hz)
!colspan="4"|Rough Bitrate Required (Kb/s)
|-
!colspan="2"|Mono
!colspan="2"|Mono
!colspan="2"|Stereo
!colspan="2"|Stereo
|-
|-
! Voice
!Voice
! Music
!Music
! Voice
!Voice
! Music
!Music
|-
|style="text-align:right;"|NarrowBand (3&nbsp;-&nbsp;4000)
|12
|15
|?
|?
|-
|-
!<abbr title="NarrowBand (3-4000&nbsp;Hz)">NB</abbr> ↔ <abbr title="MediumBand (3-6000&nbsp;Hz)">MB</abbr>
|style="text-align:right;"|MediumBand (3&nbsp;-&nbsp;6000)
|11 ± 1
|15
|12 ± 1
|18-22
|11 ± 1
|?
|12 ± 2
|?
|-
|-
!MB ↔ <abbr title="WideBand (3-8000&nbsp;Hz)">WB</abbr>
|style="text-align:right;"|WideBand (3&nbsp;-&nbsp;8000)
|14 ± 1
|16-20
|15 ± 1
|22-28
|14 ± 2
|?
|18 ± 2
|?
|-
|-
!WB ↔ <abbr title="SuperWideBand (3-12000&nbsp;Hz))">SWB</abbr>
|style="text-align:right;"|SuperWideBand (3-12000)
|17 ± 1
|24-28
|18 ± 1
|28-32
|21 ± 2
|?
|21 ± 2
|?
|-
|-
!SWB ↔ <abbr title="FullBand (3-20000&nbsp;Hz)">FB</abbr>
|style="text-align:right;"|FullBand (3-20000)
|21 ± 1
|28-40
|22 ± 2
|32-64
|28 ± 2
|32-64
|30 ± 2
|64-128
|}
|}


== Usage Table ==
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 following table has '''rough''' guidelines to help you get your required quality, file size or latency. The table is originally taken from the '''[http://wiki.hydrogenaud.io/index.php?title=Opus HydrogenAudio]''' wiki, which 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.
 
== Framesize Tweaking ==
Opus can encode frames of '''2.5''', '''5''', '''10''', '''20''', '''40''', or '''60&nbsp;ms'''.  It can also combine multiple frames into packets of '''up to 120&nbsp;ms'''.


{| class="wikitable" style="text-align:center"
Opus uses a '''20&nbsp;ms''' frame size '''[https://tools.ietf.org/html/rfc6716#section-2.1.4 by default]''', as it gives a decent mix of low latency and good quality.
|-
 
!Bitrate target
For real-time applications, sending fewer packets per second reduces the overall bitrate, since it reduces the overhead from '''[https://en.wikipedia.org/wiki/IPv6_packet#Fixed_header IP]''', '''[https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure UDP]''', and '''[https://en.wikipedia.org/wiki/Real-time_Transport_Protocol#Packet_header RTP headers]'''.
!Music quality notes
However, it increases latency and sensitivity to packet losses, as losing one packet constitutes a loss of a bigger chunk of audio.
!Use cases/notes/competitive codecs
Unless operating at very low bitrates over RTP, there is no reason to use frame sizes above 20 ms, as those will have slightly lower quality for music encoding.
|-
 
!6 kbps
For these reasons, the default 20&nbsp;ms frames are a good choice for most applications.
|Poor, muffled sound but intelligible lyrics.
 
| -
== Trading Coding Efficiency with CPU Time ==
|-
The Opus encoder uses its maximum algorithmic '''complexity''' setting of '''10''' '''[https://tools.ietf.org/html/rfc6716#section-2.1.5 by default]'''. This means that it does not hesitate to use CPU to give you the best quality encoding at a given bitrate.
!8 kbps
 
|Poor, muffled but OK for bitrate
If the CPU usage is too high for the system you are using Opus on, you can try a lower complexity setting. The allowed values span from '''10''' (highest CPU usage and quality) down to '''0''' (lowest CPU usage and quality).
| -
 
|-
[[Category:Opus]]
!14 to 16 kbps
|Fairly Poor but OK for bitrate
|Perhaps acceptable for incidental music
|-
!22 to 24 kbps
|Fair but OK for bitrate
|OK for incidental music
|-
!32 kbps
|Moderately good mono, reasonably bright treble (c.f. mono cassette)
|Good for podcasts, audiobooks, CELT-only poss for music. Competitor HE-AAC@32kbps is stereo full-band but with annoying artifacts.
|-
!36 to 40 kbps
|Moderately good stereo, reasonably bright treble (c.f. stereo cassette)
|Stereo podcasts, audiobooks, very low bitrate music
|-
!48 kbps
|Full bandwidth stereo music, some artifacts, rarely nasty
|Stereo podcasts, audiobooks, low bitrate music
|-
!64 kbps
|Full bandwidth stereo music, nice sound, detectable differences to original (mostly 'not annoying')
|Music storage & streaming. Beat HE-AAC, Vorbis, MP3 in [http://people.xiph.org/~greg/opus/ha2011/ listening test]
|-
!96 kbps
|Full bandwidth stereo music, good quality approaching transparency
|Music storage & high quality streaming. Beat LC-AAC, Vorbis, MP3 in [http://listening-test.coresv.net/results.htm listening test]
|-
!112 kbps
|Fairly close to transparency (needs more testing)
|Music storage & high quality streaming. Very low-latency stereo networked music performance/jam sessions at OK quality (see below table)
|-
!128 kbps
|Very close to transparency (needs more testing). Most modern codecs competitive (AAC-LC, Vorbis, MP3)
|Music storage & streaming. Future download music sales.
|-
!256 kbps
|Transparent with very low chance of artifacts (a few killer samples still detectable). Most old & new lossy codecs competitive.
|Music storage & streaming, dedicated limited-bandwidth audio links (e.g. wireless, [http://en.wikipedia.org/wiki/Bluetooth_profile#Advanced_Audio_Distribution_Profile_.28A2DP.29 A2DP-bluetooth] type links).  
|-
!510 kbps
|Maximum possible stereo bitrate target (actual rate often less than 510 for default frame size). At these bitrates, you probably want to be using [[FLAC]]...
|Music storage, dedicated limited-bitrate audio links (e.g. wireless, minimum latency high quality audio. LossyWAV and WavPack lossy are very competitive for storage, and WavPack lossy --blocksize=256 may be competitive with minimum latency mode also.
|-
!>510 kbps
|Above Opus bitrate range allowed for stereo sources.
|Settle for 510kbps or use [[FLAC]].
|-
|}

Revision as of 11:34, 30 May 2017

Recommended Bitrates

Depending on the kind of audio you want to encode with Opus, you may want to 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 file size (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 file size (or bitrate) is too big,
  • tweaking the bitrate up if you think the quality is bad, and you can afford having bigger files (or a larger streaming bitrate).
Use Case Channels Bitrate (Kb/s) Notes
Low bandwidth HF/VHF digital radio 1 (mono) Use Codec 2 Opus only supports bitrates down to 6 Kb/s.

Codec 2 handles ultra low bitrate speech at 0.7 - 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.

(listening test results: 64 Kb/s, 96 Kb/s)

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 1 - 8 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 all input channels to mono

--downmix-stereo - downmixes all input channels to stereo (if there are more than 2 input channels, e.g. 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).

Bandpass Range (Hz) Rough Bitrate Required (Kb/s)
Mono Stereo
Voice Music Voice Music
NarrowBand (3 - 4000) 12 15 ? ?
MediumBand (3 - 6000) 15 18-22 ? ?
WideBand (3 - 8000) 16-20 22-28 ? ?
SuperWideBand (3-12000) 24-28 28-32 ? ?
FullBand (3-20000) 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 can encode frames of 2.5, 5, 10, 20, 40, or 60 ms. It can also combine multiple frames into packets of up to 120 ms.

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

For real-time applications, sending fewer packets per second reduces the overall bitrate, since it reduces the overhead from IP, UDP, and RTP headers. However, it increases latency and sensitivity to packet losses, as losing one packet constitutes a loss of a bigger chunk of audio. Unless operating at very low bitrates over RTP, there is no reason to use frame sizes above 20 ms, as those will have slightly lower quality for music encoding.

For these reasons, the default 20 ms frames are a good choice for most applications.

Trading Coding Efficiency with CPU Time

The Opus encoder uses its maximum algorithmic complexity setting of 10 by default. This means that it does not hesitate to use CPU to give you the best quality encoding at a given bitrate.

If the CPU usage is too high for the system you are using Opus on, you can try a lower complexity setting. The allowed values span from 10 (highest CPU usage and quality) down to 0 (lowest CPU usage and quality).