<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
	<id>https://wiki.xiph.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MarkH</id>
	<title>XiphWiki - User contributions [en]</title>
	<link rel="self" type="application/atom+xml" href="https://wiki.xiph.org/api.php?action=feedcontributions&amp;feedformat=atom&amp;user=MarkH"/>
	<link rel="alternate" type="text/html" href="https://wiki.xiph.org/Special:Contributions/MarkH"/>
	<updated>2026-05-31T17:58:36Z</updated>
	<subtitle>User contributions</subtitle>
	<generator>MediaWiki 1.45.1</generator>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=Opus_Recommended_Settings&amp;diff=16818</id>
		<title>Opus Recommended Settings</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=Opus_Recommended_Settings&amp;diff=16818"/>
		<updated>2024-11-25T15:10:24Z</updated>

		<summary type="html">&lt;p&gt;MarkH: fix broken demo3 link&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Recommended Bitrates =&lt;br /&gt;
Depending on the kind of audio you want to encode with Opus, you may want to use different bitrate (quality) settings.&lt;br /&gt;
&lt;br /&gt;
The settings in the table below are meant to &#039;&#039;&#039;start you off&#039;&#039;&#039; with a decent tradeoff between &#039;&#039;&#039;good quality&#039;&#039;&#039; and &#039;&#039;&#039;small file size&#039;&#039;&#039; (or &#039;&#039;&#039;bitrate usage&#039;&#039;&#039;, if you&#039;re streaming).&lt;br /&gt;
&lt;br /&gt;
You should test the suggested bitrate by actually &#039;&#039;&#039;listening&#039;&#039;&#039; to your encoded audio and then:&lt;br /&gt;
* tweaking the bitrate &#039;&#039;&#039;down&#039;&#039;&#039; if you think the quality is good, but the file size (or bitrate) is too big,&lt;br /&gt;
* tweaking the bitrate &#039;&#039;&#039;up&#039;&#039;&#039; if you think the quality is bad, and you can afford having bigger files (or a larger streaming bitrate).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Use Case&lt;br /&gt;
!Channels&lt;br /&gt;
!Bitrate (Kb/s)&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
|Low bandwidth HF/VHF digital radio&lt;br /&gt;
|1 (mono)&lt;br /&gt;
|Use &#039;&#039;&#039;[http://www.rowetel.com/?page_id=452 Codec&amp;amp;nbsp;2]&#039;&#039;&#039;&lt;br /&gt;
|Opus only supports bitrates &#039;&#039;&#039;down to 6&amp;amp;nbsp;Kb/s&#039;&#039;&#039;.&amp;lt;br&amp;gt;&lt;br /&gt;
Codec 2 handles ultra low bitrate speech at &#039;&#039;&#039;0.7&amp;amp;nbsp;-&amp;amp;nbsp;3.2&amp;amp;nbsp;Kb/s&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|VoIP&lt;br /&gt;
|1&lt;br /&gt;
|10&amp;amp;nbsp;-&amp;amp;nbsp;24&lt;br /&gt;
|10&amp;amp;nbsp;Kb/s will deliver narrowband most of the time, 24&amp;amp;nbsp;Kb/s should give fullband.&amp;lt;br&amp;gt;&lt;br /&gt;
More details in &#039;&#039;&#039;[[Opus_Recommended_Settings#Bandwidth_Transition_Thresholds|the relevant table]]&#039;&#039;&#039; further down this page.&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|Audiobooks / Podcasts&lt;br /&gt;
|1&lt;br /&gt;
|24&lt;br /&gt;
|Bitrates from here on up tend to deliver fullband audio.&lt;br /&gt;
|-&lt;br /&gt;
|2 (stereo)&lt;br /&gt;
|32&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Music Streaming / Radio&lt;br /&gt;
|2&lt;br /&gt;
|64&amp;amp;nbsp;-&amp;amp;nbsp;96&lt;br /&gt;
|Opus has better quality than MP3, AAC and [[Vorbis]] at these rates.&amp;lt;br&amp;gt;&lt;br /&gt;
(listening test results: &#039;&#039;&#039;[http://listening-tests.hydrogenaud.io/igorc/results.html 64&amp;amp;nbsp;Kb/s]&#039;&#039;&#039;, &#039;&#039;&#039;[http://listening-test.coresv.net/results.htm 96&amp;amp;nbsp;Kb/s]&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;3&amp;quot;|Music Storage&lt;br /&gt;
|2&lt;br /&gt;
|96&amp;amp;nbsp;-&amp;amp;nbsp;128&lt;br /&gt;
|Opus at 128&amp;amp;nbsp;KB/s (VBR) is pretty much &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Transparency_(data_compression) transparent]&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|6 (5.1 surround)&lt;br /&gt;
|128&amp;amp;nbsp;-&amp;amp;nbsp;256&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|For surround sound, Opus uses &#039;&#039;&#039;[https://people.xiph.org/~xiphmont/demo/opus/demo3.shtml surround-sound bitrate allocation]&#039;&#039;&#039;.&lt;br /&gt;
|-&lt;br /&gt;
|8 (7.1 surround)&lt;br /&gt;
|256&amp;amp;nbsp;-&amp;amp;nbsp;450&lt;br /&gt;
|-&lt;br /&gt;
|Music Archiving&lt;br /&gt;
|1&amp;amp;nbsp;-&amp;amp;nbsp;8&lt;br /&gt;
|Use &#039;&#039;&#039;[[FLAC]]&#039;&#039;&#039;&lt;br /&gt;
|If you are archiving audio, use a &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Audio_file_format#Lossless_compressed_audio_format lossless audio format]&#039;&#039;&#039; to prevent &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Generation_loss generation loss]&#039;&#039;&#039;.&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Technical Details =&lt;br /&gt;
For the more technical Opus users, here are some details to help you fine-tune your decision on which bitrate best fits your needs.&lt;br /&gt;
&lt;br /&gt;
== Mono or Stereo ==&lt;br /&gt;
Opus tends to start &#039;&#039;&#039;downmixing stereo inputs to mono&#039;&#039;&#039; from roughly &#039;&#039;&#039;19&amp;amp;nbsp;Kb/s and lower&#039;&#039;&#039;.&lt;br /&gt;
You can check the details in the &#039;&#039;&#039;[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L149 opus_encoder.c]&#039;&#039;&#039; source file.&lt;br /&gt;
&lt;br /&gt;
You can force downmixing at any bitrate by using the following command-line parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--downmix-mono&amp;lt;/code&amp;gt; - downmixes all input channels to mono&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--downmix-stereo&amp;lt;/code&amp;gt; - downmixes all input channels to stereo (if there are more than 2 input channels, e.g. surround sound)&lt;br /&gt;
&lt;br /&gt;
== Bandwidth Transition Thresholds ==&lt;br /&gt;
The following table shows rough bitrates that you might want to use to encode audio that has &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2 limited frequency bandwidths]&#039;&#039;&#039;.&lt;br /&gt;
This could be useful if your audio has already been bandpassed, or should go through a bandpass filter (e.g. VoIP speech).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!rowspan=&amp;quot;3&amp;quot;|Bandpass Range (Hz)&lt;br /&gt;
!colspan=&amp;quot;4&amp;quot;|Rough Bitrate Required (Kb/s)&lt;br /&gt;
|-&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Mono&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Stereo&lt;br /&gt;
|-&lt;br /&gt;
!Voice&lt;br /&gt;
!Music&lt;br /&gt;
!Voice&lt;br /&gt;
!Music&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:right;&amp;quot;|NarrowBand (3&amp;amp;nbsp;-&amp;amp;nbsp;4000)&lt;br /&gt;
|12&lt;br /&gt;
|15&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:right;&amp;quot;|MediumBand (3&amp;amp;nbsp;-&amp;amp;nbsp;6000)&lt;br /&gt;
|15&lt;br /&gt;
|18-22&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:right;&amp;quot;|WideBand (3&amp;amp;nbsp;-&amp;amp;nbsp;8000)&lt;br /&gt;
|16-20&lt;br /&gt;
|22-28&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:right;&amp;quot;|SuperWideBand (3-12000)&lt;br /&gt;
|24-28&lt;br /&gt;
|28-32&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
|style=&amp;quot;text-align:right;&amp;quot;|FullBand (3-20000)&lt;br /&gt;
|28-40&lt;br /&gt;
|32-64&lt;br /&gt;
|32-64&lt;br /&gt;
|64-128&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The details of Opus&#039; bandpass thresholds can be found in the &#039;&#039;&#039;[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L121 opus_encoder.c]&#039;&#039;&#039; source file.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;[http://wiki.hydrogenaud.io/index.php?title=Opus HydrogenAudio]&#039;&#039;&#039; wiki also has some great information on Opus and its usage.&lt;br /&gt;
&lt;br /&gt;
== Framesize Tweaking ==&lt;br /&gt;
Opus can encode frames of &#039;&#039;&#039;2.5&#039;&#039;&#039;, &#039;&#039;&#039;5&#039;&#039;&#039;, &#039;&#039;&#039;10&#039;&#039;&#039;, &#039;&#039;&#039;20&#039;&#039;&#039;, &#039;&#039;&#039;40&#039;&#039;&#039;, or &#039;&#039;&#039;60&amp;amp;nbsp;ms&#039;&#039;&#039;.  It can also combine multiple frames into packets of &#039;&#039;&#039;up to 120&amp;amp;nbsp;ms&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Opus uses a &#039;&#039;&#039;20&amp;amp;nbsp;ms&#039;&#039;&#039; frame size &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2.1.4 by default]&#039;&#039;&#039;, as it gives a decent mix of low latency and good quality.&lt;br /&gt;
&lt;br /&gt;
For real-time applications, sending fewer packets per second reduces the overall bitrate, since it reduces the overhead from &#039;&#039;&#039;[https://en.wikipedia.org/wiki/IPv6_packet#Fixed_header IP]&#039;&#039;&#039;, &#039;&#039;&#039;[https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure UDP]&#039;&#039;&#039;, and &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Real-time_Transport_Protocol#Packet_header RTP headers]&#039;&#039;&#039;.&lt;br /&gt;
However, it increases latency and sensitivity to packet losses, as losing one packet constitutes a loss of a bigger chunk of audio.&lt;br /&gt;
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.&lt;br /&gt;
&lt;br /&gt;
For these reasons, the default 20&amp;amp;nbsp;ms frames are a good choice for most applications.&lt;br /&gt;
&lt;br /&gt;
== Trading Coding Efficiency with CPU Time ==&lt;br /&gt;
The Opus encoder uses its maximum algorithmic &#039;&#039;&#039;complexity&#039;&#039;&#039; setting of &#039;&#039;&#039;10&#039;&#039;&#039; &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2.1.5 by default]&#039;&#039;&#039;. This means that it does not hesitate to use CPU to give you the best quality encoding at a given bitrate.&lt;br /&gt;
&lt;br /&gt;
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 &#039;&#039;&#039;10&#039;&#039;&#039; (highest CPU usage and quality) down to &#039;&#039;&#039;0&#039;&#039;&#039; (lowest CPU usage and quality).&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OggKate&amp;diff=16781</id>
		<title>OggKate</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OggKate&amp;diff=16781"/>
		<updated>2023-02-21T16:20:46Z</updated>

		<summary type="html">&lt;p&gt;MarkH: fix broken links&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Disclaimer ==&lt;br /&gt;
This is not a Xiph codec, though it may be embedded in Ogg alonside other Xiph&lt;br /&gt;
codecs, such as Vorbis and Theora. As such, please do not assume that Xiph has&lt;br /&gt;
anything to do with this, much less responsibility.&lt;br /&gt;
&lt;br /&gt;
==  What is Kate? ==&lt;br /&gt;
&lt;br /&gt;
Kate is an overlay codec, originally designed for karaoke and text, that can be&lt;br /&gt;
multiplexed in Ogg.&lt;br /&gt;
&lt;br /&gt;
Text and images can be carried and animated by a Kate stream.&lt;br /&gt;
Most of the time, they will (optionally) be multiplexed with audio/video to carry subtitles,&lt;br /&gt;
song lyrics (with or without karaoke data), etc.&lt;br /&gt;
&lt;br /&gt;
Series of curves (splines, segments, etc) may be attached to various properties&lt;br /&gt;
(text position, font size, etc) to create animated overlays. This allows scrolling&lt;br /&gt;
or fading text to be defined. This can even be used to draw arbitrary shapes, so&lt;br /&gt;
hand drawing can also be represented by a Kate stream.&lt;br /&gt;
&lt;br /&gt;
Example uses of Kate streams are movie subtitles for Theora videos, either text based,&lt;br /&gt;
as may be created by [http://www.v2v.cc/~j/ffmpeg2theora ffmpeg2theora], or image&lt;br /&gt;
based, such as created by [http://thoggen.net Thoggen] (patching needed), and lyrics,&lt;br /&gt;
as created by oggenc, from vorbis-tools.&lt;br /&gt;
&lt;br /&gt;
== Why a new codec? ==&lt;br /&gt;
&lt;br /&gt;
As I was adding support for Theora, Speex and FLAC to some software of mine, I found myself&lt;br /&gt;
wanting to have song lyrics accompanying Vorbis audio. Since Vorbis comments are limited to&lt;br /&gt;
the headers, one can&#039;t add them in the stream as they are sung, so another multiplexed stream&lt;br /&gt;
would be needed to carry them.&lt;br /&gt;
&lt;br /&gt;
The three possible bases usable for such a codec I found were Writ, CMML, and OGM/SRT.&lt;br /&gt;
&lt;br /&gt;
*[[OggWrit|Writ]] is an unmaintained start at an implementation of a very basic design, though I did find an encoder/decoder in py-ogg2 later on - I&#039;d been quicker to write Kate from scratch anyway.&lt;br /&gt;
*[[CMML]] is more geared towards encapsulating metadata about an accompanying stream, rather than being a data stream itself, and seemed complex for a simple use, though I have now revised my view on this - besides, it seems designed for Annodex (which I haven&#039;t had a look at), though it does seems relatively generic for use outwith Annodex - though it is being &amp;quot;repurposed&amp;quot; as timed text now, bringing it closer to what I&#039;m doing&lt;br /&gt;
*OGM/SRT, which I only found when I added Kate support to MPlayer, is shoehorning various data formats into an Ogg stream, and just dumps the SRT subtitle format as is, AFAICS (though I haven&#039;t looked at this one in detail, since I&#039;d already had a working Kate implementation by that time)&lt;br /&gt;
&lt;br /&gt;
I then decided to roll my own, not least because it&#039;s a fun thing to do.&lt;br /&gt;
&lt;br /&gt;
I found other formats, such as USF (designed for inclusion in Matroska) and various subtitle formats,&lt;br /&gt;
but none were designed for embedding inside an Ogg container.&lt;br /&gt;
&lt;br /&gt;
== Overview of the Kate bitstream format ==&lt;br /&gt;
&lt;br /&gt;
I&#039;ve taken much inspiration from Vorbis and Theora here.&lt;br /&gt;
Headers and packets (as well as the API design) follow the design of these two codecs.&lt;br /&gt;
&lt;br /&gt;
A rough overview (see [[#Format specification|Format specification]] for more details) is:&lt;br /&gt;
&lt;br /&gt;
Headers packets:&lt;br /&gt;
*ID header [BOS]: magic, version, granule fraction, encoding, language, etc&lt;br /&gt;
*Comment header: Vorbis comments, as per Vorbis/Theora streams&lt;br /&gt;
*Style definitions header: a list of predefined styles to be referred to by data packets&lt;br /&gt;
*Region definitions header: a list of predefined regions to be referred to by data packets&lt;br /&gt;
*Curves definitions header: a list of predefined curves to be referred to by data packets&lt;br /&gt;
*Motion definitions header: a list of predefined motions to be referred to by data packets&lt;br /&gt;
*Palette definitions header: a list of predefined palettes to be referred to by data packets&lt;br /&gt;
*Bitmap definitions header: a list of predefined bitmaps to be referred to by data packets&lt;br /&gt;
*Font mapping definitions header: a list of predefined font mappings to be referred to by data packets&lt;br /&gt;
&lt;br /&gt;
Other header packets are ignored, and left for future expansion.&lt;br /&gt;
&lt;br /&gt;
Data packets:&lt;br /&gt;
*text data: text/image and optional motions, accompanied by optional overrides for style, region, language, etc&lt;br /&gt;
*keepalive: can be emitted at any time to help a demuxer know where we&#039;re at, but those packets are optional&lt;br /&gt;
*repeats: a verbatim repeat of a text packet&#039;s payload, in order to bound any backward seeking needed when starting to play a stream partway through. These are also optional.&lt;br /&gt;
*end data [EOS]: marks the end of the stream, it doesn&#039;t have any useful payload&lt;br /&gt;
&lt;br /&gt;
Other data packets are ignored, and left for future expansion.&lt;br /&gt;
&lt;br /&gt;
The intent of the &amp;quot;keepalive&amp;quot; packet is to be sent at regular&lt;br /&gt;
intervals when no other packet has been emitted for a while. This would be to help seeking code&lt;br /&gt;
find a kate page more easily.&lt;br /&gt;
&lt;br /&gt;
Things of note:&lt;br /&gt;
*Kate is a discontinuous codec, as defined in [http://www.xiph.org/ogg/doc/ogg-multiplex.html ogg-multiplex.html] in the Ogg documentation, which means it&#039;s timed by start granule, not end granule (as Theora and Vorbis).&lt;br /&gt;
* All data packets are on their own page, for two reasons:&lt;br /&gt;
**Ogg keeps track of granules at the page level, not the packet level&lt;br /&gt;
**if no text event happens for a while after a particular text event, we don&#039;t want to delay it so a larger page can be issued&lt;br /&gt;
&lt;br /&gt;
See also [[#Seeking and memory|Problems to solve: Seeking and memory]].&lt;br /&gt;
&lt;br /&gt;
*The granule encoding is not a direct time/granule correspondance, see the granule encoding section.&lt;br /&gt;
*The EOS packet should have a granule pos higher or equal to the end time of all events.&lt;br /&gt;
*User code doesn&#039;t have to know the number of headers to expect, this is moved inside the library code (as opposed to Vorbis and Theora).&lt;br /&gt;
*The format contains hooks so that additional information may be added in future revisions while keeping backward compatibility (though old decoders will correctly parse, but ignore the new information).&lt;br /&gt;
&lt;br /&gt;
== Format specification ==&lt;br /&gt;
&lt;br /&gt;
The Kate bitstream format consists of a number of sequential packets.&lt;br /&gt;
Packets can be either header packets or data packets. All header packets&lt;br /&gt;
must appear before any data packet.&lt;br /&gt;
&lt;br /&gt;
Header packets must appear in order. Decoding of a data packet is not&lt;br /&gt;
possible until all header packets have been decoded.&lt;br /&gt;
&lt;br /&gt;
Each Kate packet starts with a one byte type. A type with the MSB set&lt;br /&gt;
(eg, between 0x80 and 0xff) indicates a header packet, while a type with&lt;br /&gt;
the MSB cleared (eg, between 0x00 and 0x7f) indicates a data packet.&lt;br /&gt;
All header packets then have the Kate magic, from byte offset 1 to byte&lt;br /&gt;
offset 7 (&amp;quot;kate\0\0\0&amp;quot;). Note that this applies only to header packets:&lt;br /&gt;
data packets do not contain the Kate signature.&lt;br /&gt;
&lt;br /&gt;
Since the ID header must appear first, a Kate stream can be recognized&lt;br /&gt;
by comparing the first eight bytes of the first packet with the signature&lt;br /&gt;
string &amp;quot;\200kate\0\0\0&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
When embedded in Ogg,the first packet in a Kate stream (always packet type 0x80,&lt;br /&gt;
the id header packet) must be placed on a separate page. The corresponding Ogg&lt;br /&gt;
packet must be marked as beginning of stream (BOS).All subsequent header packets&lt;br /&gt;
must be on one or more pages. Subsequently, each data packet must be on a separate&lt;br /&gt;
page.&lt;br /&gt;
&lt;br /&gt;
The last data packet must be the end of stream packet (packet type 0x7f).&lt;br /&gt;
&lt;br /&gt;
When embedded in Ogg, the corresponding Ogg packet must be marked as end of stream (EOS).&lt;br /&gt;
&lt;br /&gt;
As per the Ogg specification, granule positions must be non decreasing&lt;br /&gt;
within the stream. Header packets have granule position 0.&lt;br /&gt;
&lt;br /&gt;
Currently existing packet types are:&lt;br /&gt;
:headers:&lt;br /&gt;
::0x80  ID header (BOS)&lt;br /&gt;
::0x81  Vorbis comment header&lt;br /&gt;
::0x82  regions list header&lt;br /&gt;
::0x83  styles list header&lt;br /&gt;
::0x84  curves list header&lt;br /&gt;
::0x85  motions list header&lt;br /&gt;
::0x86  palettes list header&lt;br /&gt;
::0x87  bitmaps list header&lt;br /&gt;
::0x88  font ranges and mappings header&lt;br /&gt;
:data:&lt;br /&gt;
::0x00 text data (including optional motions and overrides)&lt;br /&gt;
::0x01 keepalive&lt;br /&gt;
::0x02 repeat&lt;br /&gt;
::0x7f end packet (EOS)&lt;br /&gt;
&lt;br /&gt;
This format described here is for bitstream version 0.x.&lt;br /&gt;
As or 19 december 2008, the latest bitstream version is 0.4.&lt;br /&gt;
&lt;br /&gt;
For more detailed information, refer to the format documentation&lt;br /&gt;
in libkate (see URL below in the [[#Downloading|Downlading]] section).&lt;br /&gt;
&lt;br /&gt;
Following is the definition of the ID header (packet type 0x80).&lt;br /&gt;
This works out to a 64 byte ID header. This is the header that should be&lt;br /&gt;
used to detect a Kate stream within an Ogg stream.&lt;br /&gt;
&lt;br /&gt;
  0               1               2               3              |&lt;br /&gt;
  0                   1                   2                   3&lt;br /&gt;
  0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1| Byte&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | packtype      | Identifier char[7]: &#039;kate\0\0\0&#039;              | 0-3&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | kate magic continued                                          | 4-7&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | reserved - 0  | version major | version minor | num headers   | 8-11&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | text encoding | directionality| reserved - 0  | granule shift | 12-15&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | cw sh |  canvas width         | ch sh | canvas height         | 16-19&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | reserved - 0                                                  | 20-23&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | granule rate numerator                                        | 24-27&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | granule rate denominator                                      | 28-31&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | language (NUL terminated)                                     | 32-35&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | language (continued)                                          | 36-39&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | language (continued)                                          | 40-43&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | language (continued)                                          | 44-47&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | category (NUL terminated)                                     | 48-51&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | category (continued)                                          | 52-55&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | category (continued)                                          | 56-59&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
 | category (continued)                                          | 60-63&lt;br /&gt;
 +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
&lt;br /&gt;
The fields cw sh, canvas width, cw sh, and canvas height were introduced&lt;br /&gt;
in bistream 0.3. Earlier bitstreams will have 0 in these fields.&lt;br /&gt;
&lt;br /&gt;
language and category are NUL terminating ASCII strings.&lt;br /&gt;
Language follows RFC 3066, though obviously will not accommodate language tags&lt;br /&gt;
with lots of subtags.&lt;br /&gt;
&lt;br /&gt;
Category is currently loosely defined, and I haven&#039;t found yet a nice way to&lt;br /&gt;
present it in a generic way, but is meant for automatic classifying of&lt;br /&gt;
various multiplexed Kate streams (eg, to recognize that some streams are&lt;br /&gt;
subtitles (in a set of languages), and some others are commentary (in a&lt;br /&gt;
possibly different set of languages, etc).&lt;br /&gt;
&lt;br /&gt;
== API overview ==&lt;br /&gt;
&lt;br /&gt;
libkate offers an API very similar to that of libvorbis and libtheora, as well as&lt;br /&gt;
an extra higher level decoding API.&lt;br /&gt;
&lt;br /&gt;
Here&#039;s an overview of the three main modules:&lt;br /&gt;
&lt;br /&gt;
=== Decoding ===&lt;br /&gt;
&lt;br /&gt;
Decoding is done in a way similar to libvorbis. First, initialize a kate_info and a&lt;br /&gt;
kate_comment structure. Then, read headers by calling kate_decode_headerin. Once&lt;br /&gt;
all headers have been read, a kate_state is initialized for decoding using kate_decode_init,&lt;br /&gt;
and kate_decode_packetin is called repeatedly with data packets. Events (eg, text) can be&lt;br /&gt;
retrieved via kate_decode_eventout.&lt;br /&gt;
&lt;br /&gt;
=== Encoding ===&lt;br /&gt;
&lt;br /&gt;
Encoding is also done in a way similar to libvorbis. First initialize a kate_info&lt;br /&gt;
and a kate_comment structure, and fill them out as needed. kate_encode_headers will&lt;br /&gt;
create ogg packets from those. Then, kate_encode_text is called repeatedly for all&lt;br /&gt;
the text events to add. When done, calling kate_encode_finish will create an end of&lt;br /&gt;
stream packet.&lt;br /&gt;
&lt;br /&gt;
=== High level decoding API ===&lt;br /&gt;
&lt;br /&gt;
There are only 3 calls here:&lt;br /&gt;
&lt;br /&gt;
 kate_high_decode_init&lt;br /&gt;
 kate_high_decode_packetin&lt;br /&gt;
 kate_high_decode_clear&lt;br /&gt;
&lt;br /&gt;
Here, all Ogg packets are sent to kate_high_decode_packetin, which does the right&lt;br /&gt;
thing (header/data classification, decoding, and event retrieval). Note that you&lt;br /&gt;
do not get access to the comments directly using this, but you do get access to the&lt;br /&gt;
kate_info via events.&lt;br /&gt;
&lt;br /&gt;
The libkate distribution includes commented examples for each of those.&lt;br /&gt;
&lt;br /&gt;
Additionally, libkate includes a layer (liboggkate) to make it easier to use when&lt;br /&gt;
embedded in Ogg. While the normal API uses kate_packet structures, liboggkate uses&lt;br /&gt;
ogg_packet structures.&lt;br /&gt;
&lt;br /&gt;
The High level decoding API does not have an Ogg specific layer, but functions exist&lt;br /&gt;
to wrap a kate_packet around a memory buffer (such as the one ogg_packet uses, for instance).&lt;br /&gt;
&lt;br /&gt;
== Support ==&lt;br /&gt;
&lt;br /&gt;
Among the software with Kate support:&lt;br /&gt;
*VLC&lt;br /&gt;
*ffmpeg2theora&lt;br /&gt;
*liboggz&lt;br /&gt;
*liboggplay&lt;br /&gt;
*Cortado (wikimedia version)&lt;br /&gt;
*vorbis-tools&lt;br /&gt;
&lt;br /&gt;
I have patches for the following with Kate support:&lt;br /&gt;
*MPlayer&lt;br /&gt;
*xine&lt;br /&gt;
*GStreamer&lt;br /&gt;
*Thoggen&lt;br /&gt;
*Audacious&lt;br /&gt;
*and more...&lt;br /&gt;
&lt;br /&gt;
These may be found in the libkate source distribution (see [[#Downloading|Downloading]]&lt;br /&gt;
for links).&lt;br /&gt;
&lt;br /&gt;
In addition, libtiger is a rendering library for Kate streams using Pango and Cairo,&lt;br /&gt;
though it is not quite yet API stable (though no major changes are expected).&lt;br /&gt;
&lt;br /&gt;
== Granule encoding ==&lt;br /&gt;
&lt;br /&gt;
=== Ogg ===&lt;br /&gt;
&lt;br /&gt;
Ogg leaves the encoding of granules up to a particular codec, only&lt;br /&gt;
mandating that granules be non decreasing with time.&lt;br /&gt;
&lt;br /&gt;
The Kate bitstream format uses a linear mapping between time and&lt;br /&gt;
granule, described here.&lt;br /&gt;
&lt;br /&gt;
A Kate granule position is composed of two different parts:&lt;br /&gt;
 - a base granule, in the high bits&lt;br /&gt;
 - a granule offset, in the low bits&lt;br /&gt;
&lt;br /&gt;
 +----------------+----------------+&lt;br /&gt;
 | base           | offset         |&lt;br /&gt;
 +----------------+----------------+&lt;br /&gt;
&lt;br /&gt;
The number of bits these parts occupy is variable, and each stream&lt;br /&gt;
may choose how many bits to dedicate to each. The kate_info structure&lt;br /&gt;
for a stream holds that information in the granule_shift field,&lt;br /&gt;
so each part may be reconstructed from a granulepos.&lt;br /&gt;
&lt;br /&gt;
The timestamp T of a given Kate packet is split into a base B and&lt;br /&gt;
offset O, and these are stored in the granulepos of that packet.&lt;br /&gt;
The split is done such that the B is the time of the earliest event&lt;br /&gt;
still active at the time, and the O is the time elapsed between B&lt;br /&gt;
and T. Thus, T = B + O. This mimics the way Theora stores its own&lt;br /&gt;
timestamps in granulepos, where the base acts as a keyframe, and&lt;br /&gt;
an offset acts as the position of an intra frame from the previous&lt;br /&gt;
keyframe. Since Kate allows time overlapping events, however, the&lt;br /&gt;
choice of the base to use is slightly more complex, as it may not&lt;br /&gt;
be the starting time of the previous event, if the stream contains&lt;br /&gt;
time overlapping events.&lt;br /&gt;
&lt;br /&gt;
The kate_info structure for a stream holds a rational fraction&lt;br /&gt;
representing the time span of granule units for both the base and&lt;br /&gt;
the offset parts.&lt;br /&gt;
&lt;br /&gt;
The granule rate is defined by the two fields:&lt;br /&gt;
&lt;br /&gt;
 kate_info::gps_numerator&lt;br /&gt;
 kate_info::gps_denominator&lt;br /&gt;
&lt;br /&gt;
The number of bits reserved for the offset is defined by the field:&lt;br /&gt;
&lt;br /&gt;
 kate_info::granule_shift&lt;br /&gt;
&lt;br /&gt;
=== Generic timing ===&lt;br /&gt;
&lt;br /&gt;
Kate data packets (data packet type 0) includes timing information (start time,&lt;br /&gt;
end time, and time of the earliest event still active). All these are stored as&lt;br /&gt;
64 bit at the rate defined by the granule rate, so they do not suffer from the&lt;br /&gt;
granule_shift space limitation.&lt;br /&gt;
&lt;br /&gt;
This also allows for Kate streams to be stored in other containers.&lt;br /&gt;
&lt;br /&gt;
== Motion ==&lt;br /&gt;
&lt;br /&gt;
The Kate bitstream format includes motion definition, originally for karaoke purposes, but&lt;br /&gt;
which can be used for more general purpose, such as line based drawing, or animation of&lt;br /&gt;
the text (position, color, etc)&lt;br /&gt;
&lt;br /&gt;
Motions are defined by the means of a series of curves (static points, segments, splines (catmull-rom, bezier, and b-splines)).&lt;br /&gt;
A 2D point can be obtained from a motion for any timestamp during the lifetime of a text.&lt;br /&gt;
This can be used for moving a marker in 2D above the text for karaoke, or to use the x&lt;br /&gt;
coordinate to color text when the motion position passes each letter or word, etc.&lt;br /&gt;
Motions have an attached semantics so the client code knows how to use a particular motion.&lt;br /&gt;
Predefined semantics include text color, text position, etc).&lt;br /&gt;
&lt;br /&gt;
Since a motion can be composed of an arbitrary number of curves, each of which may have&lt;br /&gt;
an arbitrary number of control points, complex motions can be achieved. If the motion is&lt;br /&gt;
the main object of an event, it is even possible to have an empty text, and use the motion&lt;br /&gt;
as a virtual pencil to draw arbitrary shapes. Even on-the-fly handwriting subtitles could&lt;br /&gt;
be done this way, though this would require a lot of control points, and would not be able&lt;br /&gt;
to be used with text-to-speech.&lt;br /&gt;
&lt;br /&gt;
As a proof of concept, I also have a &amp;quot;draw chat&amp;quot; program where two people can draw, and&lt;br /&gt;
the shapes are turned to b-splines and sent as a kate motion to be displayed on the other&lt;br /&gt;
person&#039;s window.&lt;br /&gt;
&lt;br /&gt;
It is also possible for motions to be discontinuous - simply insert a curve of &#039;none&#039; type.&lt;br /&gt;
While the timestamp lies within such a curve, no 2D point will be generated. This can be&lt;br /&gt;
used to temporarily hide a marker, for instance.&lt;br /&gt;
&lt;br /&gt;
It is worth mentionning that pauses in the motion can be trivially included by inserting&lt;br /&gt;
at the right time and for the right duration a simple linear interpolation curve with only&lt;br /&gt;
two equal points, equal to the position the motion is supposed to pause at.&lt;br /&gt;
&lt;br /&gt;
Kate defines a set of predefined mappings so that each decoder user interprets a motion in&lt;br /&gt;
the same way. A mapping is coded on 8 bits in the bitstream, and the first 128 are reserved&lt;br /&gt;
for Kate, leaving 128 for application specific mappings, to avoid constraining creative uses&lt;br /&gt;
of that feature. Predefined mappings include frame (eg, 0-1 points are mapped to the size of&lt;br /&gt;
the current video frame), or region, to scale 0-1 to the current region. This allows curves&lt;br /&gt;
to be defined without knowing in advance the pixel size of the area it should cover.&lt;br /&gt;
&lt;br /&gt;
For uses which require more than two coordinates (eg, text color, where 4 (RGBA) values are&lt;br /&gt;
needed, Kate predefines the semantics text_color_rg and text_color_ba, so a 4D point can be&lt;br /&gt;
obtained using two different motions.&lt;br /&gt;
&lt;br /&gt;
There are higher level constructs, such as morphing between two styles, or predefined&lt;br /&gt;
karaoke effects. More are planned to be added in the future.&lt;br /&gt;
&lt;br /&gt;
See also [[#Trackers|Trackers]].&lt;br /&gt;
&lt;br /&gt;
== Trackers ==&lt;br /&gt;
&lt;br /&gt;
Since attaching motions to text position, etc, makes it hard for the client to keep track of&lt;br /&gt;
everything, doing interpolation, etc, the library supplies a tracker object, which handles the&lt;br /&gt;
interpolation of the relevant properties.&lt;br /&gt;
Once initialized with a text and a set of motions, the client code can give the tracker a new&lt;br /&gt;
timestamp, and get back the current text position, text color, etc.&lt;br /&gt;
&lt;br /&gt;
Using a tracker is not necessary, if one wants to use the motions directly, or just ignore them,&lt;br /&gt;
but it makes life easier, especially when considering the the order in which motions are applied&lt;br /&gt;
does matter (to be defined formally, but the current source code is informative at this point).&lt;br /&gt;
&lt;br /&gt;
== The Kate file format ==&lt;br /&gt;
&lt;br /&gt;
Though this is not a feature of the bitstream format, I have created a text file format to&lt;br /&gt;
describe a series of events to be turned into a Kate bitstream.&lt;br /&gt;
At its minimum, the following is a valid input to the encoder:&lt;br /&gt;
&lt;br /&gt;
: kate {&lt;br /&gt;
::  event { 00:00:05 --&amp;gt; 00:00:10    &amp;quot;This is a text&amp;quot; }&lt;br /&gt;
: }&lt;br /&gt;
&lt;br /&gt;
This will create a simple stream with &amp;quot;This is a text&amp;quot; emitted at an offset of 5 seconds into&lt;br /&gt;
the track, lasting 5 seconds to an end time at 10 seconds.&lt;br /&gt;
&lt;br /&gt;
Motions, regions, styles can be declared in a definitions block to be reused by events, or can&lt;br /&gt;
be defined inline. Defining those in the definitions block places them in a header so they can&lt;br /&gt;
be reused later, saving space. However, they can also be defined in each event, so they will be&lt;br /&gt;
sent with the event. This allows them to be generated on the fly (eg, if the bitstream is being&lt;br /&gt;
streamed from a realtime input).&lt;br /&gt;
&lt;br /&gt;
For convenience, the Kate file format also allows C style macros, though without parameters.&lt;br /&gt;
&lt;br /&gt;
Please note that the Kate file format is fully separate from the Kate bitstream format. The&lt;br /&gt;
difference between the two is similar to the difference between a C source file and the resulting&lt;br /&gt;
object file, when compiled.&lt;br /&gt;
&lt;br /&gt;
Note that the format is not based on XML for a very parochial reason: I tend to dislike very&lt;br /&gt;
much editing XML by hand, as it&#039;s really hard to read. XML is really meant for machines to parse&lt;br /&gt;
generically text data in a shared syntax but with possibly unknown semantics, and I need those&lt;br /&gt;
text representations to be editable easily.&lt;br /&gt;
&lt;br /&gt;
This also implies that there could be an XML representation of a Kate stream, which would be&lt;br /&gt;
useful if one were to make an editor that worked on a higher level than the current all-text&lt;br /&gt;
representation, and it is something that might very well happen in the future, in parallel with&lt;br /&gt;
the current format.&lt;br /&gt;
&lt;br /&gt;
== Karaoke ==&lt;br /&gt;
&lt;br /&gt;
Karaoke effects rely on motions, and there will be predefined higher level ways of specifying&lt;br /&gt;
timings and effects, two of which are already done.&lt;br /&gt;
&lt;br /&gt;
As an example, this is a valid Karaoke script:&lt;br /&gt;
&lt;br /&gt;
:kate {&lt;br /&gt;
::  simple_timed_glyph_style_morph {&lt;br /&gt;
:::   from style &amp;quot;start_style&amp;quot; to style &amp;quot;end_style&amp;quot;&lt;br /&gt;
:::   &amp;quot;Let &amp;quot;    at 1.0&lt;br /&gt;
:::   &amp;quot;us &amp;quot;     at 1.2&lt;br /&gt;
:::   &amp;quot;sing &amp;quot;   at 1.4&lt;br /&gt;
:::   &amp;quot;to&amp;quot;      at 2.0&lt;br /&gt;
:::   &amp;quot;ge&amp;quot;      at 2.5&lt;br /&gt;
:::   &amp;quot;ther&amp;quot;    at 3.0&lt;br /&gt;
::  }&lt;br /&gt;
:}&lt;br /&gt;
&lt;br /&gt;
The syllables will change from a style to another as time passes. The definition of the start_style&lt;br /&gt;
and end_style styles is omitted for brevity.&lt;br /&gt;
&lt;br /&gt;
== Problems to solve ==&lt;br /&gt;
&lt;br /&gt;
There are a few things to solve before the Kate bitstream format can be considered good&lt;br /&gt;
enough to be frozen:&lt;br /&gt;
&lt;br /&gt;
Note: the following is mostly solved, and the bitstream is now stable, and has been&lt;br /&gt;
backward and forward compatible since the first released version. This will be updated&lt;br /&gt;
when I get some time.&lt;br /&gt;
&lt;br /&gt;
=== Seeking and memory ===&lt;br /&gt;
&lt;br /&gt;
When seeking to a particular time in a movie with subtitles, we may end up at a place when a subtitle has been started, but is not removed yet. Pure streaming doesn&#039;t have this problem as it remembers the subtitle being issued (as opposed to, say, Vorbis, for which all data valid now is decoded from the last packet). With Kate, a text string valid now may have been issued long ago.&lt;br /&gt;
&lt;br /&gt;
I see three possible ways to solve this:&lt;br /&gt;
*each data packet includes the granule of the earliest still active packet (if none, this will be the granule of this very packet)&lt;br /&gt;
**this means seeks are two phased: first seek, find the next Kate packet, and seek again if the granule of the earlier still active packet is less than the original seeked granule. This implies support code on players to do the double seek.&lt;br /&gt;
&lt;br /&gt;
*use &amp;quot;reference frames&amp;quot;, a bit like Theora does, where the granule position is split in several fields: the higher bits represent a position for the reference frame, and the lowest bits a delta time to the current position. When seeking to a granule position, the lower bits are cleared off, yielding the granule position of the previous reference frame, so the seek ends up at the reference frame. The reference frame is a sync point where any active strings are issued again. This is a variant of the method described in the Writ wiki page, but the granule splitting avoids any &amp;quot;downtime&amp;quot;.&lt;br /&gt;
**this requires reissuing packets, and it doesn&#039;t feel right (and wastes space).&lt;br /&gt;
**it also requires &amp;quot;dummy&amp;quot; decoding of Kate data from the reference frame to the actual seek point to fully refresh the state &amp;quot;memory&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
*A variant of the two-granules-in-one system used by libcmml, where the &amp;quot;back link&amp;quot; points to the earliest still active string, rather than the previous one (this allows a two phase seek, rather than a multiphase seek, hopping back from event to event, with no real way to know if there is or not a previous event which is still active - I suppose CMML has no need to know this, if their &amp;quot;clips&amp;quot; do not overlap - mine can do).&lt;br /&gt;
**Such a system considerably shortens the usable granule space, though it can do a one phase seek, if I understand the system correctly, which I am not certain.&lt;br /&gt;
*** Well, it seems it can&#039;t do a one phase seek anyway.&lt;br /&gt;
&lt;br /&gt;
*Additionally, it could be possible to emit simple &amp;quot;keepalive&amp;quot; packets at regular intervals to help a seek algorithm to sync up to the stream without needing too much data reading - this helps for discontinuous streams where there could be no pages for a while if no data is needed at that time.&lt;br /&gt;
&lt;br /&gt;
=== Text encoding ===&lt;br /&gt;
&lt;br /&gt;
A header field declares the text encoding used in the stream. At the moment, only UTF-8 is&lt;br /&gt;
supported, for simplicity. There are no plans to support other encodings, such as UTF-16,&lt;br /&gt;
at the moment.&lt;br /&gt;
&lt;br /&gt;
Note that strings included in the header (language, category) are not affected by that&lt;br /&gt;
language encoding (rather obviously for language itself). These are ASCII.&lt;br /&gt;
&lt;br /&gt;
The actual text in events may include simple HTML-like markup (at the moment, allowed markup&lt;br /&gt;
is the same as the one Pango uses, but more markup types may be defined in the future).&lt;br /&gt;
It is also possible to ask libkate to remove this markup if the client prefers to receive&lt;br /&gt;
plain text without the markup.&lt;br /&gt;
&lt;br /&gt;
=== Language encoding ===&lt;br /&gt;
&lt;br /&gt;
A header field defines the language (if any) used in the stream (this can be overridden in a&lt;br /&gt;
data packet, but this is not relevant to this point). At the moment, my test code uses&lt;br /&gt;
ISO 639-1 two letter codes, but I originally thought to use RFC 3066 tags. However, matching&lt;br /&gt;
a language to a user selection may be simpler for user code if the language encoding is kept&lt;br /&gt;
simple. At the moment, I tend to favor allowing both two letter tags (eg, &amp;quot;en&amp;quot;) and secondary&lt;br /&gt;
tags (like &amp;quot;en_EN&amp;quot;), as RFC 3066 tags can be quite complex, but I welcome comments on this.&lt;br /&gt;
&lt;br /&gt;
If a stream contains more than one language, there usually is a predominant language, which&lt;br /&gt;
can be set as the default language for the stream. Each event can then have a language&lt;br /&gt;
override. If there is no predominant language, and it is not possible to split the stream&lt;br /&gt;
into multiple substreams, each with its own language, then it is possible to use the &amp;quot;mul&amp;quot;&lt;br /&gt;
language tag, as a last resort.&lt;br /&gt;
&lt;br /&gt;
=== Bitstream format for floating point values ===&lt;br /&gt;
&lt;br /&gt;
Floating point values are be turned to a 16.16 fixed point format, then stored in a bitpacked&lt;br /&gt;
format, storing the number of zero bits at the head and tail of the floating point values once&lt;br /&gt;
per stream, and the remainder bits for all values in the stream. This seems to yield good results&lt;br /&gt;
(typically a 50% reduction over 32 bits raw writes, and 70% over the snprintf based storage), and&lt;br /&gt;
has the big advantage of being portable (eg, independant of any IEEE format).&lt;br /&gt;
However, this means reduced precision due to the quantization to 16.16. I may add support for&lt;br /&gt;
variable precision (eg, 8.24 fixed point formats) to alleviate this. This would however mean less&lt;br /&gt;
space savings, though these are likely to be insignificant when Kate streams are interleaved with&lt;br /&gt;
a video.&lt;br /&gt;
&lt;br /&gt;
*Though this is not a Kate issue per se, the motion feature is very difficult to use without a curve editor. While tools may be coded to create a Kate bitstream for various existing subtitle formats, it is not certain it will be easy to find a good authoring tool for a series of curves. That said, it&#039;s not exactly difficult to do if you know a widget set.&lt;br /&gt;
&lt;br /&gt;
=== Higher dimensional curves/motions ===&lt;br /&gt;
&lt;br /&gt;
It is quite annoying to have to create two motions to control a color change, due to curves&lt;br /&gt;
being restricted to two dimensions. I may add support for arbitrary dimensions. It would also&lt;br /&gt;
help for 1D motions, like changing the time flow, where one coordinate is simply ignored at&lt;br /&gt;
the moment.&lt;br /&gt;
Alternatively, changes could be made to the Kate file format to hide the two dimensionality and&lt;br /&gt;
allow simpler specification of non-2 dimensional motions, but still map them to 2D in the kate&lt;br /&gt;
bitstream format.&lt;br /&gt;
&lt;br /&gt;
=== Category definition ===&lt;br /&gt;
&lt;br /&gt;
The category field in the BOS packet is a 16 byte text field (15 really, as it is zero terminated&lt;br /&gt;
in the bitstream itself). Its goal is to provide the reader with a short description of what kind&lt;br /&gt;
of information the stream contains, eg subtitles, lyrics, etc. This would be displayed to the user,&lt;br /&gt;
possibly to allow to choose to turn some streams on and off.&lt;br /&gt;
&lt;br /&gt;
Since this category is meant primarily for a machine to parse, they will be kept to ASCII. When&lt;br /&gt;
a player recognizes a category, it is free to replace its name with one in the user&#039;s language if&lt;br /&gt;
it prefers. Even in English, the &amp;quot;lyrics&amp;quot; category could be displayed by a player as &amp;quot;Lyrics&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
Since this is a free text field rather than an enumeration, it would be good to have a list of&lt;br /&gt;
common predefined category names that Kate streams can use.&lt;br /&gt;
&lt;br /&gt;
This is a list of proposed predefined categories, feedback/additions welcome:&lt;br /&gt;
&lt;br /&gt;
* subtitles - the usual movie subtitles, as text&lt;br /&gt;
* spu-subtitles - movie subtitles in DVD style paletted images&lt;br /&gt;
* lyrics - song lyrics&lt;br /&gt;
&lt;br /&gt;
Please remember the 15 character limit if proposing other categories.&lt;br /&gt;
&lt;br /&gt;
 Note that the list of categories is subject to change, and will likely&lt;br /&gt;
 be replaced by new, more &amp;quot;identifier like&amp;quot; ones. The three ones above,&lt;br /&gt;
 however, would be kept for backward compatibility as they&#039;re already used.&lt;br /&gt;
&lt;br /&gt;
== Text to speech ==&lt;br /&gt;
&lt;br /&gt;
One of the goals of the Kate bitstream format is that text data can be easily parsed&lt;br /&gt;
by the user of the decoder, so any additional information, such as style, placement,&lt;br /&gt;
karaoke data, etc, should be able to be stripped to leave only the bare text. This is&lt;br /&gt;
in view of allowing text-to-speech software to use Kate bitstreams as a bandwith-cheap&lt;br /&gt;
way of conveying speech data, and could also allow things like e-books which can be&lt;br /&gt;
either read or listened to from the same bitstream (I have seen no reference to this&lt;br /&gt;
being used anywhere, but I see no reason why the granule progression should be temporal,&lt;br /&gt;
and not user controlled, such as by using a &amp;quot;next&amp;quot; button which would bump a granule&lt;br /&gt;
postion by a preset amount, simulating turning a page (this would be close to necessary&lt;br /&gt;
for text-to-speech, as the wall time duration of the spoken speech is not known in&lt;br /&gt;
advance to the Kate encoder, and can&#039;t be mapped to a time based granule progression)).&lt;br /&gt;
All text strings triggered consecutively between the two granule positions would then&lt;br /&gt;
be read in order.&lt;br /&gt;
&lt;br /&gt;
== Possible additions ==&lt;br /&gt;
&lt;br /&gt;
=== Embedded binary data ===&lt;br /&gt;
&lt;br /&gt;
Images and font mappings can be included within a Kate stream.&lt;br /&gt;
&lt;br /&gt;
==== Images ====&lt;br /&gt;
&lt;br /&gt;
Though this could be misused to interfere with ability to render as text-to-speech, Kate&lt;br /&gt;
can use images as well as text. The same caveat as for fonts applies with regard to data&lt;br /&gt;
duplication.&lt;br /&gt;
&lt;br /&gt;
Complex images might however be best left to a multiplexed OggSpots or OggMNG stream, unless the&lt;br /&gt;
images mesh with the text (eg, graphical exclamation points, custom fonts, (see next&lt;br /&gt;
paragraph), etc).&lt;br /&gt;
&lt;br /&gt;
There is support for simple paletted bitmap images, with a variable length palette of up&lt;br /&gt;
to 256 colors (in fact, sized in powers of 2 up to 256) and matching pixel data in as&lt;br /&gt;
many bits per pixel as can address the palette. Palettes and images are stored separately,&lt;br /&gt;
so can be used with one another with no fixed assignment.&lt;br /&gt;
&lt;br /&gt;
Palettes and bitmaps are put in two separate header for later use by reference, but can&lt;br /&gt;
also be placed in data packets, as with motions, etc, if they are not going to be reused.&lt;br /&gt;
&lt;br /&gt;
PNG bitmaps can also be embedded in a Kate stream. These do not have associated palettes&lt;br /&gt;
(but the PNGs themselves may or may not be paletted). There is no support for decoding PNG&lt;br /&gt;
images in libkate itself, so a program will have to use libpng (or similar code) to decode&lt;br /&gt;
the PNG image. For instance, the libtiger rendering library uses Cairo to decode and render&lt;br /&gt;
PNG images in Kate streams.&lt;br /&gt;
&lt;br /&gt;
This can be used to have custom fonts, so that raw text is still available if the stream&lt;br /&gt;
creator wants a custom look.&lt;br /&gt;
&lt;br /&gt;
I expect that the need for more than 256 colors in a bitmap, or non palette bitmap data,&lt;br /&gt;
would be best handled by another codec, eg OggMNG or OggSpots. The goal of images in a&lt;br /&gt;
Kate stream is to mesh the images with the text, not to  have large images by themselves.&lt;br /&gt;
&lt;br /&gt;
On the other hand, interesting Karaoke effects could be achieved by having MNG images&lt;br /&gt;
instead of simple paletted bitmaps in a Kate streams. Comments would be most welcome on&lt;br /&gt;
whether this is going too far, however.&lt;br /&gt;
&lt;br /&gt;
I am also investigating SVG images. These allow for very small footprint images for simple&lt;br /&gt;
vector drawings, and could be very useful for things like background gradients below text.&lt;br /&gt;
&lt;br /&gt;
A possible solution to the duplication issue is to have another stream in the container&lt;br /&gt;
stream, which would hold the shared data (eg, fonts), which the user program could load,&lt;br /&gt;
and which could then be used by any Kate (and other) stream. Typically, this type of stream&lt;br /&gt;
would be a degenerate stream with only header packets (so it is fully processed before any&lt;br /&gt;
other stream presents data packets that might make use of that shared data), and all payload&lt;br /&gt;
such as fonts being contained within the headers. Thinking about it, it has parallels with&lt;br /&gt;
the way Vorbis stores its codebooks within a header packet, or even the way Kate stores the&lt;br /&gt;
list of styles within a header packet.&lt;br /&gt;
&lt;br /&gt;
==== Fonts ====&lt;br /&gt;
&lt;br /&gt;
Custom fonts are merely a set of ranges mapping unicode code points to bitmaps. As this implies,&lt;br /&gt;
fonts are bitmap fonts, not vector fonts, so scaling, if supported by the rendering client,&lt;br /&gt;
may not look as good as with a vector font.&lt;br /&gt;
&lt;br /&gt;
A style may also refer to a font name to use (eg, &amp;quot;Tahoma&amp;quot;). These fonts may or may not be&lt;br /&gt;
available on the playing system, however, since the font data is not included in the stream,&lt;br /&gt;
just referenced by name. For this reason, it is best to keep to widely known fonts.&lt;br /&gt;
&lt;br /&gt;
== Reference encoder/decoder ==&lt;br /&gt;
&lt;br /&gt;
A encoder (kateenc) and a decoder (katedec) are included in the tools directory.&lt;br /&gt;
The encoder supports input from several different formats:&lt;br /&gt;
* a custom text based file format (see [[#The Kate file format|The Kate file format]]), which is by no means meant to be part of the Kate bitstream specification itself&lt;br /&gt;
* SubRip (.srt), the most common subtitle format I found&lt;br /&gt;
* LRC lyrics format.&lt;br /&gt;
&lt;br /&gt;
As an example for the widely used SRT subtitles format, the following command line&lt;br /&gt;
create a Kate subtitles stream from an SRT file:&lt;br /&gt;
&lt;br /&gt;
kateenc -l en -c subtitles -t srt -o subtites.ogg subtitles.srt&lt;br /&gt;
&lt;br /&gt;
The reverse is possible, to recover an SRT file from a Kate stream, with katedec.&lt;br /&gt;
&lt;br /&gt;
Note that the subtitles.ogg file should then be multiplexed into the A/V stream,&lt;br /&gt;
using either ogg-tools or oggz-tools.&lt;br /&gt;
&lt;br /&gt;
The Kate bitstreams encoded and decoded by those tools are (supposed to be) correct for this&lt;br /&gt;
specification, provided their input is correct.&lt;br /&gt;
&lt;br /&gt;
== Next steps ==&lt;br /&gt;
&lt;br /&gt;
=== Continuations ===&lt;br /&gt;
&lt;br /&gt;
Continuations are a way to add to existing events, and are mostly meant for motions. When streaming&lt;br /&gt;
in real time, what motions may be applied to events may not be known in advance (for instance, for a&lt;br /&gt;
draw chat program where two programs exchange Kate streams, the drawing motions are only known as&lt;br /&gt;
they are drawn. Continuations will allow an event to be extended in time, and motions to be appended&lt;br /&gt;
to it. This is only useful for streaming, as when stored in a file, everything is already known in&lt;br /&gt;
advance.&lt;br /&gt;
&lt;br /&gt;
=== A rendering library ===&lt;br /&gt;
&lt;br /&gt;
This will allow easier integration in other packages (movie players, etc).&lt;br /&gt;
I have started working on an implementation using Cairo and Pango, though I&#039;m still at the early stages.&lt;br /&gt;
I might add support for embedding vector fonts in a Kate stream if I was going that way. Still need to think about this.&lt;br /&gt;
Another point of note is that when this library is available, it would make it easier to add&lt;br /&gt;
capabilities such as rotation, scaling, etc, to the bitstream, since this would not cause too&lt;br /&gt;
much work for playing programs using the rendering library. It is expected that these additions&lt;br /&gt;
would stay backward compatible (eg, an old player would ignore this information but still correctly&lt;br /&gt;
decode the information they can work with from a newly encoded stream).&lt;br /&gt;
&lt;br /&gt;
=== An XML representation ===&lt;br /&gt;
&lt;br /&gt;
While I purposefully did not write Kate description files in XML due to me finding editing XML such&lt;br /&gt;
a chore, it would be nice to be able to losslessly convert between the more user friendly representation&lt;br /&gt;
and an XML document, so one can do what one does with XML documents, like transformations.&lt;br /&gt;
&lt;br /&gt;
And after all, some people might prefer editing the XML version.&lt;br /&gt;
&lt;br /&gt;
=== Packaging ===&lt;br /&gt;
&lt;br /&gt;
It would be really nice to have packages for libkate/libtiger for many distros.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re a packager for a distro which doesn&#039;t have yet packages for libkate&lt;br /&gt;
or libtiger, please consider helping :)&lt;br /&gt;
&lt;br /&gt;
In particular, packages for Debian would be grand.&lt;br /&gt;
&lt;br /&gt;
== Matroska mapping ==&lt;br /&gt;
&lt;br /&gt;
The codec ID is &amp;quot;S_KATE&amp;quot;.&lt;br /&gt;
&lt;br /&gt;
As for Theora and Vorbis, Kate headers are stored in the private data as xiph-laced packets:&lt;br /&gt;
&lt;br /&gt;
 Byte 0: number of packets present, minus 1 (there must be at least one packet) - let this number be NP&lt;br /&gt;
 Bytes 1..n: lengths of the first NP packets, coded in xiph style lacing&lt;br /&gt;
 Bytes n+1..end: the data packets themselves concatenated one after the other&lt;br /&gt;
&lt;br /&gt;
Note that the length of the last packet isn&#039;t encoded, it is deduced from the sizes of the other&lt;br /&gt;
packets and the total size of the private data.&lt;br /&gt;
&lt;br /&gt;
This mapping is similar to the Vorbis and Theora mappings, with the caveat that one should not&lt;br /&gt;
expect a set number of headers.&lt;br /&gt;
&lt;br /&gt;
== Downloading ==&lt;br /&gt;
&lt;br /&gt;
libkate encodes and decodes Kate streams, and is API and ABI stable.&lt;br /&gt;
&lt;br /&gt;
The libkate source distribution is available at [https://code.google.com/archive/p/libkate/ https://code.google.com/archive/p/libkate/].&lt;br /&gt;
&lt;br /&gt;
A public git repository is available at [https://gitlab.xiph.org/xiph/kate https://gitlab.xiph.org/xiph/kate].&lt;br /&gt;
&lt;br /&gt;
libtiger renders Kate streams using Pango and Cairo, and is alpha, with API changes still possible.&lt;br /&gt;
&lt;br /&gt;
The libtiger source distribution is available at [https://code.google.com/archive/p/libtiger/ https://code.google.com/archive/p/libtiger/].&lt;br /&gt;
&lt;br /&gt;
== HOWTOs ==&lt;br /&gt;
&lt;br /&gt;
These paragraphs describe a few ways to use Kate streams:&lt;br /&gt;
&lt;br /&gt;
=== Text movie subtitles ===&lt;br /&gt;
&lt;br /&gt;
Kate streams can carry Unicode text (that is, text that can represent&lt;br /&gt;
pretty much any existing language/script). If several Kate streams are&lt;br /&gt;
multiplexed along with a video, subtitles in various languages can be&lt;br /&gt;
made for that movie.&lt;br /&gt;
&lt;br /&gt;
An easy way to create such subtitles is to use ffmpeg2theora, which&lt;br /&gt;
can create Kate streams from SubRip (.srt) format files, a simple but&lt;br /&gt;
common text subtitles format. ffmpeg2theora 0.21 or later is needed.&lt;br /&gt;
&lt;br /&gt;
At its simplest:&lt;br /&gt;
&lt;br /&gt;
    ffmpeg2theora -o video-with-subtitles.ogg --subtitles subtitles.srt&lt;br /&gt;
      video-without-subtitles.avi&lt;br /&gt;
&lt;br /&gt;
Several languages may be created and tagged with their language code&lt;br /&gt;
for easy selection in a media player:&lt;br /&gt;
&lt;br /&gt;
    ffmpeg2theora -o video-with-subtitles.ogg video-without-subtitles.avi&lt;br /&gt;
      --subtitles japanese-subtitles.srt --subtitles-language ja&lt;br /&gt;
      --subtitles welsh-subtitles.srt --subtitles-language cy&lt;br /&gt;
      --subtitles english-subtitles.srt --subtitles-language en_GB&lt;br /&gt;
&lt;br /&gt;
Alternatively, kateenc (which comes with the libkate distribution) can&lt;br /&gt;
create Kate streams from SubRip files as well. These can then be merged&lt;br /&gt;
with a video with oggz-tools:&lt;br /&gt;
&lt;br /&gt;
    kateenc -t srt -c SUB -l it -o subtitles.ogg italian-subtitles.srt&lt;br /&gt;
    oggz merge -o movie-with-subtitles.ogg movie-without-subtitles.ogg subtitles.ogg&lt;br /&gt;
&lt;br /&gt;
This second method can also be used to add subtitles to a video which&lt;br /&gt;
is already encoded to Theora, as it will not transcode the video again.&lt;br /&gt;
&lt;br /&gt;
=== DVD subtitles ===&lt;br /&gt;
&lt;br /&gt;
DVD subtitles are not text, but images. Thoggen, a DVD ripper program,&lt;br /&gt;
can convert these subtitles to Kate streams (at the time of writing,&lt;br /&gt;
Thoggen and GStreamer have not applied the necessary patches for this&lt;br /&gt;
to be possible out of the box, so patching them will be required).&lt;br /&gt;
&lt;br /&gt;
When configuring how to rip DVD tracks, any subtitles will be detected&lt;br /&gt;
by Thoggen, and selecting them in the GUI will cause them to be saved as&lt;br /&gt;
Kate tracks along with the movie.&lt;br /&gt;
&lt;br /&gt;
=== Song lyrics ===&lt;br /&gt;
&lt;br /&gt;
Kate streams carrying song lyrics can be embedded in an Ogg file. The&lt;br /&gt;
oggenc Vorbis encoding tool from the Xiph.Org Vorbis tools allows lyrics&lt;br /&gt;
to be loaded from a LRC or SRT text file and converted to a Kate stream&lt;br /&gt;
multiplexed with the resulting Vorbis audio. At the time of writing,&lt;br /&gt;
the patch to oggenc was not applied yet, so it will have to be patched&lt;br /&gt;
manually with the patch found in the diffs directory.&lt;br /&gt;
&lt;br /&gt;
    oggenc -o song-with-lyrics.ogg --lyrics lyrics.lrc --lyrics-language en_US song.wav&lt;br /&gt;
&lt;br /&gt;
So called &#039;enhanced LRC&#039; files (containing extra karaoke timing information)&lt;br /&gt;
are supported, and a simple karaoke color change scheme will be saved&lt;br /&gt;
out for these files. For more complex karaoke effects (such as more&lt;br /&gt;
complex style changes, or sprite animation), kateenc should be used with&lt;br /&gt;
a Kate description file to create a separate Kate stream, which can then&lt;br /&gt;
be merged with a Vorbis only song with oggz-tools:&lt;br /&gt;
&lt;br /&gt;
    oggenc -o song.ogg song.wav&lt;br /&gt;
    kateenc -t kate -c LRC -l en_US -o lyrics.ogg lyrics-with-karaoke.kate&lt;br /&gt;
    oggz merge -o song-with-karaoke.ogg lyrics-with-karaoke.ogg song.ogg&lt;br /&gt;
&lt;br /&gt;
This latter method may also be used if you already have an encoded Vorbis song&lt;br /&gt;
with no lyrics, and just want to add the lyrics without reencoding.&lt;br /&gt;
&lt;br /&gt;
=== Metadata ===&lt;br /&gt;
&lt;br /&gt;
Metadata can be attached to events, or to styles, bitmaps, regions, etc.&lt;br /&gt;
Metadata are free form tag/value pairs, and can be used to enrich their&lt;br /&gt;
attached data with extra information. However, how this information is&lt;br /&gt;
interpreted is up to the application layer.&lt;br /&gt;
&lt;br /&gt;
It is worth noting that an event may not have attached text, so it is&lt;br /&gt;
possible to create an empty timed event with attached metadata.&lt;br /&gt;
&lt;br /&gt;
For instance, let&#039;s say we have a documentary, with footage from various&lt;br /&gt;
places, as well as short interviews, and we want two things:&lt;br /&gt;
- tag footage with metadata about the location and date that footage was shot&lt;br /&gt;
- subtitle the interviews and tag those subtitles with information about the speaker&lt;br /&gt;
&lt;br /&gt;
You can then create an empty Kate event for each footage part, synchronized&lt;br /&gt;
with the footage, and attach a new metadata item called GEO_LOCATION, filled&lt;br /&gt;
with latitude and longitude of the place the footage was shot at.&lt;br /&gt;
Similarly, for each subtitle event, a metadata item called SPEAKER can be&lt;br /&gt;
attached.&lt;br /&gt;
&lt;br /&gt;
An empty event to tag a long 4:20 footage shot in Tokyo on 2011/08/12, and&lt;br /&gt;
inserted at 18:30 in the documentary could look like:&lt;br /&gt;
&lt;br /&gt;
  event {&lt;br /&gt;
    00:18:30,000 --&amp;gt; 00:22:50,000&lt;br /&gt;
    meta &amp;quot;GEO_LOCATION&amp;quot; = &amp;quot;35.42; 139.42&amp;quot;&lt;br /&gt;
    meta &amp;quot;DATE&amp;quot; = &amp;quot;2011-08-12&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Here&#039;s a example for a line spoken by Dr Joe Bloggs at 18:30 into the documentary:&lt;br /&gt;
&lt;br /&gt;
  event {&lt;br /&gt;
    00:18:30,000 --&amp;gt; 00:18:32,000&lt;br /&gt;
    &amp;quot;Notice how the subtitles for my words have metadata attached to them&amp;quot;&lt;br /&gt;
    meta &amp;quot;SPEAKER&amp;quot; = &amp;quot;Dr Joe Bloggs&amp;quot;&lt;br /&gt;
    meta &amp;quot;URL&amp;quot; = &amp;quot;http://www.example.com/biography?name=Joe+Bloggs&amp;quot;&lt;br /&gt;
  }&lt;br /&gt;
&lt;br /&gt;
Notice how another metadata item, URL, is also present. The application&lt;br /&gt;
will have to be aware of those metadata in order to do something with it&lt;br /&gt;
though. Since those are free form, it is up to you to think of what&lt;br /&gt;
metadata you want, and make use of it.&lt;br /&gt;
&lt;br /&gt;
Note that metadata may be attached to other objects, such as regions.&lt;br /&gt;
This way, you can for example create a region tagged with a name, and&lt;br /&gt;
track a person&#039;s movements with that region. Or you can tag a bitmap&lt;br /&gt;
with a copyright and a URL to a larger version of the image.&lt;br /&gt;
&lt;br /&gt;
=== Changing a Kate stream embedded in an Ogg stream ===&lt;br /&gt;
&lt;br /&gt;
If you need to change a Kate stream already embedded in an Ogg stream (eg, you have a movie with subtitles, and you want to fix a spelling mistake, or want to bring one of the subtitles forward in time, etc), you can do this easily with KateDJ, a tool that will extract Kate streams, decode them to a temporary location, and rebuild the original stream after you&#039;ve made whatever changes you want.&lt;br /&gt;
&lt;br /&gt;
KateDJ (included with the libkate distribution) is a GUI program using wxPython, a Python module for the wxWidgets GUI library, and the oggz tools (both needing installing separately if they are not already).&lt;br /&gt;
&lt;br /&gt;
The procedure consists of:&lt;br /&gt;
&lt;br /&gt;
* Run KateDJ&lt;br /&gt;
* Click &#039;Load Ogg stream&#039; and select the file to load&lt;br /&gt;
* Click &#039;Demux file&#039; to decode Kate streams in a temporary location&lt;br /&gt;
* Edit the Kate streams (a message box tells you where they are placed)&lt;br /&gt;
* When done, click &#039;Remux file from parts&#039;&lt;br /&gt;
* If any errors are reported, continue editing until the remux step succeeds&lt;br /&gt;
&lt;br /&gt;
== Frequently Asked Questions ==&lt;br /&gt;
&lt;br /&gt;
=== Does libkate work on other plaforms than Linux ? ===&lt;br /&gt;
&lt;br /&gt;
Yes, libkate is not Linux specific in any way. It optionally relies on libogg&lt;br /&gt;
and libpng, two libraries widely ported to various platforms.&lt;br /&gt;
It has been reported to work on Windows and MacOS X as well as UNIX platforms.&lt;br /&gt;
&lt;br /&gt;
However, libtiger, a rendering library for Kate streams, relies on [http://www.pango.org/ Pango] and [https://www.cairographics.org/ Cairo],&lt;br /&gt;
which are not easy to build on Windows, though they can be.&lt;br /&gt;
The Tiger renderer is however completely separate from libkate, and is not needed&lt;br /&gt;
for full encoding and decoding of Kate streams.&lt;br /&gt;
&lt;br /&gt;
=== Where can I find some example files ? ===&lt;br /&gt;
&lt;br /&gt;
The libkate distribution can generate various examples, but already built files&lt;br /&gt;
can be found there:&lt;br /&gt;
[http://people.xiph.org/~oggk/elephants_dream/elephantsdream-with-subtitles.ogg]&lt;br /&gt;
[http://stallman.org/fry/Stephen_Fry-Happy_Birthday_GNU-nq_600px_425kbit.ogv]&lt;br /&gt;
&lt;br /&gt;
These files use raw text only.&lt;br /&gt;
&lt;br /&gt;
[[Category:Ogg Mappings]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusContributing&amp;diff=16688</id>
		<title>OpusContributing</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusContributing&amp;diff=16688"/>
		<updated>2018-09-26T03:41:30Z</updated>

		<summary type="html">&lt;p&gt;MarkH: /* How to report bugs */ trac issues have been migrated to gitlab.xiph.org&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Community ==&lt;br /&gt;
&lt;br /&gt;
Development discussions and questions take place on the Xiph.Org Opus mailing list ([mailto:opus@xiph.org opus@xiph.org]).&lt;br /&gt;
&lt;br /&gt;
Discussions related to the IETF process happen on the IETF codec working group mailing list ([mailto:codec@ietf.org codec@ietf.org]).&lt;br /&gt;
&lt;br /&gt;
For archives of recent discussions, try:&lt;br /&gt;
&lt;br /&gt;
* Xiph.Org [http://lists.xiph.org/pipermail/opus/ Opus mailing list archives]&lt;br /&gt;
* IETF [https://www.ietf.org/mail-archive/web/codec/current/maillist.html codec mailing list archives]&lt;br /&gt;
&lt;br /&gt;
Informal development chat and support happens in #opus on irc.freenode.net. You can join the chat room through a &#039;&#039;&#039;[https://webchat.freenode.net/ web interface]&#039;&#039;&#039; if you don&#039;t have an IRC client.&lt;br /&gt;
&lt;br /&gt;
== How To Contribute ==&lt;br /&gt;
&lt;br /&gt;
There are many ways to contribute to Opus development:&lt;br /&gt;
&lt;br /&gt;
* Reporting and fixing bugs&lt;br /&gt;
* Improving tools&lt;br /&gt;
* Improving testing framework - see the &#039;&#039;&#039;[https://github.com/xiph/opus/tree/master/tests test code]&#039;&#039;&#039; and the &#039;&#039;&#039;[[Opus_testvectors|Opus Test Vectors]]&#039;&#039;&#039; page&lt;br /&gt;
* Optimizations (assembly/intrinsics)&lt;br /&gt;
* Encoding quality improvements - see the &#039;&#039;&#039;[[Opus tuning]]&#039;&#039;&#039; page for suggestions&lt;br /&gt;
* Mapping to new containers - see Opus within &#039;&#039;&#039;[[MatroskaOpus|Matroska]]&#039;&#039;&#039;, &#039;&#039;&#039;[[Mp4Opus|MP4]]&#039;&#039;&#039;, &#039;&#039;&#039;[[OpusTS|Mpeg-TS]]&#039;&#039;&#039; and &#039;&#039;&#039;[[OggOpus|Ogg]]&#039;&#039;&#039; containers (Ogg spec is on Standards Track as &#039;&#039;&#039;[https://tools.ietf.org/html/rfc7845 RFC 7845]&#039;&#039;&#039;).&lt;br /&gt;
&lt;br /&gt;
It is generally advisable to contact the developers on the mailing list or the IRC channel before taking on new work on Opus,&lt;br /&gt;
to avoid duplicating work and to make sure you&#039;re doing things the right way from the start.&lt;br /&gt;
&lt;br /&gt;
== How to report bugs ==&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;[https://gitlab.xiph.org/ Xiph.Org GitLab]&#039;&#039;&#039; may be used to report bugs in [https://gitlab.xiph.org/xiph/opus/issues opus], [https://gitlab.xiph.org/xiph/opusfile/issues opusfile], [https://gitlab.xiph.org/xiph/libopusenc/issues libopusenc], or [https://gitlab.xiph.org/xiph/opus-tools/issues opus-tools]. Please also notify developers on the [mailto:opus@xiph.org mailing list].&lt;br /&gt;
&lt;br /&gt;
For sensitive (security-related) bugs, please &#039;&#039;&#039;[https://www.opus-codec.org/contact/ contact the developers]&#039;&#039;&#039; directly.&lt;br /&gt;
&lt;br /&gt;
== How to submit a patch ==&lt;br /&gt;
&lt;br /&gt;
If you have a patch you would like to contribute, just send it to the mailing list.&lt;br /&gt;
We can also take [https://github.com/xiph/opus/ Github] pull requests,&lt;br /&gt;
but please send a note to the mailing list since the GitHub Opus repository is only a mirror.&lt;br /&gt;
&lt;br /&gt;
== Coding style ==&lt;br /&gt;
&lt;br /&gt;
Opus is the result of merging three different codebases and therefore does not&lt;br /&gt;
have a consistent coding style. For example, the SILK code uses 4-space&lt;br /&gt;
indentation, while the rest of the code is mostly 3-space, except the entropy&lt;br /&gt;
coder, which is 2-space.&lt;br /&gt;
&lt;br /&gt;
The general rule is that you should follow the style of the code you&#039;re modifying.&lt;br /&gt;
* &#039;&#039;&#039;Do not&#039;&#039;&#039; reformat the code in your &amp;quot;functional change&amp;quot; patches, as it mostly makes it harder to review changes.&lt;br /&gt;
* &#039;&#039;&#039;Do&#039;&#039;&#039; send separate &amp;quot;format-fixing&amp;quot; patches, making sure they don&#039;t change Opus&#039; functionality at all.&lt;br /&gt;
&lt;br /&gt;
== Testing ==&lt;br /&gt;
&lt;br /&gt;
For any new feature, it is strongly suggested to also include tests for the new code to make sure it works and keeps working in the future.&lt;br /&gt;
&lt;br /&gt;
== Language ==&lt;br /&gt;
&lt;br /&gt;
Opus only requires a C89 compiler, so any use of C99 and later constructs has&lt;br /&gt;
to be optional (e.g. OPUS_INLINE). This is also why we do not use C++-style&lt;br /&gt;
// comments.&lt;br /&gt;
&lt;br /&gt;
To reduce the risk of exploitable memory errors, we do not use any function&lt;br /&gt;
pointers in the code unless they are declared as static const. We also&lt;br /&gt;
have &amp;quot;flat&amp;quot; objects, which can be copied using a &amp;quot;shallow copy&amp;quot;, so do not add&lt;br /&gt;
pointers to non-static data in the data structures.&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=Opus_Recommended_Settings&amp;diff=16495</id>
		<title>Opus Recommended Settings</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=Opus_Recommended_Settings&amp;diff=16495"/>
		<updated>2016-11-08T15:08:25Z</updated>

		<summary type="html">&lt;p&gt;MarkH: /* Recommended Bitrates */ FLAC supports only 1-8 channels&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Recommended Bitrates =&lt;br /&gt;
Depending on the kind of audio you want to encode with Opus, you may want to use different bitrate (quality) settings.&lt;br /&gt;
&lt;br /&gt;
The settings in the table below are meant to &#039;&#039;&#039;start you off&#039;&#039;&#039; with a decent tradeoff between &#039;&#039;&#039;good quality&#039;&#039;&#039; and &#039;&#039;&#039;small file size&#039;&#039;&#039; (or &#039;&#039;&#039;bitrate usage&#039;&#039;&#039;, if you&#039;re streaming).&lt;br /&gt;
&lt;br /&gt;
You should test the suggested bitrate by actually &#039;&#039;&#039;listening&#039;&#039;&#039; to your encoded audio and then tweaking the bitrate:&lt;br /&gt;
* &#039;&#039;&#039;down&#039;&#039;&#039; if you think the quality is good, but the file size (or bitrate) is too big&lt;br /&gt;
* &#039;&#039;&#039;up&#039;&#039;&#039; if you think the quality is bad, and you can afford having bigger files (or a larger streaming bitrate)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Use Case&lt;br /&gt;
!Channels&lt;br /&gt;
!Bitrate (Kb/s)&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
|Low bandwidth HF/VHF digital radio&lt;br /&gt;
|1 (mono)&lt;br /&gt;
|use &#039;&#039;&#039;[http://www.rowetel.com/?page_id=452 Codec&amp;amp;nbsp;2]&#039;&#039;&#039;&lt;br /&gt;
|Opus only supports bitrates down to 6&amp;amp;nbsp;Kb/s. Codec 2 handles ultra low bitrate speech from 0.7 to 3.2&amp;amp;nbsp;Kb/s.&lt;br /&gt;
|-&lt;br /&gt;
|VoIP&lt;br /&gt;
|1&lt;br /&gt;
|10-24&lt;br /&gt;
|10&amp;amp;nbsp;Kb/s will deliver narrowband most of the time, 24&amp;amp;nbsp;Kb/s should give fullband.&amp;lt;br&amp;gt;More details in &#039;&#039;&#039;[[Opus_Recommended_Settings#Bandwidth_Transition_Thresholds|the relevant table]]&#039;&#039;&#039; further down this page.&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|Audiobooks / Podcasts&lt;br /&gt;
|1&lt;br /&gt;
|24&lt;br /&gt;
|bitrates from here on up tend to deliver fullband audio.&lt;br /&gt;
|-&lt;br /&gt;
|2 (stereo)&lt;br /&gt;
|32&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Music Streaming / Radio&lt;br /&gt;
|2&lt;br /&gt;
|64-96&lt;br /&gt;
|Opus has better quality than MP3, AAC and [[Vorbis]] at these rates.&amp;lt;br&amp;gt;(test results &#039;&#039;&#039;[http://listening-tests.hydrogenaud.io/igorc/results.html here]&#039;&#039;&#039; and &#039;&#039;&#039;[http://listening-test.coresv.net/results.htm here]&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;3&amp;quot;|Music Storage&lt;br /&gt;
|2&lt;br /&gt;
|96-128&lt;br /&gt;
|Opus at 128&amp;amp;nbsp;KB/s (VBR) is pretty much &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Transparency_(data_compression) transparent]&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|6 (5.1 surround)&lt;br /&gt;
|128-256&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|for surround sound, Opus uses &#039;&#039;&#039;[https://xiph.org/~xiphmont/demo/opus/demo3.shtml surround-sound bitrate allocation]&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|8 (7.1 surround)&lt;br /&gt;
|256-450&lt;br /&gt;
|-&lt;br /&gt;
|Music Archiving&lt;br /&gt;
|1-8&lt;br /&gt;
|use &#039;&#039;&#039;[[FLAC]]&#039;&#039;&#039;&lt;br /&gt;
|if you are archiving audio, use a &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Audio_file_format#Lossless_compressed_audio_format lossless audio format]&#039;&#039;&#039; to prevent &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Generation_loss generation loss]&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Technical Details =&lt;br /&gt;
For the more technical Opus users, here are some details to help you fine-tune your decision on which bitrate best fits your needs.&lt;br /&gt;
&lt;br /&gt;
== Mono or Stereo ==&lt;br /&gt;
Opus tends to start &#039;&#039;&#039;downmixing stereo inputs to mono&#039;&#039;&#039; from roughly &#039;&#039;&#039;24&amp;amp;nbsp;Kb/s and lower&#039;&#039;&#039;.&lt;br /&gt;
You can check the details in the &#039;&#039;&#039;[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L148 opus_encoder.c]&#039;&#039;&#039; source file.&lt;br /&gt;
&lt;br /&gt;
You can force downmixing at any bitrate by using the following command-line parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--downmix-mono&amp;lt;/code&amp;gt; - downmixes all input channels to mono&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--downmix-stereo&amp;lt;/code&amp;gt; - downmixes all input channels to stereo (if there are more than 2 input channels, e.g. surround sound)&lt;br /&gt;
&lt;br /&gt;
== Bandwidth Transition Thresholds ==&lt;br /&gt;
The following table shows rough bitrates that you might want to use to encode audio that has &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2 limited frequency bandwidths]&#039;&#039;&#039;.&lt;br /&gt;
This could be useful if your audio has already been bandpassed, or should go through a bandpass filter (e.g. VoIP speech).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|(bitrates in&amp;amp;nbsp;Kb/s)&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Mono&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Stereo&lt;br /&gt;
|-&lt;br /&gt;
!Voice&lt;br /&gt;
!Music&lt;br /&gt;
!Voice&lt;br /&gt;
!Music&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-4000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;NarrowBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|12&lt;br /&gt;
|15&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-6000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;MediumBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|15&lt;br /&gt;
|18-22&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-8000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;WideBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|16-20&lt;br /&gt;
|22-28&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-12000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;SuperWideBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|24-28&lt;br /&gt;
|28-32&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-20000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;FullBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|28-40&lt;br /&gt;
|32-64&lt;br /&gt;
|32-64&lt;br /&gt;
|64-128&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The details of Opus&#039; bandpass thresholds can be found in the &#039;&#039;&#039;[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L121 opus_encoder.c]&#039;&#039;&#039; source file.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;[http://wiki.hydrogenaud.io/index.php?title=Opus HydrogenAudio]&#039;&#039;&#039; wiki also has some great information on Opus and its usage.&lt;br /&gt;
&lt;br /&gt;
== Framesize Tweaking ==&lt;br /&gt;
Opus can encode frames of &#039;&#039;&#039;2.5&#039;&#039;&#039;, &#039;&#039;&#039;5&#039;&#039;&#039;, &#039;&#039;&#039;10&#039;&#039;&#039;, &#039;&#039;&#039;20&#039;&#039;&#039;, &#039;&#039;&#039;40&#039;&#039;&#039;, or &#039;&#039;&#039;60&amp;amp;nbsp;ms&#039;&#039;&#039;.  It can also combine multiple frames into packets of &#039;&#039;&#039;up to 120&amp;amp;nbsp;ms&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Opus uses a &#039;&#039;&#039;20&amp;amp;nbsp;ms&#039;&#039;&#039; frame size &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2.1.4 by default]&#039;&#039;&#039;, as it gives a decent mix of low latency and good quality.&lt;br /&gt;
&lt;br /&gt;
For real-time applications, sending fewer packets per second reduces the overall bitrate, since it reduces the overhead from &#039;&#039;&#039;[https://en.wikipedia.org/wiki/IPv6_packet#Fixed_header IP]&#039;&#039;&#039;, &#039;&#039;&#039;[https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure UDP]&#039;&#039;&#039;, and &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Real-time_Transport_Protocol#Packet_header RTP headers]&#039;&#039;&#039;.&lt;br /&gt;
However, it increases latency and sensitivity to packet losses, as losing one packet constitutes a loss of a bigger chunk of audio.&lt;br /&gt;
Increasing the frame duration also slightly improves coding efficiency, but the gain becomes small for frame sizes above 20&amp;amp;nbsp;ms.&lt;br /&gt;
&lt;br /&gt;
For these reasons, the default 20&amp;amp;nbsp;ms frames are a good choice for most applications.&lt;br /&gt;
&lt;br /&gt;
== Trading Coding Efficiency with CPU Time ==&lt;br /&gt;
The Opus encoder uses its maximum algorithmic &#039;&#039;&#039;complexity&#039;&#039;&#039; setting of &#039;&#039;&#039;10&#039;&#039;&#039; &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2.1.5 by default]&#039;&#039;&#039;. This means that it does not hesitate to use CPU to give you the best quality encoding at a given bitrate.&lt;br /&gt;
&lt;br /&gt;
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 &#039;&#039;&#039;10&#039;&#039;&#039; (highest CPU usage and quality) down to &#039;&#039;&#039;0&#039;&#039;&#039; (lowest CPU usage and quality).&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=Opus_Recommended_Settings&amp;diff=16494</id>
		<title>Opus Recommended Settings</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=Opus_Recommended_Settings&amp;diff=16494"/>
		<updated>2016-11-08T15:03:37Z</updated>

		<summary type="html">&lt;p&gt;MarkH: /* Recommended Bitrates */ fix Codec2 URL, and clarify: not all ham radio uses want ultra low bitrate&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Recommended Bitrates =&lt;br /&gt;
Depending on the kind of audio you want to encode with Opus, you may want to use different bitrate (quality) settings.&lt;br /&gt;
&lt;br /&gt;
The settings in the table below are meant to &#039;&#039;&#039;start you off&#039;&#039;&#039; with a decent tradeoff between &#039;&#039;&#039;good quality&#039;&#039;&#039; and &#039;&#039;&#039;small file size&#039;&#039;&#039; (or &#039;&#039;&#039;bitrate usage&#039;&#039;&#039;, if you&#039;re streaming).&lt;br /&gt;
&lt;br /&gt;
You should test the suggested bitrate by actually &#039;&#039;&#039;listening&#039;&#039;&#039; to your encoded audio and then tweaking the bitrate:&lt;br /&gt;
* &#039;&#039;&#039;down&#039;&#039;&#039; if you think the quality is good, but the file size (or bitrate) is too big&lt;br /&gt;
* &#039;&#039;&#039;up&#039;&#039;&#039; if you think the quality is bad, and you can afford having bigger files (or a larger streaming bitrate)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Use Case&lt;br /&gt;
!Channels&lt;br /&gt;
!Bitrate (Kb/s)&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
|Low bandwidth HF/VHF digital radio&lt;br /&gt;
|1 (mono)&lt;br /&gt;
|use &#039;&#039;&#039;[http://www.rowetel.com/?page_id=452 Codec&amp;amp;nbsp;2]&#039;&#039;&#039;&lt;br /&gt;
|Opus only supports bitrates down to 6&amp;amp;nbsp;Kb/s. Codec 2 handles ultra low bitrate speech from 0.7 to 3.2&amp;amp;nbsp;Kb/s.&lt;br /&gt;
|-&lt;br /&gt;
|VoIP&lt;br /&gt;
|1&lt;br /&gt;
|10-24&lt;br /&gt;
|10&amp;amp;nbsp;Kb/s will deliver narrowband most of the time, 24&amp;amp;nbsp;Kb/s should give fullband.&amp;lt;br&amp;gt;More details in &#039;&#039;&#039;[[Opus_Recommended_Settings#Bandwidth_Transition_Thresholds|the relevant table]]&#039;&#039;&#039; further down this page.&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|Audiobooks / Podcasts&lt;br /&gt;
|1&lt;br /&gt;
|24&lt;br /&gt;
|bitrates from here on up tend to deliver fullband audio.&lt;br /&gt;
|-&lt;br /&gt;
|2 (stereo)&lt;br /&gt;
|32&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Music Streaming / Radio&lt;br /&gt;
|2&lt;br /&gt;
|64-96&lt;br /&gt;
|Opus has better quality than MP3, AAC and [[Vorbis]] at these rates.&amp;lt;br&amp;gt;(test results &#039;&#039;&#039;[http://listening-tests.hydrogenaud.io/igorc/results.html here]&#039;&#039;&#039; and &#039;&#039;&#039;[http://listening-test.coresv.net/results.htm here]&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;3&amp;quot;|Music Storage&lt;br /&gt;
|2&lt;br /&gt;
|96-128&lt;br /&gt;
|Opus at 128&amp;amp;nbsp;KB/s (VBR) is pretty much &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Transparency_(data_compression) transparent]&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|6 (5.1 surround)&lt;br /&gt;
|128-256&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|for surround sound, Opus uses &#039;&#039;&#039;[https://xiph.org/~xiphmont/demo/opus/demo3.shtml surround-sound bitrate allocation]&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|8 (7.1 surround)&lt;br /&gt;
|256-450&lt;br /&gt;
|-&lt;br /&gt;
|Music Archiving&lt;br /&gt;
|any&lt;br /&gt;
|use &#039;&#039;&#039;[[FLAC]]&#039;&#039;&#039;&lt;br /&gt;
|if you are archiving audio, use a &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Audio_file_format#Lossless_compressed_audio_format lossless audio format]&#039;&#039;&#039; to prevent &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Generation_loss generation loss]&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Technical Details =&lt;br /&gt;
For the more technical Opus users, here are some details to help you fine-tune your decision on which bitrate best fits your needs.&lt;br /&gt;
&lt;br /&gt;
== Mono or Stereo ==&lt;br /&gt;
Opus tends to start &#039;&#039;&#039;downmixing stereo inputs to mono&#039;&#039;&#039; from roughly &#039;&#039;&#039;24&amp;amp;nbsp;Kb/s and lower&#039;&#039;&#039;.&lt;br /&gt;
You can check the details in the &#039;&#039;&#039;[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L148 opus_encoder.c]&#039;&#039;&#039; source file.&lt;br /&gt;
&lt;br /&gt;
You can force downmixing at any bitrate by using the following command-line parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--downmix-mono&amp;lt;/code&amp;gt; - downmixes all input channels to mono&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--downmix-stereo&amp;lt;/code&amp;gt; - downmixes all input channels to stereo (if there are more than 2 input channels, e.g. surround sound)&lt;br /&gt;
&lt;br /&gt;
== Bandwidth Transition Thresholds ==&lt;br /&gt;
The following table shows rough bitrates that you might want to use to encode audio that has &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2 limited frequency bandwidths]&#039;&#039;&#039;.&lt;br /&gt;
This could be useful if your audio has already been bandpassed, or should go through a bandpass filter (e.g. VoIP speech).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|(bitrates in&amp;amp;nbsp;Kb/s)&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Mono&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Stereo&lt;br /&gt;
|-&lt;br /&gt;
!Voice&lt;br /&gt;
!Music&lt;br /&gt;
!Voice&lt;br /&gt;
!Music&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-4000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;NarrowBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|12&lt;br /&gt;
|15&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-6000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;MediumBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|15&lt;br /&gt;
|18-22&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-8000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;WideBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|16-20&lt;br /&gt;
|22-28&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-12000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;SuperWideBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|24-28&lt;br /&gt;
|28-32&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-20000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;FullBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|28-40&lt;br /&gt;
|32-64&lt;br /&gt;
|32-64&lt;br /&gt;
|64-128&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The details of Opus&#039; bandpass thresholds can be found in the &#039;&#039;&#039;[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L121 opus_encoder.c]&#039;&#039;&#039; source file.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;[http://wiki.hydrogenaud.io/index.php?title=Opus HydrogenAudio]&#039;&#039;&#039; wiki also has some great information on Opus and its usage.&lt;br /&gt;
&lt;br /&gt;
== Framesize Tweaking ==&lt;br /&gt;
Opus can encode frames of &#039;&#039;&#039;2.5&#039;&#039;&#039;, &#039;&#039;&#039;5&#039;&#039;&#039;, &#039;&#039;&#039;10&#039;&#039;&#039;, &#039;&#039;&#039;20&#039;&#039;&#039;, &#039;&#039;&#039;40&#039;&#039;&#039;, or &#039;&#039;&#039;60&amp;amp;nbsp;ms&#039;&#039;&#039;.  It can also combine multiple frames into packets of &#039;&#039;&#039;up to 120&amp;amp;nbsp;ms&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Opus uses a &#039;&#039;&#039;20&amp;amp;nbsp;ms&#039;&#039;&#039; frame size &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2.1.4 by default]&#039;&#039;&#039;, as it gives a decent mix of low latency and good quality.&lt;br /&gt;
&lt;br /&gt;
For real-time applications, sending fewer packets per second reduces the overall bitrate, since it reduces the overhead from &#039;&#039;&#039;[https://en.wikipedia.org/wiki/IPv6_packet#Fixed_header IP]&#039;&#039;&#039;, &#039;&#039;&#039;[https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure UDP]&#039;&#039;&#039;, and &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Real-time_Transport_Protocol#Packet_header RTP headers]&#039;&#039;&#039;.&lt;br /&gt;
However, it increases latency and sensitivity to packet losses, as losing one packet constitutes a loss of a bigger chunk of audio.&lt;br /&gt;
Increasing the frame duration also slightly improves coding efficiency, but the gain becomes small for frame sizes above 20&amp;amp;nbsp;ms.&lt;br /&gt;
&lt;br /&gt;
For these reasons, the default 20&amp;amp;nbsp;ms frames are a good choice for most applications.&lt;br /&gt;
&lt;br /&gt;
== Trading Coding Efficiency with CPU Time ==&lt;br /&gt;
The Opus encoder uses its maximum algorithmic &#039;&#039;&#039;complexity&#039;&#039;&#039; setting of &#039;&#039;&#039;10&#039;&#039;&#039; &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2.1.5 by default]&#039;&#039;&#039;. This means that it does not hesitate to use CPU to give you the best quality encoding at a given bitrate.&lt;br /&gt;
&lt;br /&gt;
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 &#039;&#039;&#039;10&#039;&#039;&#039; (highest CPU usage and quality) down to &#039;&#039;&#039;0&#039;&#039;&#039; (lowest CPU usage and quality).&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=Opus_Recommended_Settings&amp;diff=16493</id>
		<title>Opus Recommended Settings</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=Opus_Recommended_Settings&amp;diff=16493"/>
		<updated>2016-11-08T14:44:19Z</updated>

		<summary type="html">&lt;p&gt;MarkH: /* Trading Coding Efficiency with CPU Time */ not really lots, try video encoding for that!&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;= Recommended Bitrates =&lt;br /&gt;
Depending on what kinds of sounds you want to encode with Opus, you should use different bitrate (quality) settings.&lt;br /&gt;
&lt;br /&gt;
The settings in the table below are meant to &#039;&#039;&#039;start you off&#039;&#039;&#039; with a decent tradeoff between &#039;&#039;&#039;good quality&#039;&#039;&#039; and &#039;&#039;&#039;small filesize&#039;&#039;&#039; (or &#039;&#039;&#039;bitrate usage&#039;&#039;&#039;, if you&#039;re streaming).&lt;br /&gt;
&lt;br /&gt;
You should test the suggested bitrate by actually &#039;&#039;&#039;listening&#039;&#039;&#039; to your encoded audio and then tweaking the bitrate:&lt;br /&gt;
* &#039;&#039;&#039;down&#039;&#039;&#039; if you think the quality is good, but the filesize (or bitrate) is too big&lt;br /&gt;
* &#039;&#039;&#039;up&#039;&#039;&#039; if you think the quality is bad, and you can afford having bigger files (or a larger streaming bitrate)&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
!Use Case&lt;br /&gt;
!Channels&lt;br /&gt;
!Bitrate (Kb/s)&lt;br /&gt;
!Notes&lt;br /&gt;
|-&lt;br /&gt;
|Ham radio&lt;br /&gt;
|1 (mono)&lt;br /&gt;
|use &#039;&#039;&#039;[http://www.rowetel.com/blog/?page_id=452 Codec&amp;amp;nbsp;2]&#039;&#039;&#039;&lt;br /&gt;
|Opus only supports bitrates down to 6&amp;amp;nbsp;Kb/s. Codec 2 handles speech from 0.7 to 3.2&amp;amp;nbsp;Kb/s.&lt;br /&gt;
|-&lt;br /&gt;
|VoIP&lt;br /&gt;
|1&lt;br /&gt;
|10-24&lt;br /&gt;
|10&amp;amp;nbsp;Kb/s will deliver narrowband most of the time, 24&amp;amp;nbsp;Kb/s should give fullband.&amp;lt;br&amp;gt;More details in &#039;&#039;&#039;[[Opus_Recommended_Settings#Bandwidth_Transition_Thresholds|the relevant table]]&#039;&#039;&#039; further down this page.&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|Audiobooks / Podcasts&lt;br /&gt;
|1&lt;br /&gt;
|24&lt;br /&gt;
|bitrates from here on up tend to deliver fullband audio.&lt;br /&gt;
|-&lt;br /&gt;
|2 (stereo)&lt;br /&gt;
|32&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
|Music Streaming / Radio&lt;br /&gt;
|2&lt;br /&gt;
|64-96&lt;br /&gt;
|Opus has better quality than MP3, AAC and [[Vorbis]] at these rates.&amp;lt;br&amp;gt;(test results &#039;&#039;&#039;[http://listening-tests.hydrogenaud.io/igorc/results.html here]&#039;&#039;&#039; and &#039;&#039;&#039;[http://listening-test.coresv.net/results.htm here]&#039;&#039;&#039;)&lt;br /&gt;
|-&lt;br /&gt;
|rowspan=&amp;quot;3&amp;quot;|Music Storage&lt;br /&gt;
|2&lt;br /&gt;
|96-128&lt;br /&gt;
|Opus at 128&amp;amp;nbsp;KB/s (VBR) is pretty much &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Transparency_(data_compression) transparent]&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|6 (5.1 surround)&lt;br /&gt;
|128-256&lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|for surround sound, Opus uses &#039;&#039;&#039;[https://xiph.org/~xiphmont/demo/opus/demo3.shtml surround-sound bitrate allocation]&#039;&#039;&#039;&lt;br /&gt;
|-&lt;br /&gt;
|8 (7.1 surround)&lt;br /&gt;
|256-450&lt;br /&gt;
|-&lt;br /&gt;
|Music Archiving&lt;br /&gt;
|any&lt;br /&gt;
|use &#039;&#039;&#039;[[FLAC]]&#039;&#039;&#039;&lt;br /&gt;
|if you are archiving audio, use a &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Audio_file_format#Lossless_compressed_audio_format lossless audio format]&#039;&#039;&#039; to prevent &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Generation_loss generation loss]&#039;&#039;&#039;&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
= Technical Details =&lt;br /&gt;
For the more technical Opus users, here are some details to help you fine-tune your decision on which bitrate best fits your needs.&lt;br /&gt;
&lt;br /&gt;
== Mono or Stereo ==&lt;br /&gt;
Opus tends to start &#039;&#039;&#039;downmixing stereo inputs to mono&#039;&#039;&#039; from roughly &#039;&#039;&#039;24&amp;amp;nbsp;Kb/s and lower&#039;&#039;&#039;.&lt;br /&gt;
You can check the details in the &#039;&#039;&#039;[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L148 opus_encoder.c]&#039;&#039;&#039; source file.&lt;br /&gt;
&lt;br /&gt;
You can force downmixing at any bitrate by using the following command-line parameters:&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--downmix-mono&amp;lt;/code&amp;gt; - downmixes all input channels to mono&lt;br /&gt;
&lt;br /&gt;
&amp;lt;code&amp;gt;--downmix-stereo&amp;lt;/code&amp;gt; - downmixes all input channels to stereo (if there are more than 2 input channels, e.g. surround sound)&lt;br /&gt;
&lt;br /&gt;
== Bandwidth Transition Thresholds ==&lt;br /&gt;
The following table shows rough bitrates that you might want to use to encode audio that has &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2 limited frequency bandwidths]&#039;&#039;&#039;.&lt;br /&gt;
This could be useful if your audio has already been bandpassed, or should go through a bandpass filter (e.g. VoIP speech).&lt;br /&gt;
&lt;br /&gt;
{| class=&amp;quot;wikitable&amp;quot; style=&amp;quot;text-align:center&amp;quot;&lt;br /&gt;
|- &lt;br /&gt;
|rowspan=&amp;quot;2&amp;quot;|(bitrates in&amp;amp;nbsp;Kb/s)&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Mono&lt;br /&gt;
!colspan=&amp;quot;2&amp;quot;|Stereo&lt;br /&gt;
|-&lt;br /&gt;
!Voice&lt;br /&gt;
!Music&lt;br /&gt;
!Voice&lt;br /&gt;
!Music&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-4000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;NarrowBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|12&lt;br /&gt;
|15&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-6000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;MediumBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|15&lt;br /&gt;
|18-22&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-8000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;WideBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|16-20&lt;br /&gt;
|22-28&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-12000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;SuperWideBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|24-28&lt;br /&gt;
|28-32&lt;br /&gt;
|?&lt;br /&gt;
|?&lt;br /&gt;
|-&lt;br /&gt;
!&amp;lt;abbr title=&amp;quot;(3-20000&amp;amp;nbsp;Hz)&amp;quot;&amp;gt;FullBand&amp;lt;/abbr&amp;gt;&lt;br /&gt;
|28-40&lt;br /&gt;
|32-64&lt;br /&gt;
|32-64&lt;br /&gt;
|64-128&lt;br /&gt;
|}&lt;br /&gt;
&lt;br /&gt;
The details of Opus&#039; bandpass thresholds can be found in the &#039;&#039;&#039;[https://github.com/xiph/opus/blob/master/src/opus_encoder.c#L121 opus_encoder.c]&#039;&#039;&#039; source file.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;[http://wiki.hydrogenaud.io/index.php?title=Opus HydrogenAudio]&#039;&#039;&#039; wiki also has some great information on Opus and its usage.&lt;br /&gt;
&lt;br /&gt;
== Framesize Tweaking ==&lt;br /&gt;
Opus can encode frames of &#039;&#039;&#039;2.5&#039;&#039;&#039;, &#039;&#039;&#039;5&#039;&#039;&#039;, &#039;&#039;&#039;10&#039;&#039;&#039;, &#039;&#039;&#039;20&#039;&#039;&#039;, &#039;&#039;&#039;40&#039;&#039;&#039;, or &#039;&#039;&#039;60&amp;amp;nbsp;ms&#039;&#039;&#039;.  It can also combine multiple frames into packets of &#039;&#039;&#039;up to 120&amp;amp;nbsp;ms&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Opus uses a &#039;&#039;&#039;20&amp;amp;nbsp;ms&#039;&#039;&#039; frame size &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2.1.4 by default]&#039;&#039;&#039;, as it gives a decent mix of low latency and good quality.&lt;br /&gt;
&lt;br /&gt;
For real-time applications, sending fewer packets per second reduces the overall bitrate, since it reduces the overhead from &#039;&#039;&#039;[https://en.wikipedia.org/wiki/IPv6_packet#Fixed_header IP]&#039;&#039;&#039;, &#039;&#039;&#039;[https://en.wikipedia.org/wiki/User_Datagram_Protocol#Packet_structure UDP]&#039;&#039;&#039;, and &#039;&#039;&#039;[https://en.wikipedia.org/wiki/Real-time_Transport_Protocol#Packet_header RTP headers]&#039;&#039;&#039;.&lt;br /&gt;
However, it increases latency and sensitivity to packet losses, as losing one packet constitutes a loss of a bigger chunk of audio.&lt;br /&gt;
Increasing the frame duration also slightly improves coding efficiency, but the gain becomes small for frame sizes above 20&amp;amp;nbsp;ms.&lt;br /&gt;
&lt;br /&gt;
For these reasons, the default 20&amp;amp;nbsp;ms frames are a good choice for most applications.&lt;br /&gt;
&lt;br /&gt;
== Trading Coding Efficiency with CPU Time ==&lt;br /&gt;
The Opus encoder uses its maximum algorithmic &#039;&#039;&#039;complexity&#039;&#039;&#039; setting of &#039;&#039;&#039;10&#039;&#039;&#039; &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716#section-2.1.5 by default]&#039;&#039;&#039;. This means that it does not hesitate to use CPU to give you the best quality encoding at a given bitrate.&lt;br /&gt;
&lt;br /&gt;
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 &#039;&#039;&#039;10&#039;&#039;&#039; (highest CPU usage and quality) down to &#039;&#039;&#039;0&#039;&#039;&#039; (lowest CPU usage and quality).&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusTodo&amp;diff=16445</id>
		<title>OpusTodo</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusTodo&amp;diff=16445"/>
		<updated>2016-07-20T02:59:33Z</updated>

		<summary type="html">&lt;p&gt;MarkH: update for 1.1.3&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== For 1.2 ==&lt;br /&gt;
* Low bitrate quality improvements&lt;br /&gt;
* AVX optimizations&lt;br /&gt;
* Fix compilation as a single module for gecko&lt;br /&gt;
&lt;br /&gt;
== Spec ==&lt;br /&gt;
* Matroska mapping. See: [[MatroskaOpus]] And firefox/ffmpeg implementation&lt;br /&gt;
* RTP payload format. Mono/stereo mapping is complete [[https://tools.ietf.org/html/rfc7587 RFC 7587]], no multichannel mapping yet.&lt;br /&gt;
* mp4 mapping. See [[https://opus-codec.org/docs/opus_in_isobmff.html ISO Base Media File Format draft]]&lt;br /&gt;
&lt;br /&gt;
== Website ==&lt;br /&gt;
* De-uglify webpage - some suggestions:&lt;br /&gt;
** write about codecs obsoleted by OPUS (Speex, CELT, Vorbis(?) and the proprietary ones)&lt;br /&gt;
** write about implementations (libopus encoder/decoder, libavcodec decoder, any others?)&lt;br /&gt;
** [https://en.wikipedia.org/wiki/Comparison_of_audio_coding_formats audio codec comparison table] (Opus, Vorbis, Speex, ..., MP5) of features (channels, freq, bits per sample, license, language (C89), integer impl. (Vorbis decoder only, Opus YES, ...)&lt;br /&gt;
** future use in video files (Theora? Dirac? WebM? other future codecs...)&lt;br /&gt;
** audio files for storage (like Vorbis, no raw Opus defined, only inside OGG), ... &lt;br /&gt;
* Promotional material (some nice free/public-domain sounds/radio stations in Opus format)&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
* Oggz-validate (should also validate opus toc)&lt;br /&gt;
&lt;br /&gt;
== Opus-tools ==&lt;br /&gt;
* Port opusdec to libopusfile/libopusurl.&lt;br /&gt;
* A simple real time streaming example tool&lt;br /&gt;
** Start with opusrtp.c in [https://git.xiph.org/?p=opus-tools.git opus-tools]&lt;br /&gt;
** Make &amp;lt;code&amp;gt;opusrtp rtp://example.com:5431/&amp;lt;/code&amp;gt; listen to that host and port and mux packets from there. Generalize the cpac bases --sniff implementation&lt;br /&gt;
** Make sending similarly generic. Maybe just &amp;lt;code&amp;gt;opusrtp source.opus -o rtp://example.com:5431/&amp;lt;/code&amp;gt; to send source.opus out to the destination?&lt;br /&gt;
** Make --sniff save one file per&lt;br /&gt;
** Implement DTLS-SRTP. See webrtc.&lt;br /&gt;
** audio capture/encode, decode/playback?&lt;br /&gt;
** Parse and act on sdp for convenience and testing.&lt;br /&gt;
&lt;br /&gt;
* EBU R128/Replaygain (half done— needs a gain tool)&lt;br /&gt;
&lt;br /&gt;
== Surround work ==&lt;br /&gt;
&lt;br /&gt;
* Apply spreading to energy masking&lt;br /&gt;
* More conservative energy masking (not just mean difference) and dynalloc&lt;br /&gt;
* Allow SILK/hybrid on center channel for voice?&lt;br /&gt;
&lt;br /&gt;
== Psychoacoustic stuff ==&lt;br /&gt;
&lt;br /&gt;
* Adaptive width narrowing and forced intensity stereo bands&lt;br /&gt;
&lt;br /&gt;
== Optimisations ==&lt;br /&gt;
&lt;br /&gt;
* Vectorising comb_filter()&lt;br /&gt;
* Use 16-bit mul plus shift in denormalise_bands()&lt;br /&gt;
* Optimise MDCT somehow&lt;br /&gt;
&lt;br /&gt;
== Third-Party tool enhancements ==&lt;br /&gt;
* mutagen: [https://bitbucket.org/lazka/mutagen/issue/202/oggopus-support-in-place-rewrites-for support padding in comments header], [https://bitbucket.org/lazka/mutagen/issue/203/oggopus-allow-updating-the-output_gain allow updating output gain in ID header]&lt;br /&gt;
&lt;br /&gt;
== Future work ==&lt;br /&gt;
* psymodel based VBR&lt;br /&gt;
* Remove copy in inverse MDCT&lt;br /&gt;
* Save some float&amp;lt;-&amp;gt;int conversions&lt;br /&gt;
* Improvements to LP mode CBR (greg has some code)&lt;br /&gt;
* Unconstrained SILK VBR&lt;br /&gt;
* Better handling for the case where FEC has a different bandwidth than the current mode&lt;br /&gt;
* PLC transitions on unprotected SILK-SILK bandwidth changes?&lt;br /&gt;
* Figure out how to use speech/music detection optimally&lt;br /&gt;
** find optimal switching time (low energy/tonality)&lt;br /&gt;
* Improve variable frame size&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=16350</id>
		<title>OpusFAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=16350"/>
		<updated>2016-05-01T13:06:50Z</updated>

		<summary type="html">&lt;p&gt;MarkH: opus-codec.com→opus-codec.org, http→https&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you are looking for info not covered in this FAQ, try the [https://opus-codec.org main Opus website] or the pages included in the [[:Category:Opus|Opus category]] of this wiki.&lt;br /&gt;
&lt;br /&gt;
[[Image:Opus logo trans.png|right]]&lt;br /&gt;
&lt;br /&gt;
== General Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What is Opus? Who created it? ===&lt;br /&gt;
&lt;br /&gt;
Opus is a totally open, royalty-free, highly versatile audio codec.&lt;br /&gt;
&lt;br /&gt;
It is primarily designed for interactive speech and music transmission over the Internet, but is also applicable to storage and streaming applications. It incorporates technology from Skype&#039;s &#039;&#039;&#039;[https://en.wikipedia.org/wiki/SILK SILK]&#039;&#039;&#039; codec and Xiph.Org&#039;s &#039;&#039;&#039;[http://celt-codec.org/ CELT]&#039;&#039;&#039; codec. It has been standardized by the &#039;&#039;&#039;[https://www.ietf.org/ Internet Engineering Task Force]&#039;&#039;&#039; (IETF) as &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716 RFC 6716]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Opus has been in development since early 2007. Programmers associated with &#039;&#039;&#039;[https://xiph.org/ Xiph.Org]&#039;&#039;&#039;, &#039;&#039;&#039;[https://www.skype.com/ Skype]&#039;&#039;&#039; and several other organizations have contributed to its development and to the standardization process as part of the &#039;&#039;&#039;[https://datatracker.ietf.org/wg/codec/charter/ IETF&#039;s Codec Working Group]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== How does Opus compare to other codecs? ===&lt;br /&gt;
&lt;br /&gt;
Opus is distinguished from most high quality formats (eg: AAC, [[Vorbis]], MP3) by having &#039;&#039;&#039;low delay&#039;&#039;&#039; (5 ~ 66.5 ms) and distinguished from most low delay formats (eg: G.711, GSM, Speex) by supporting &#039;&#039;&#039;high audio quality&#039;&#039;&#039; ([https://tools.ietf.org/html/rfc6716#section-2.1.1 details here]).&lt;br /&gt;
&lt;br /&gt;
It meets or exceeds existing codecs&#039; quality across a wide range of bitrates, and it operates at lower delay than virtually any existing compressed format.&lt;br /&gt;
&lt;br /&gt;
Most importantly, the Opus format and its reference implementation are both available under &#039;&#039;&#039;[https://opus-codec.org/license/ liberal, royalty-free licenses]&#039;&#039;&#039;.&amp;lt;br /&amp;gt;&lt;br /&gt;
This makes it:&lt;br /&gt;
* easy to adopt&lt;br /&gt;
* compatible with free software&lt;br /&gt;
* suitable for use as part of the basic infrastructure of the Internet&lt;br /&gt;
&lt;br /&gt;
See the Opus &#039;&#039;&#039;[https://opus-codec.org/comparison comparison page]&#039;&#039;&#039; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus make all those other lossy codecs obsolete? ===&lt;br /&gt;
&lt;br /&gt;
Theoretically, yes.&lt;br /&gt;
&lt;br /&gt;
From a technical point of view (loss, delay, bitrates, ...) it should replace both [[Vorbis]] and [[Speex]], and the common proprietary codecs too.&lt;br /&gt;
&lt;br /&gt;
=== Will Opus replace Vorbis in video files? ===&lt;br /&gt;
&lt;br /&gt;
For Ogg [[Theora]] video files, it can, just the overall size reduction will be minimal and it will break compatibility with existing players.&lt;br /&gt;
&lt;br /&gt;
For WebM video files, the convention is to use the VP9 video codec when using Opus as an audio codec.&lt;br /&gt;
&lt;br /&gt;
=== How do I use Opus? What programs support Opus? ===&lt;br /&gt;
&lt;br /&gt;
Opus decoding support is now included in &#039;&#039;&#039;[http://caniuse.com/opus some Internet browsers]&#039;&#039;&#039; and &#039;&#039;&#039;[[OpusSupport|many applications]]&#039;&#039;&#039;, including &#039;&#039;&#039;[https://www.mozilla.org/firefox Firefox]&#039;&#039;&#039;, &#039;&#039;&#039;[https://www.foobar2000.org/ foobar2000]&#039;&#039;&#039; and &#039;&#039;&#039;[https://www.videolan.org/vlc/ VLC]&#039;&#039;&#039;, as well as in frameworks such as &#039;&#039;&#039;[https://gstreamer.freedesktop.org/ GStreamer]&#039;&#039;&#039; and &#039;&#039;&#039;[https://ffmpeg.org/ FFmpeg]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For now, the best way to &#039;&#039;&#039;encode&#039;&#039;&#039; Opus files is to use the &#039;&#039;&#039;opusenc&#039;&#039;&#039; command-line tool from the &#039;&#039;&#039;[https://opus-codec.org/downloads/ opus-tools package]&#039;&#039;&#039;.&lt;br /&gt;
If you want to encode many files at once (e.g. your music library), you can also try the &#039;&#039;&#039;[http://lamexp.sourceforge.net/ LameXP]&#039;&#039;&#039; converter.&lt;br /&gt;
&lt;br /&gt;
For real-time applications, Opus support is available in &#039;&#039;&#039;[https://www.webrtc.org/ Google&#039;s WebRTC codebase]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Opus is a relatively new codec: many more applications will support it in the near future.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus support higher sampling rates, such as 96 kHz or 192 kHz? ===&lt;br /&gt;
&lt;br /&gt;
Yes and no.&lt;br /&gt;
&lt;br /&gt;
Opus encoding tools like opusenc will happily encode input files that are sampled at 96 or 192 kHz.&lt;br /&gt;
&lt;br /&gt;
However, files at these rates are internally &#039;&#039;&#039;converted to 48 kHz&#039;&#039;&#039; and then only frequencies &#039;&#039;&#039;up to 20 kHz&#039;&#039;&#039; are encoded.&lt;br /&gt;
&lt;br /&gt;
The reason is simple: lossy codecs are designed to preserve audible details while discarding irrelevant information. Since the human ear can only hear up to 20 kHz at best (usually lower than that), frequency content above 20 kHz is the first thing to go.&lt;br /&gt;
&lt;br /&gt;
See Monty&#039;s &#039;&#039;&#039;[https://people.xiph.org/~xiphmont/demo/neil-young.html article]&#039;&#039;&#039; for more details.&lt;br /&gt;
&lt;br /&gt;
If you want a codec to handle higher sampling rates losslessly, use &#039;&#039;&#039;[[FLAC]]&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
=== What are the licensing requirements? ===&lt;br /&gt;
&lt;br /&gt;
The reference Opus source code is released under a three-clause BSD license, which is a very permissive Open Source license. Commercial use and distribution (including in proprietary software) is permitted, provided that some basic conditions specified in the license are met. &lt;br /&gt;
&lt;br /&gt;
Opus is also covered by some patents, for which royalty-free usage rights are granted, under conditions that the authors believe are compatible with (hopefully) all open source licenses, including the GPL (v2 and v3).&lt;br /&gt;
&lt;br /&gt;
See the &#039;&#039;&#039;[https://www.opus-codec.org/license/ Opus Licensing]&#039;&#039;&#039; page for details.&lt;br /&gt;
&lt;br /&gt;
=== Why make Opus free? ===&lt;br /&gt;
&lt;br /&gt;
On the Internet, protocol and codec standards are part of the common infrastructure everyone builds upon.&lt;br /&gt;
&lt;br /&gt;
Most of the value of a high-quality standard is the innovation and inter-operation provided by the systems built on top of it. When a few parties have monopoly rights to monetize a standard, that infrastructure stops being so common and everyone else has more reason to use their own solution instead, increasing cost and reducing efficiency.&lt;br /&gt;
&lt;br /&gt;
Imagine a road system where each type of car could only drive on its own manufacturer&#039;s pavement. We all benefit from living in a world where all the roads are connected.&lt;br /&gt;
&lt;br /&gt;
This is why Opus, unlike many codecs, is free.&lt;br /&gt;
&lt;br /&gt;
=== Is the SILK part of Opus compatible with the SILK implementation shipped in Skype? ===&lt;br /&gt;
&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
The SILK codec, as submitted by Skype to the IETF, was heavily modified as part of its integration within Opus. The modifications are significant enough that it is not possible to just write a &amp;quot;translator&amp;quot;. Even sharing code between Opus and the &amp;quot;old SILK&amp;quot; would be highly complex.&lt;br /&gt;
&lt;br /&gt;
=== Why not keep the SILK and CELT codecs separate? ===&lt;br /&gt;
Opus is more than just two independent codecs with a switch.&lt;br /&gt;
&lt;br /&gt;
In addition to a [https://en.wikipedia.org/wiki/Linear_predictive_coding Linear Prediction] &#039;&#039;&#039;SILK mode&#039;&#039;&#039; and an [https://en.wikipedia.org/wiki/Modified_discrete_cosine_transform MDCT] &#039;&#039;&#039;CELT mode&#039;&#039;&#039; it has a &#039;&#039;&#039;hybrid mode&#039;&#039;&#039;, where speech frequencies up to 8 kHz are encoded with LP while those between 8 and 20 kHz are encoded with MDCT. This is what allows Opus to have such high speech quality around 32 kbps.&lt;br /&gt;
&lt;br /&gt;
Another advantage of the integration is the ability to switch between these 3 modes seamlessly, without any audible &amp;quot;glitches&amp;quot; and without any out-of-band signalling.&lt;br /&gt;
&lt;br /&gt;
=== Now that Opus is standardized, will its development stop, or can it be further improved? ===&lt;br /&gt;
Yes, Opus &#039;&#039;&#039;can&#039;&#039;&#039; and &#039;&#039;&#039;should&#039;&#039;&#039; be improved, because unlike most ITU-T codecs, Opus is only defined in terms of its decoder.&lt;br /&gt;
&lt;br /&gt;
The encoder can keep evolving as long as the bitstream it produces can be decoded by the reference decoder. This is what made it possible for modern MP3 encoders (e.g. &#039;&#039;&#039;[https://en.wikipedia.org/wiki/LAME LAME]&#039;&#039;&#039;) to improve far beyond the original &#039;&#039;&#039;[https://en.wikipedia.org/wiki/L3enc L3enc]&#039;&#039;&#039; and &#039;&#039;&#039;dist10&#039;&#039;&#039; reference implementations.&lt;br /&gt;
&lt;br /&gt;
Although it is unlikely that Opus encoders will see such a spectacular evolution, we certainly hope that future encoders will become much better than the reference encoder.&lt;br /&gt;
&lt;br /&gt;
In fact, the 1.1 libopus release significantly improves on the reference encoder&#039;s quality. See &#039;&#039;&#039;[https://people.xiph.org/~xiphmont/demo/opus/demo3.shtml Monty&#039;s demo]&#039;&#039;&#039; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Will all future Opus releases comply with the [https://tools.ietf.org/html/rfc6716 Opus specification]? ===&lt;br /&gt;
&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
=== In what ways is Opus optimized for the Internet? ===&lt;br /&gt;
&lt;br /&gt;
Opus has good packet loss robustness and concealment, but its optimisations go further.&lt;br /&gt;
&lt;br /&gt;
One of the first things we&#039;ve been asked when designing Opus was to make the rate &#039;&#039;&#039;really&#039;&#039;&#039; adaptable because we never know what kind of rates will be available. This not only meant having a wide range of bitrates, but also being able to vary in small increments.&lt;br /&gt;
&lt;br /&gt;
This is why Opus scales from about &#039;&#039;&#039;6 &#039;&#039;&#039; to &#039;&#039;&#039;512 kb/s&#039;&#039;&#039;, in increments of &#039;&#039;&#039;0.4 kb/s&#039;&#039;&#039; (one byte with 20 ms frames). Opus can have &#039;&#039;&#039;more than 1200 possible bitrates&#039;&#039;&#039; while spending only &#039;&#039;&#039;11 bits&#039;&#039;&#039; signalling the bitrate because UDP already encodes the packet size.&lt;br /&gt;
&lt;br /&gt;
One last aspect is that Opus is simple to transport over RTP, as can be seen from the [https://tools.ietf.org/html/rfc7587 Opus RTP payload format]. For example, it&#039;s possible to decode RTP packets without having even seen the SDP or any out-of-band signalling.&lt;br /&gt;
&lt;br /&gt;
=== What applications for Android can play Opus? ===&lt;br /&gt;
&lt;br /&gt;
Right now, there are just a few but that list is fast growing. Please reference [https://android.stackexchange.com/q/37970/7425 this question on android.stackexchange.com]. Feel free to suggest other applications.&lt;br /&gt;
&lt;br /&gt;
=== When will the next version be released? ===&lt;br /&gt;
&lt;br /&gt;
When it&#039;s done. Seriously, we do not know.&lt;br /&gt;
&lt;br /&gt;
Opus is not a large project with a fixed release schedule.&lt;br /&gt;
&lt;br /&gt;
That being said, our [https://www.opus-codec.org/downloads/ pre-releases] and even the [https://git.xiph.org/?p=opus.git git repository] are generally pretty stable and given proper testing (which you should always do anyway), are safe to distribute.&lt;br /&gt;
&lt;br /&gt;
Just be aware that the API of new features (that have never been included in a stable release) could potentially still change.&lt;br /&gt;
&lt;br /&gt;
== Software Developers&#039; Questions ==&lt;br /&gt;
&lt;br /&gt;
=== On what platforms does Opus run? ===&lt;br /&gt;
&lt;br /&gt;
The Opus code base is written in C89 and should run on the vast majority of recent (and not so recent) CPUs.&lt;br /&gt;
&lt;br /&gt;
Some of the platforms &#039;&#039;&#039;[https://mf4.xiph.org/jenkins/view/opus/ on which Opus has been tested]&#039;&#039;&#039; include x86, x86-64, ARM, Itanium, Blackfin, and SPARC.&lt;br /&gt;
&lt;br /&gt;
=== Is there a fixed-point implementation? ===&lt;br /&gt;
&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
The fixed-point and floating-point decoder and encoder implementations are part of the same code base.&lt;br /&gt;
&lt;br /&gt;
The code defaults to float, so you need to configure with &#039;&#039;&#039;--enable-fixed-point&#039;&#039;&#039; (or define &#039;&#039;&#039;FIXED_POINT&#039;&#039;&#039; if not using the configure script) to build the code for fixed-point.&lt;br /&gt;
&lt;br /&gt;
=== Which implementation should I use? ===&lt;br /&gt;
&lt;br /&gt;
While the implementation in RFC 6716 is what &#039;&#039;defines&#039;&#039; the standard, it is likely not the best and most up-to-date implementation.&lt;br /&gt;
&lt;br /&gt;
The [https://opus-codec.org/ Opus] website was set up for the purpose of continually improving the implementation — in terms of speed, encoding quality, device compatibility, etc — while still conforming to the standard.&lt;br /&gt;
&lt;br /&gt;
All Opus implementations are compatible by definition.&lt;br /&gt;
&lt;br /&gt;
=== How is supporting Opus different from supporting Speex/G.711/MP3? ===&lt;br /&gt;
&lt;br /&gt;
Opus has variable frame durations which can change on the fly, so an Opus decoder needs to be ready to accept packets with durations that are &#039;&#039;&#039;any multiple of 2.5ms&#039;&#039;&#039; up to a &#039;&#039;&#039;maximum of 120ms&#039;&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
The opus encoder and decoder do not need to have matched sampling rates or channel counts.  It is recommended to always just decode at the highest rate the hardware supports (e.g. 48kHz stereo) so the user gets the full quality of whatever the far end is sending.&lt;br /&gt;
&lt;br /&gt;
=== My application doesn&#039;t work. Can anyone help me? ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to get help, but before doing so, there are a few basic things to try:&lt;br /&gt;
&lt;br /&gt;
* Implement your application with uncompressed audio instead of Opus. If it still doesn&#039;t work, then the problem isn&#039;t related to Opus.&lt;br /&gt;
* Read the [https://www.opus-codec.org/docs/ Opus documentation].&lt;br /&gt;
* Read the [https://git.xiph.org/?p=opus.git;a=blob;f=src/opus_demo.c opus_demo.c] source code to see how to use the encoder and decoder.&lt;br /&gt;
&lt;br /&gt;
If you still can&#039;t solve the problem, the best option is to ask for help on the [http://lists.xiph.org/mailman/listinfo/opus mailing list] or on the &#039;&#039;&#039;#opus&#039;&#039;&#039; IRC channel on &#039;&#039;&#039;irc.freenode.net&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== How do I report a bug? ===&lt;br /&gt;
&lt;br /&gt;
If you think you have found a bug in Opus (and not in your application), please [https://trac.xiph.org/newticket?component=Opus file a bug report].&lt;br /&gt;
&lt;br /&gt;
Please include a way for us to reproduce the problem. The best way to do this is to provide an input file, along with the opusenc/opusdec/opus_demo command line that causes the bug to occur.&lt;br /&gt;
&lt;br /&gt;
If the bug cannot be triggered by the command line tools, please provide a simple patch or C file that can help reproduce it. Please also provide any other relevant information, such as OS, CPU, build options, etc.&lt;br /&gt;
&lt;br /&gt;
Don&#039;t hesitate to also contact us on the [http://lists.xiph.org/mailman/listinfo/opus mailing list] or on [irc://irc.freenode.net/opus IRC].&lt;br /&gt;
&lt;br /&gt;
=== What is Opus Custom? ===&lt;br /&gt;
&lt;br /&gt;
Opus Custom is an &#039;&#039;&#039;optional&#039;&#039;&#039; part of the Opus standard that allows for sampling rates other than 8, 12, 16, 24, or 48 kHz and frame sizes other than multiples of 2.5 ms.&lt;br /&gt;
&lt;br /&gt;
Opus Custom requires additional out-of-band signalling that Opus does not normally require and disables many of Opus&#039; coding modes. Also, because it is an optional part of the specification, using Opus Custom may lead to compatibility problems.&lt;br /&gt;
&lt;br /&gt;
For these reasons, its use is discouraged outside of very specific applications, for example:&lt;br /&gt;
* ultra low delay applications where synchronization with the soundcard buffer is important. &lt;br /&gt;
* low-power embedded applications where compatibility with others is not important.&lt;br /&gt;
&lt;br /&gt;
For almost all other types of applications, Opus Custom should not be used.&lt;br /&gt;
&lt;br /&gt;
=== How do I use 44.1 kHz or some other sampling rate not directly supported by Opus? ===&lt;br /&gt;
&lt;br /&gt;
Tools which read or write Opus should inter-operate with other sampling rates by transparently performing sample rate conversion behind the scenes whenever necessary. In particular, software developers should not use Opus Custom for 44.1 kHz support, except in the very specific circumstances outlined above.&lt;br /&gt;
&lt;br /&gt;
Note that it&#039;s generally preferable for a decoder to output at 48kHz, even when you know the original input was 44.1kHz. This is not only because you can skip resampling, but also because many cheaper audio interfaces have poor quality output for 44.1kHz.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;[https://opus-codec.org/downloads/ opus-tools]&#039;&#039;&#039; package source code contains a small, high quality, high performance, BSD licensed resampler which can be used where resampling is required.&lt;br /&gt;
&lt;br /&gt;
=== How is the bitrate setting used in VBR mode? ===&lt;br /&gt;
&lt;br /&gt;
Variable bitrate (VBR) mode allows the bitrate to automatically vary over time based on the audio being encoded, in order to achieve a consistent quality.&lt;br /&gt;
&lt;br /&gt;
The bitrate setting controls the desired quality, on a scale that is calibrated to closely approximate the average bitrate that would be obtained over a large and diverse collection of audio.  The actual bitrate of any particular audio stream may be higher or lower than this average.&lt;br /&gt;
&lt;br /&gt;
=== What frame size should I use? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;20ms&#039;&#039;&#039; frame size works well for most applications.&lt;br /&gt;
&lt;br /&gt;
Smaller frame sizes may be used to achieve lower latency, but have lower quality at a given bitrate.&lt;br /&gt;
&lt;br /&gt;
Sizes greater than 20 ms increase latency and are generally beneficial only at fairly low bitrates, or when used to reduce external overhead (e.g. by reducing the number of packets that are sent).&lt;br /&gt;
&lt;br /&gt;
=== Forward Error correction (FEC) doesn&#039;t appear to do anything! HELP! ===&lt;br /&gt;
&lt;br /&gt;
The in-band FEC feature of Opus helps reduce the harm of packet loss by encoding some information about the prior packet.&lt;br /&gt;
&lt;br /&gt;
In order to make use of in-band FEC the decoder must delay its output by at least one frame so that it can call the decoder with the decode_fec argument on the &#039;&#039;next&#039;&#039; frame in order to reconstruct the missed frame. This works best if it&#039;s integrated with a jitter buffer.&lt;br /&gt;
&lt;br /&gt;
FEC is only used by the encoder under certain conditions:&lt;br /&gt;
* the feature must be enabled via the OPUS_SET_INBAND_FEC CTL&lt;br /&gt;
* the encoder must be told to expect loss via the OPUS_SET_PACKET_LOSS_PERC CTL&lt;br /&gt;
* the codec must be operated in any of the linear prediction or Hybrid modes&lt;br /&gt;
&lt;br /&gt;
Frame durations shorter than 10ms and very high bitrates will use the MDCT modes, where FEC is not available.&lt;br /&gt;
&lt;br /&gt;
Even when FEC is not used, telling the encoder about the expected level of loss will help it make more intelligent decisions. By default the implementation assumes there is no loss.&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t use malloc or much stack on my embedded platform. How do I make Opus work? ===&lt;br /&gt;
&lt;br /&gt;
A normal build of libopus only uses &amp;lt;tt&amp;gt;malloc/free&amp;lt;/tt&amp;gt; in the &amp;lt;tt&amp;gt;_create()&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;_destroy()&amp;lt;/tt&amp;gt; calls, making it safe for realtime use as long as the codec state is pre-created.&lt;br /&gt;
&lt;br /&gt;
To build Opus without the references to &amp;lt;tt&amp;gt;malloc/free&amp;lt;/tt&amp;gt;, you must:&lt;br /&gt;
&lt;br /&gt;
* use &amp;lt;tt&amp;gt;init()&amp;lt;/tt&amp;gt; calls rather than &amp;lt;tt&amp;gt;create()&amp;lt;/tt&amp;gt; calls in your application&lt;br /&gt;
* compile with &amp;lt;tt&amp;gt;CFLAGS=&amp;quot;-DOVERRIDE_OPUS_ALLOC -DOVERRIDE_OPUS_FREE  -D&#039;opus_alloc(x)=NULL&#039; -D&#039;opus_free(x)=NULL&#039; &amp;quot;&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If libopus is built with &amp;lt;tt&amp;gt;-DNONTHREADSAFE_PSEUDOSTACK&amp;lt;/tt&amp;gt; (instead of &amp;lt;tt&amp;gt;VAR_ARRAYS&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;USE_ALLOCA&amp;lt;/tt&amp;gt;), it will use a user-provided block of heap instead of stack for many things, resulting in much lower stack usage.&amp;lt;br&amp;gt;&lt;br /&gt;
This makes the resulting library &#039;&#039;&#039;non-threadsafe&#039;&#039;&#039; and is &#039;&#039;&#039;not recommended&#039;&#039;&#039; on anything except limited embedded platforms.&lt;br /&gt;
&lt;br /&gt;
=== How can I ensure that my software interoperates with other software implementing Opus? ===&lt;br /&gt;
&lt;br /&gt;
For applications using Ogg files, there are some [https://people.xiph.org/~greg/opus_testvectors/ Ogg Opus testvectors] to test decoders and you can test encoders with opusdec. For RTP applications, the opusrtp tool can be useful.&lt;br /&gt;
&lt;br /&gt;
In general, here&#039;s a list of specific issues to check:&lt;br /&gt;
* Can your application handle all frame sizes, including changing the frame size from frame to frame?&lt;br /&gt;
* Does your application properly react to lost packet by calling the decoder with a NULL packet?&lt;br /&gt;
&lt;br /&gt;
=== What is the complexity of Opus? ===&lt;br /&gt;
&lt;br /&gt;
The complexity of Opus varies by a large amount based on the settings used.&lt;br /&gt;
&lt;br /&gt;
It depends on the mode, audio bandwidth, number of channels, and even a &amp;quot;complexity knob&amp;quot; that can trade complexity for quality. It will run easily on any recent PC or smartphone. &lt;br /&gt;
&lt;br /&gt;
For slower embedded CPUs/DSPs, the amount of CPU required will vary depending on the configuration and the exact CPU, so you will need to experiment. Do not expect Opus to run quickly on really slow devices like 8-bit micro-controllers.&lt;br /&gt;
&lt;br /&gt;
=== Opus is using too much CPU for my application. What can I do? ===&lt;br /&gt;
&lt;br /&gt;
First don&#039;t panic and don&#039;t start writing assembly just yet.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible that you&#039;re just not using the right set of options.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re targeting an embedded/mobile platform, chances are the fixed-point build will be faster, so make sure you&#039;re using &#039;&#039;&#039;--enable-fixed-point&#039;&#039;&#039; or defining &#039;&#039;&#039;FIXED_POINT&#039;&#039;&#039; in the build system.&lt;br /&gt;
&lt;br /&gt;
Opus also has a complexity option that can trade quality for complexity. The default is highest quality and highest complexity. You can control this using &#039;&#039;&#039;OPUS_SET_COMPLEXITY()&#039;&#039;&#039; (see the &#039;&#039;&#039;[https://www.opus-codec.org/docs/ Documentation]&#039;&#039;&#039; for details).&lt;br /&gt;
&lt;br /&gt;
If all else fails and you need to optimize the Opus code, see the next question.&lt;br /&gt;
&lt;br /&gt;
=== I would like to optimize/improve/help with Opus. Where should I start? ===&lt;br /&gt;
&lt;br /&gt;
Please &#039;&#039;&#039;[https://www.opus-codec.org/contact/ contact us]&#039;&#039;&#039; before you start, or at least before you get too far.&lt;br /&gt;
&lt;br /&gt;
This will help coordinate the efforts made on Opus and reduce the probability of wasting your time on duplicated effort or going down the wrong path.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus have an echo canceller like Speex does? ===&lt;br /&gt;
&lt;br /&gt;
Echo cancellation is completely independent from codecs.&lt;br /&gt;
&lt;br /&gt;
You can use any echo canceller (including the one from libspeexdsp) along with Opus.&lt;br /&gt;
&lt;br /&gt;
That being said, among the free acoustic echo cancelers (AEC) we&#039;re aware of, the best is probably the Google AEC from the [https://code.google.com/p/webrtc/ WebRTC codebase].&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=16349</id>
		<title>OpusFAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=16349"/>
		<updated>2016-05-01T04:37:22Z</updated>

		<summary type="html">&lt;p&gt;MarkH: http→https for sites where it functions correctly&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you are looking for info not covered in this FAQ, try the [http://opus-codec.org main Opus website] or the pages included in the [[:Category:Opus|Opus category]] of this wiki.&lt;br /&gt;
&lt;br /&gt;
[[Image:Opus logo trans.png|right]]&lt;br /&gt;
&lt;br /&gt;
== General Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What is Opus? Who created it? ===&lt;br /&gt;
&lt;br /&gt;
Opus is a totally open, royalty-free, highly versatile audio codec.&lt;br /&gt;
&lt;br /&gt;
It is primarily designed for interactive speech and music transmission over the Internet, but is also applicable to storage and streaming applications. It incorporates technology from Skype&#039;s &#039;&#039;&#039;[https://en.wikipedia.org/wiki/SILK SILK]&#039;&#039;&#039; codec and Xiph.Org&#039;s &#039;&#039;&#039;[http://celt-codec.org/ CELT]&#039;&#039;&#039; codec. It has been standardized by the &#039;&#039;&#039;[https://www.ietf.org/ Internet Engineering Task Force]&#039;&#039;&#039; (IETF) as &#039;&#039;&#039;[https://tools.ietf.org/html/rfc6716 RFC 6716]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Opus has been in development since early 2007. Programmers associated with &#039;&#039;&#039;[https://xiph.org/ Xiph.Org]&#039;&#039;&#039;, &#039;&#039;&#039;[https://www.skype.com/ Skype]&#039;&#039;&#039; and several other organizations have contributed to its development and to the standardization process as part of the &#039;&#039;&#039;[https://datatracker.ietf.org/wg/codec/charter/ IETF&#039;s Codec Working Group]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== How does Opus compare to other codecs? ===&lt;br /&gt;
&lt;br /&gt;
Opus is distinguished from most high quality formats (eg: AAC, [[Vorbis]], MP3) by having &#039;&#039;&#039;low delay&#039;&#039;&#039; (5 ~ 66.5 ms) and distinguished from most low delay formats (eg: G.711, GSM, Speex) by supporting &#039;&#039;&#039;high audio quality&#039;&#039;&#039; ([https://tools.ietf.org/html/rfc6716#section-2.1.1 details here]).&lt;br /&gt;
&lt;br /&gt;
It meets or exceeds existing codecs&#039; quality across a wide range of bitrates, and it operates at lower delay than virtually any existing compressed format.&lt;br /&gt;
&lt;br /&gt;
Most importantly, the Opus format and its reference implementation are both available under &#039;&#039;&#039;[http://opus-codec.com/license/ liberal, royalty-free licenses]&#039;&#039;&#039;.&amp;lt;br /&amp;gt;&lt;br /&gt;
This makes it:&lt;br /&gt;
* easy to adopt&lt;br /&gt;
* compatible with free software&lt;br /&gt;
* suitable for use as part of the basic infrastructure of the Internet&lt;br /&gt;
&lt;br /&gt;
See the Opus &#039;&#039;&#039;[http://opus-codec.org/comparison comparison page]&#039;&#039;&#039; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus make all those other lossy codecs obsolete? ===&lt;br /&gt;
&lt;br /&gt;
Theoretically, yes.&lt;br /&gt;
&lt;br /&gt;
From a technical point of view (loss, delay, bitrates, ...) it should replace both [[Vorbis]] and [[Speex]], and the common proprietary codecs too.&lt;br /&gt;
&lt;br /&gt;
=== Will Opus replace Vorbis in video files? ===&lt;br /&gt;
&lt;br /&gt;
For Ogg [[Theora]] video files, it can, just the overall size reduction will be minimal and it will break compatibility with existing players.&lt;br /&gt;
&lt;br /&gt;
For WebM video files, the convention is to use the VP9 video codec when using Opus as an audio codec.&lt;br /&gt;
&lt;br /&gt;
=== How do I use Opus? What programs support Opus? ===&lt;br /&gt;
&lt;br /&gt;
Opus decoding support is now included in &#039;&#039;&#039;[http://caniuse.com/opus some Internet browsers]&#039;&#039;&#039; and &#039;&#039;&#039;[[OpusSupport|many applications]]&#039;&#039;&#039;, including &#039;&#039;&#039;[https://www.mozilla.org/firefox Firefox]&#039;&#039;&#039;, &#039;&#039;&#039;[https://www.foobar2000.org/ foobar2000]&#039;&#039;&#039; and &#039;&#039;&#039;[https://www.videolan.org/vlc/ VLC]&#039;&#039;&#039;, as well as in frameworks such as &#039;&#039;&#039;[https://gstreamer.freedesktop.org/ GStreamer]&#039;&#039;&#039; and &#039;&#039;&#039;[https://ffmpeg.org/ FFmpeg]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For now, the best way to &#039;&#039;&#039;encode&#039;&#039;&#039; Opus files is to use the &#039;&#039;&#039;opusenc&#039;&#039;&#039; command-line tool from the &#039;&#039;&#039;[http://opus-codec.com/downloads/ opus-tools package]&#039;&#039;&#039;.&lt;br /&gt;
If you want to encode many files at once (e.g. your music library), you can also try the &#039;&#039;&#039;[http://lamexp.sourceforge.net/ LameXP]&#039;&#039;&#039; converter.&lt;br /&gt;
&lt;br /&gt;
For real-time applications, Opus support is available in &#039;&#039;&#039;[https://www.webrtc.org/ Google&#039;s WebRTC codebase]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Opus is a relatively new codec: many more applications will support it in the near future.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus support higher sampling rates, such as 96 kHz or 192 kHz? ===&lt;br /&gt;
&lt;br /&gt;
Yes and no.&lt;br /&gt;
&lt;br /&gt;
Opus encoding tools like opusenc will happily encode input files that are sampled at 96 or 192 kHz.&lt;br /&gt;
&lt;br /&gt;
However, files at these rates are internally &#039;&#039;&#039;converted to 48 kHz&#039;&#039;&#039; and then only frequencies &#039;&#039;&#039;up to 20 kHz&#039;&#039;&#039; are encoded.&lt;br /&gt;
&lt;br /&gt;
The reason is simple: lossy codecs are designed to preserve audible details while discarding irrelevant information. Since the human ear can only hear up to 20 kHz at best (usually lower than that), frequency content above 20 kHz is the first thing to go.&lt;br /&gt;
&lt;br /&gt;
See Monty&#039;s &#039;&#039;&#039;[https://people.xiph.org/~xiphmont/demo/neil-young.html article]&#039;&#039;&#039; for more details.&lt;br /&gt;
&lt;br /&gt;
If you want a codec to handle higher sampling rates losslessly, use &#039;&#039;&#039;[[FLAC]]&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
=== What are the licensing requirements? ===&lt;br /&gt;
&lt;br /&gt;
The reference Opus source code is released under a three-clause BSD license, which is a very permissive Open Source license. Commercial use and distribution (including in proprietary software) is permitted, provided that some basic conditions specified in the license are met. &lt;br /&gt;
&lt;br /&gt;
Opus is also covered by some patents, for which royalty-free usage rights are granted, under conditions that the authors believe are compatible with (hopefully) all open source licenses, including the GPL (v2 and v3).&lt;br /&gt;
&lt;br /&gt;
See the &#039;&#039;&#039;[http://www.opus-codec.org/license/ Opus Licensing]&#039;&#039;&#039; page for details.&lt;br /&gt;
&lt;br /&gt;
=== Why make Opus free? ===&lt;br /&gt;
&lt;br /&gt;
On the Internet, protocol and codec standards are part of the common infrastructure everyone builds upon.&lt;br /&gt;
&lt;br /&gt;
Most of the value of a high-quality standard is the innovation and inter-operation provided by the systems built on top of it. When a few parties have monopoly rights to monetize a standard, that infrastructure stops being so common and everyone else has more reason to use their own solution instead, increasing cost and reducing efficiency.&lt;br /&gt;
&lt;br /&gt;
Imagine a road system where each type of car could only drive on its own manufacturer&#039;s pavement. We all benefit from living in a world where all the roads are connected.&lt;br /&gt;
&lt;br /&gt;
This is why Opus, unlike many codecs, is free.&lt;br /&gt;
&lt;br /&gt;
=== Is the SILK part of Opus compatible with the SILK implementation shipped in Skype? ===&lt;br /&gt;
&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
The SILK codec, as submitted by Skype to the IETF, was heavily modified as part of its integration within Opus. The modifications are significant enough that it is not possible to just write a &amp;quot;translator&amp;quot;. Even sharing code between Opus and the &amp;quot;old SILK&amp;quot; would be highly complex.&lt;br /&gt;
&lt;br /&gt;
=== Why not keep the SILK and CELT codecs separate? ===&lt;br /&gt;
Opus is more than just two independent codecs with a switch.&lt;br /&gt;
&lt;br /&gt;
In addition to a [https://en.wikipedia.org/wiki/Linear_predictive_coding Linear Prediction] &#039;&#039;&#039;SILK mode&#039;&#039;&#039; and an [https://en.wikipedia.org/wiki/Modified_discrete_cosine_transform MDCT] &#039;&#039;&#039;CELT mode&#039;&#039;&#039; it has a &#039;&#039;&#039;hybrid mode&#039;&#039;&#039;, where speech frequencies up to 8 kHz are encoded with LP while those between 8 and 20 kHz are encoded with MDCT. This is what allows Opus to have such high speech quality around 32 kbps.&lt;br /&gt;
&lt;br /&gt;
Another advantage of the integration is the ability to switch between these 3 modes seamlessly, without any audible &amp;quot;glitches&amp;quot; and without any out-of-band signalling.&lt;br /&gt;
&lt;br /&gt;
=== Now that Opus is standardized, will its development stop, or can it be further improved? ===&lt;br /&gt;
Yes, Opus &#039;&#039;&#039;can&#039;&#039;&#039; and &#039;&#039;&#039;should&#039;&#039;&#039; be improved, because unlike most ITU-T codecs, Opus is only defined in terms of its decoder.&lt;br /&gt;
&lt;br /&gt;
The encoder can keep evolving as long as the bitstream it produces can be decoded by the reference decoder. This is what made it possible for modern MP3 encoders (e.g. &#039;&#039;&#039;[https://en.wikipedia.org/wiki/LAME LAME]&#039;&#039;&#039;) to improve far beyond the original &#039;&#039;&#039;[https://en.wikipedia.org/wiki/L3enc L3enc]&#039;&#039;&#039; and &#039;&#039;&#039;dist10&#039;&#039;&#039; reference implementations.&lt;br /&gt;
&lt;br /&gt;
Although it is unlikely that Opus encoders will see such a spectacular evolution, we certainly hope that future encoders will become much better than the reference encoder.&lt;br /&gt;
&lt;br /&gt;
In fact, the 1.1 libopus release significantly improves on the reference encoder&#039;s quality. See &#039;&#039;&#039;[https://people.xiph.org/~xiphmont/demo/opus/demo3.shtml Monty&#039;s demo]&#039;&#039;&#039; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Will all future Opus releases comply with the [https://tools.ietf.org/html/rfc6716 Opus specification]? ===&lt;br /&gt;
&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
=== In what ways is Opus optimized for the Internet? ===&lt;br /&gt;
&lt;br /&gt;
Opus has good packet loss robustness and concealment, but its optimisations go further.&lt;br /&gt;
&lt;br /&gt;
One of the first things we&#039;ve been asked when designing Opus was to make the rate &#039;&#039;&#039;really&#039;&#039;&#039; adaptable because we never know what kind of rates will be available. This not only meant having a wide range of bitrates, but also being able to vary in small increments.&lt;br /&gt;
&lt;br /&gt;
This is why Opus scales from about &#039;&#039;&#039;6 &#039;&#039;&#039; to &#039;&#039;&#039;512 kb/s&#039;&#039;&#039;, in increments of &#039;&#039;&#039;0.4 kb/s&#039;&#039;&#039; (one byte with 20 ms frames). Opus can have &#039;&#039;&#039;more than 1200 possible bitrates&#039;&#039;&#039; while spending only &#039;&#039;&#039;11 bits&#039;&#039;&#039; signalling the bitrate because UDP already encodes the packet size.&lt;br /&gt;
&lt;br /&gt;
One last aspect is that Opus is simple to transport over RTP, as can be seen from the [https://tools.ietf.org/html/rfc7587 Opus RTP payload format]. For example, it&#039;s possible to decode RTP packets without having even seen the SDP or any out-of-band signalling.&lt;br /&gt;
&lt;br /&gt;
=== What applications for Android can play Opus? ===&lt;br /&gt;
&lt;br /&gt;
Right now, there are just a few but that list is fast growing. Please reference [https://android.stackexchange.com/q/37970/7425 this question on android.stackexchange.com]. Feel free to suggest other applications.&lt;br /&gt;
&lt;br /&gt;
=== When will the next version be released? ===&lt;br /&gt;
&lt;br /&gt;
When it&#039;s done. Seriously, we do not know.&lt;br /&gt;
&lt;br /&gt;
Opus is not a large project with a fixed release schedule.&lt;br /&gt;
&lt;br /&gt;
That being said, our [http://www.opus-codec.org/downloads/ pre-releases] and even the [https://git.xiph.org/?p=opus.git git repository] are generally pretty stable and given proper testing (which you should always do anyway), are safe to distribute.&lt;br /&gt;
&lt;br /&gt;
Just be aware that the API of new features (that have never been included in a stable release) could potentially still change.&lt;br /&gt;
&lt;br /&gt;
== Software Developers&#039; Questions ==&lt;br /&gt;
&lt;br /&gt;
=== On what platforms does Opus run? ===&lt;br /&gt;
&lt;br /&gt;
The Opus code base is written in C89 and should run on the vast majority of recent (and not so recent) CPUs.&lt;br /&gt;
&lt;br /&gt;
Some of the platforms &#039;&#039;&#039;[https://mf4.xiph.org/jenkins/view/opus/ on which Opus has been tested]&#039;&#039;&#039; include x86, x86-64, ARM, Itanium, Blackfin, and SPARC.&lt;br /&gt;
&lt;br /&gt;
=== Is there a fixed-point implementation? ===&lt;br /&gt;
&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
The fixed-point and floating-point decoder and encoder implementations are part of the same code base.&lt;br /&gt;
&lt;br /&gt;
The code defaults to float, so you need to configure with &#039;&#039;&#039;--enable-fixed-point&#039;&#039;&#039; (or define &#039;&#039;&#039;FIXED_POINT&#039;&#039;&#039; if not using the configure script) to build the code for fixed-point.&lt;br /&gt;
&lt;br /&gt;
=== Which implementation should I use? ===&lt;br /&gt;
&lt;br /&gt;
While the implementation in RFC 6716 is what &#039;&#039;defines&#039;&#039; the standard, it is likely not the best and most up-to-date implementation.&lt;br /&gt;
&lt;br /&gt;
The [http://opus-codec.org/ Opus] website was set up for the purpose of continually improving the implementation — in terms of speed, encoding quality, device compatibility, etc — while still conforming to the standard.&lt;br /&gt;
&lt;br /&gt;
All Opus implementations are compatible by definition.&lt;br /&gt;
&lt;br /&gt;
=== How is supporting Opus different from supporting Speex/G.711/MP3? ===&lt;br /&gt;
&lt;br /&gt;
Opus has variable frame durations which can change on the fly, so an Opus decoder needs to be ready to accept packets with durations that are &#039;&#039;&#039;any multiple of 2.5ms&#039;&#039;&#039; up to a &#039;&#039;&#039;maximum of 120ms&#039;&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
The opus encoder and decoder do not need to have matched sampling rates or channel counts.  It is recommended to always just decode at the highest rate the hardware supports (e.g. 48kHz stereo) so the user gets the full quality of whatever the far end is sending.&lt;br /&gt;
&lt;br /&gt;
=== My application doesn&#039;t work. Can anyone help me? ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to get help, but before doing so, there are a few basic things to try:&lt;br /&gt;
&lt;br /&gt;
* Implement your application with uncompressed audio instead of Opus. If it still doesn&#039;t work, then the problem isn&#039;t related to Opus.&lt;br /&gt;
* Read the [http://www.opus-codec.org/docs/ Opus documentation].&lt;br /&gt;
* Read the [https://git.xiph.org/?p=opus.git;a=blob;f=src/opus_demo.c opus_demo.c] source code to see how to use the encoder and decoder.&lt;br /&gt;
&lt;br /&gt;
If you still can&#039;t solve the problem, the best option is to ask for help on the [http://lists.xiph.org/mailman/listinfo/opus mailing list] or on the &#039;&#039;&#039;#opus&#039;&#039;&#039; IRC channel on &#039;&#039;&#039;irc.freenode.net&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== How do I report a bug? ===&lt;br /&gt;
&lt;br /&gt;
If you think you have found a bug in Opus (and not in your application), please [https://trac.xiph.org/newticket?component=Opus file a bug report].&lt;br /&gt;
&lt;br /&gt;
Please include a way for us to reproduce the problem. The best way to do this is to provide an input file, along with the opusenc/opusdec/opus_demo command line that causes the bug to occur.&lt;br /&gt;
&lt;br /&gt;
If the bug cannot be triggered by the command line tools, please provide a simple patch or C file that can help reproduce it. Please also provide any other relevant information, such as OS, CPU, build options, etc.&lt;br /&gt;
&lt;br /&gt;
Don&#039;t hesitate to also contact us on the [http://lists.xiph.org/mailman/listinfo/opus mailing list] or on [irc://irc.freenode.net/opus IRC].&lt;br /&gt;
&lt;br /&gt;
=== What is Opus Custom? ===&lt;br /&gt;
&lt;br /&gt;
Opus Custom is an &#039;&#039;&#039;optional&#039;&#039;&#039; part of the Opus standard that allows for sampling rates other than 8, 12, 16, 24, or 48 kHz and frame sizes other than multiples of 2.5 ms.&lt;br /&gt;
&lt;br /&gt;
Opus Custom requires additional out-of-band signalling that Opus does not normally require and disables many of Opus&#039; coding modes. Also, because it is an optional part of the specification, using Opus Custom may lead to compatibility problems.&lt;br /&gt;
&lt;br /&gt;
For these reasons, its use is discouraged outside of very specific applications, for example:&lt;br /&gt;
* ultra low delay applications where synchronization with the soundcard buffer is important. &lt;br /&gt;
* low-power embedded applications where compatibility with others is not important.&lt;br /&gt;
&lt;br /&gt;
For almost all other types of applications, Opus Custom should not be used.&lt;br /&gt;
&lt;br /&gt;
=== How do I use 44.1 kHz or some other sampling rate not directly supported by Opus? ===&lt;br /&gt;
&lt;br /&gt;
Tools which read or write Opus should inter-operate with other sampling rates by transparently performing sample rate conversion behind the scenes whenever necessary. In particular, software developers should not use Opus Custom for 44.1 kHz support, except in the very specific circumstances outlined above.&lt;br /&gt;
&lt;br /&gt;
Note that it&#039;s generally preferable for a decoder to output at 48kHz, even when you know the original input was 44.1kHz. This is not only because you can skip resampling, but also because many cheaper audio interfaces have poor quality output for 44.1kHz.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;[https://opus-codec.org/downloads/ opus-tools]&#039;&#039;&#039; package source code contains a small, high quality, high performance, BSD licensed resampler which can be used where resampling is required.&lt;br /&gt;
&lt;br /&gt;
=== How is the bitrate setting used in VBR mode? ===&lt;br /&gt;
&lt;br /&gt;
Variable bitrate (VBR) mode allows the bitrate to automatically vary over time based on the audio being encoded, in order to achieve a consistent quality.&lt;br /&gt;
&lt;br /&gt;
The bitrate setting controls the desired quality, on a scale that is calibrated to closely approximate the average bitrate that would be obtained over a large and diverse collection of audio.  The actual bitrate of any particular audio stream may be higher or lower than this average.&lt;br /&gt;
&lt;br /&gt;
=== What frame size should I use? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;20ms&#039;&#039;&#039; frame size works well for most applications.&lt;br /&gt;
&lt;br /&gt;
Smaller frame sizes may be used to achieve lower latency, but have lower quality at a given bitrate.&lt;br /&gt;
&lt;br /&gt;
Sizes greater than 20 ms increase latency and are generally beneficial only at fairly low bitrates, or when used to reduce external overhead (e.g. by reducing the number of packets that are sent).&lt;br /&gt;
&lt;br /&gt;
=== Forward Error correction (FEC) doesn&#039;t appear to do anything! HELP! ===&lt;br /&gt;
&lt;br /&gt;
The in-band FEC feature of Opus helps reduce the harm of packet loss by encoding some information about the prior packet.&lt;br /&gt;
&lt;br /&gt;
In order to make use of in-band FEC the decoder must delay its output by at least one frame so that it can call the decoder with the decode_fec argument on the &#039;&#039;next&#039;&#039; frame in order to reconstruct the missed frame. This works best if it&#039;s integrated with a jitter buffer.&lt;br /&gt;
&lt;br /&gt;
FEC is only used by the encoder under certain conditions:&lt;br /&gt;
* the feature must be enabled via the OPUS_SET_INBAND_FEC CTL&lt;br /&gt;
* the encoder must be told to expect loss via the OPUS_SET_PACKET_LOSS_PERC CTL&lt;br /&gt;
* the codec must be operated in any of the linear prediction or Hybrid modes&lt;br /&gt;
&lt;br /&gt;
Frame durations shorter than 10ms and very high bitrates will use the MDCT modes, where FEC is not available.&lt;br /&gt;
&lt;br /&gt;
Even when FEC is not used, telling the encoder about the expected level of loss will help it make more intelligent decisions. By default the implementation assumes there is no loss.&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t use malloc or much stack on my embedded platform. How do I make Opus work? ===&lt;br /&gt;
&lt;br /&gt;
A normal build of libopus only uses &amp;lt;tt&amp;gt;malloc/free&amp;lt;/tt&amp;gt; in the &amp;lt;tt&amp;gt;_create()&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;_destroy()&amp;lt;/tt&amp;gt; calls, making it safe for realtime use as long as the codec state is pre-created.&lt;br /&gt;
&lt;br /&gt;
To build Opus without the references to &amp;lt;tt&amp;gt;malloc/free&amp;lt;/tt&amp;gt;, you must:&lt;br /&gt;
&lt;br /&gt;
* use &amp;lt;tt&amp;gt;init()&amp;lt;/tt&amp;gt; calls rather than &amp;lt;tt&amp;gt;create()&amp;lt;/tt&amp;gt; calls in your application&lt;br /&gt;
* compile with &amp;lt;tt&amp;gt;CFLAGS=&amp;quot;-DOVERRIDE_OPUS_ALLOC -DOVERRIDE_OPUS_FREE  -D&#039;opus_alloc(x)=NULL&#039; -D&#039;opus_free(x)=NULL&#039; &amp;quot;&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If libopus is built with &amp;lt;tt&amp;gt;-DNONTHREADSAFE_PSEUDOSTACK&amp;lt;/tt&amp;gt; (instead of &amp;lt;tt&amp;gt;VAR_ARRAYS&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;USE_ALLOCA&amp;lt;/tt&amp;gt;), it will use a user-provided block of heap instead of stack for many things, resulting in much lower stack usage.&amp;lt;br&amp;gt;&lt;br /&gt;
This makes the resulting library &#039;&#039;&#039;non-threadsafe&#039;&#039;&#039; and is &#039;&#039;&#039;not recommended&#039;&#039;&#039; on anything except limited embedded platforms.&lt;br /&gt;
&lt;br /&gt;
=== How can I ensure that my software interoperates with other software implementing Opus? ===&lt;br /&gt;
&lt;br /&gt;
For applications using Ogg files, there are some [https://people.xiph.org/~greg/opus_testvectors/ Ogg Opus testvectors] to test decoders and you can test encoders with opusdec. For RTP applications, the opusrtp tool can be useful.&lt;br /&gt;
&lt;br /&gt;
In general, here&#039;s a list of specific issues to check:&lt;br /&gt;
* Can your application handle all frame sizes, including changing the frame size from frame to frame?&lt;br /&gt;
* Does your application properly react to lost packet by calling the decoder with a NULL packet?&lt;br /&gt;
&lt;br /&gt;
=== What is the complexity of Opus? ===&lt;br /&gt;
&lt;br /&gt;
The complexity of Opus varies by a large amount based on the settings used.&lt;br /&gt;
&lt;br /&gt;
It depends on the mode, audio bandwidth, number of channels, and even a &amp;quot;complexity knob&amp;quot; that can trade complexity for quality. It will run easily on any recent PC or smartphone. &lt;br /&gt;
&lt;br /&gt;
For slower embedded CPUs/DSPs, the amount of CPU required will vary depending on the configuration and the exact CPU, so you will need to experiment. Do not expect Opus to run quickly on really slow devices like 8-bit micro-controllers.&lt;br /&gt;
&lt;br /&gt;
=== Opus is using too much CPU for my application. What can I do? ===&lt;br /&gt;
&lt;br /&gt;
First don&#039;t panic and don&#039;t start writing assembly just yet.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible that you&#039;re just not using the right set of options.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re targeting an embedded/mobile platform, chances are the fixed-point build will be faster, so make sure you&#039;re using &#039;&#039;&#039;--enable-fixed-point&#039;&#039;&#039; or defining &#039;&#039;&#039;FIXED_POINT&#039;&#039;&#039; in the build system.&lt;br /&gt;
&lt;br /&gt;
Opus also has a complexity option that can trade quality for complexity. The default is highest quality and highest complexity. You can control this using &#039;&#039;&#039;OPUS_SET_COMPLEXITY()&#039;&#039;&#039; (see the &#039;&#039;&#039;[http://www.opus-codec.org/docs/ Documentation]&#039;&#039;&#039; for details).&lt;br /&gt;
&lt;br /&gt;
If all else fails and you need to optimize the Opus code, see the next question.&lt;br /&gt;
&lt;br /&gt;
=== I would like to optimize/improve/help with Opus. Where should I start? ===&lt;br /&gt;
&lt;br /&gt;
Please &#039;&#039;&#039;[http://www.opus-codec.org/contact/ contact us]&#039;&#039;&#039; before you start, or at least before you get too far.&lt;br /&gt;
&lt;br /&gt;
This will help coordinate the efforts made on Opus and reduce the probability of wasting your time on duplicated effort or going down the wrong path.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus have an echo canceller like Speex does? ===&lt;br /&gt;
&lt;br /&gt;
Echo cancellation is completely independent from codecs.&lt;br /&gt;
&lt;br /&gt;
You can use any echo canceller (including the one from libspeexdsp) along with Opus.&lt;br /&gt;
&lt;br /&gt;
That being said, among the free acoustic echo cancelers (AEC) we&#039;re aware of, the best is probably the Google AEC from the [https://code.google.com/p/webrtc/ WebRTC codebase].&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusExtensions&amp;diff=16348</id>
		<title>OpusExtensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusExtensions&amp;diff=16348"/>
		<updated>2016-05-01T04:12:43Z</updated>

		<summary type="html">&lt;p&gt;MarkH: RFC 7845&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;Opus audio data packets begin with a &amp;quot;table of contents&amp;quot; (TOC) sequence which defines the frame duration, audio bandwidth and coding mode of the packet, as well as describing how individual frames are packed into the data packet. [[https://tools.ietf.org/html/rfc6716#section-3.1 RFC 6716 Section 3.1]]. Other types of data packets are used with Opus in various containers are designed to start with a sequence which is not a valid TOC. This simplifies sorting such data for muxing implementations and ensures they will be rejected by the decoder if they are accidentally passed as Opus audio data.&lt;br /&gt;
&lt;br /&gt;
Below is a list of such alternate sequences, to avoid duplication.&lt;br /&gt;
&lt;br /&gt;
== List of reserved invalid Opus TOC sequences ==&lt;br /&gt;
&lt;br /&gt;
* `Op` is used as a prefix for metadata headers in .opus files. [https://tools.ietf.org/html/rfc7845 RFC 7845]&lt;br /&gt;
* &#039;0x3FF&#039; in the first 11 bits marks an `opus_control_header` in MPEG-TS. [[OpusTS]]&lt;br /&gt;
&lt;br /&gt;
== Space of all invalid Opus TOC sequences ==&lt;br /&gt;
&lt;br /&gt;
* 0x0300&lt;br /&gt;
* 0x030D...0x0340&lt;br /&gt;
* 0x034D...0x0380&lt;br /&gt;
* 0x038D...0x03C0&lt;br /&gt;
* 0x03CD...0x03FF&lt;br /&gt;
&lt;br /&gt;
* 0x0700&lt;br /&gt;
* 0x070D...0x0740&lt;br /&gt;
* 0x074D...0x0780&lt;br /&gt;
* 0x078D...0x07C0&lt;br /&gt;
* 0x07CD...0x07FF&lt;br /&gt;
&lt;br /&gt;
* 0x0B00&lt;br /&gt;
* 0x0B07...0x0B40&lt;br /&gt;
* 0x0B47...0x0B80&lt;br /&gt;
* 0x0B87...0x0BC0&lt;br /&gt;
* 0x0BC7...0x0BFF&lt;br /&gt;
&lt;br /&gt;
* 0x0F00&lt;br /&gt;
* 0x0F07...0x0F40&lt;br /&gt;
* 0x0F47...0x0F80&lt;br /&gt;
* 0x0F87...0x0FC0&lt;br /&gt;
* 0x0FC7...0x0FFF&lt;br /&gt;
&lt;br /&gt;
* 0x1300&lt;br /&gt;
* 0x1304...0x1340&lt;br /&gt;
* 0x1344...0x1380&lt;br /&gt;
* 0x1384...0x13C0&lt;br /&gt;
* 0x13C4...0x13FF&lt;br /&gt;
&lt;br /&gt;
* 0x1700&lt;br /&gt;
* 0x1704...0x1740&lt;br /&gt;
* 0x1744...0x1780&lt;br /&gt;
* 0x1784...0x17C0&lt;br /&gt;
* 0x17C4...0x17FF&lt;br /&gt;
&lt;br /&gt;
* 0x1B00&lt;br /&gt;
* 0x1B03...0x1B40&lt;br /&gt;
* 0x1B43...0x1B80&lt;br /&gt;
* 0x1B83...0x1BC0&lt;br /&gt;
* 0x1BC3...0x1BFF&lt;br /&gt;
&lt;br /&gt;
* 0x1F00&lt;br /&gt;
* 0x1F03...0x1F40&lt;br /&gt;
* 0x1F43...0x1F80&lt;br /&gt;
* 0x1F83...0x1FC0&lt;br /&gt;
* 0x1FC3...0x1FFF&lt;br /&gt;
&lt;br /&gt;
* 0x2300&lt;br /&gt;
* 0x230D...0x2340&lt;br /&gt;
* 0x234D...0x2380&lt;br /&gt;
* 0x238D...0x23C0&lt;br /&gt;
* 0x23CD...0x23FF&lt;br /&gt;
&lt;br /&gt;
* 0x2700&lt;br /&gt;
* 0x270D...0x2740&lt;br /&gt;
* 0x274D...0x2780&lt;br /&gt;
* 0x278D...0x27C0&lt;br /&gt;
* 0x27CD...0x27FF&lt;br /&gt;
&lt;br /&gt;
* 0x2B00&lt;br /&gt;
* 0x2B07...0x2B40&lt;br /&gt;
* 0x2B47...0x2B80&lt;br /&gt;
* 0x2B87...0x2BC0&lt;br /&gt;
* 0x2BC7...0x2BFF&lt;br /&gt;
&lt;br /&gt;
* 0x2F00&lt;br /&gt;
* 0x2F07...0x2F40&lt;br /&gt;
* 0x2F47...0x2F80&lt;br /&gt;
* 0x2F87...0x2FC0&lt;br /&gt;
* 0x2FC7...0x2FFF&lt;br /&gt;
&lt;br /&gt;
* 0x3300&lt;br /&gt;
* 0x3304...0x3340&lt;br /&gt;
* 0x3344...0x3380&lt;br /&gt;
* 0x3384...0x33C0&lt;br /&gt;
* 0x33C4...0x33FF&lt;br /&gt;
&lt;br /&gt;
* 0x3700&lt;br /&gt;
* 0x3704...0x3740&lt;br /&gt;
* 0x3744...0x3780&lt;br /&gt;
* 0x3784...0x37C0&lt;br /&gt;
* 0x37C4...0x37FF&lt;br /&gt;
&lt;br /&gt;
* 0x3B00&lt;br /&gt;
* 0x3B03...0x3B40&lt;br /&gt;
* 0x3B43...0x3B80&lt;br /&gt;
* 0x3B83...0x3BC0&lt;br /&gt;
* 0x3BC3...0x3BFF&lt;br /&gt;
&lt;br /&gt;
* 0x3F00&lt;br /&gt;
* 0x3F03...0x3F40&lt;br /&gt;
* 0x3F43...0x3F80&lt;br /&gt;
* 0x3F83...0x3FC0&lt;br /&gt;
* 0x3FC3...0x3FFF&lt;br /&gt;
&lt;br /&gt;
* 0x4300&lt;br /&gt;
* 0x430D...0x4340&lt;br /&gt;
* 0x434D...0x4380&lt;br /&gt;
* 0x438D...0x43C0&lt;br /&gt;
* 0x43CD...0x43FF&lt;br /&gt;
&lt;br /&gt;
* 0x4700&lt;br /&gt;
* 0x470D...0x4740&lt;br /&gt;
* 0x474D...0x4780&lt;br /&gt;
* 0x478D...0x47C0&lt;br /&gt;
* 0x47CD...0x47FF&lt;br /&gt;
&lt;br /&gt;
* 0x4B00&lt;br /&gt;
* 0x4B07...0x4B40&lt;br /&gt;
* 0x4B47...0x4B80&lt;br /&gt;
* 0x4B87...0x4BC0&lt;br /&gt;
* 0x4BC7...0x4BFF&lt;br /&gt;
&lt;br /&gt;
* 0x4F00&lt;br /&gt;
* 0x4F07...0x4F40&lt;br /&gt;
* 0x4F47...0x4F6F&lt;br /&gt;
* 0x4F70 (&amp;quot;Op&amp;quot;): ID and Comment headers in .opus files [https://tools.ietf.org/html/rfc7845 RFC 7845]&lt;br /&gt;
* 0x4F71...0x4F80&lt;br /&gt;
* 0x4F87...0x4FC0&lt;br /&gt;
* 0x4FC7...0x4FFF&lt;br /&gt;
&lt;br /&gt;
* 0x5300&lt;br /&gt;
* 0x5304...0x5340&lt;br /&gt;
* 0x5344...0x5380&lt;br /&gt;
* 0x5384...0x53C0&lt;br /&gt;
* 0x53C4...0x53FF&lt;br /&gt;
&lt;br /&gt;
* 0x5700&lt;br /&gt;
* 0x5704...0x5740&lt;br /&gt;
* 0x5744...0x5780&lt;br /&gt;
* 0x5784...0x57C0&lt;br /&gt;
* 0x57C4...0x57FF&lt;br /&gt;
&lt;br /&gt;
* 0x5B00&lt;br /&gt;
* 0x5B03...0x5B40&lt;br /&gt;
* 0x5B43...0x5B80&lt;br /&gt;
* 0x5B83...0x5BC0&lt;br /&gt;
* 0x5BC3...0x5BFF&lt;br /&gt;
&lt;br /&gt;
* 0x5F00&lt;br /&gt;
* 0x5F03...0x5F40&lt;br /&gt;
* 0x5F43...0x5F80&lt;br /&gt;
* 0x5F83...0x5FC0&lt;br /&gt;
* 0x5FC3...0x5FFF&lt;br /&gt;
&lt;br /&gt;
* 0x6300&lt;br /&gt;
* 0x630D...0x6340&lt;br /&gt;
* 0x634D...0x6380&lt;br /&gt;
* 0x638D...0x63C0&lt;br /&gt;
* 0x63CD...0x63FF&lt;br /&gt;
&lt;br /&gt;
* 0x6700&lt;br /&gt;
* 0x670D...0x6740&lt;br /&gt;
* 0x674D...0x6780&lt;br /&gt;
* 0x678D...0x67C0&lt;br /&gt;
* 0x67CD...0x67FF&lt;br /&gt;
&lt;br /&gt;
* 0x6B00&lt;br /&gt;
* 0x6B07...0x6B40&lt;br /&gt;
* 0x6B47...0x6B80&lt;br /&gt;
* 0x6B87...0x6BC0&lt;br /&gt;
* 0x6BC7...0x6BFF&lt;br /&gt;
&lt;br /&gt;
* 0x6F00&lt;br /&gt;
* 0x6F07...0x6F40&lt;br /&gt;
* 0x6F47...0x6F80&lt;br /&gt;
* 0x6F87...0x6FC0&lt;br /&gt;
* 0x6FC7...0x6FFF&lt;br /&gt;
&lt;br /&gt;
* 0x7300&lt;br /&gt;
* 0x730D...0x7340&lt;br /&gt;
* 0x734D...0x7380&lt;br /&gt;
* 0x738D...0x73C0&lt;br /&gt;
* 0x73CD...0x73FF&lt;br /&gt;
&lt;br /&gt;
* 0x7700&lt;br /&gt;
* 0x770D...0x7740&lt;br /&gt;
* 0x774D...0x7780&lt;br /&gt;
* 0x778D...0x77C0&lt;br /&gt;
* 0x77CD...0x77FF&lt;br /&gt;
&lt;br /&gt;
* 0x7B00&lt;br /&gt;
* 0x7B07...0x7B40&lt;br /&gt;
* 0x7B47...0x7B80&lt;br /&gt;
* 0x7B87...0x7BC0&lt;br /&gt;
* 0x7BC7...0x7BFF&lt;br /&gt;
&lt;br /&gt;
* 0x7F00&lt;br /&gt;
* 0x7F07...0x7F40&lt;br /&gt;
* 0x7F47...0x7F80&lt;br /&gt;
* 0x7F87...0x7FC0&lt;br /&gt;
* 0x7FC7...0x7FDF&lt;br /&gt;
* 0x7FE0...0x7FFF: opus_control_header in MPEG-TS [[OpusTS]]&lt;br /&gt;
&lt;br /&gt;
* 0x8300&lt;br /&gt;
* 0x8331...0x8340&lt;br /&gt;
* 0x8371...0x8380&lt;br /&gt;
* 0x83B1...0x83C0&lt;br /&gt;
* 0x83F1...0x83FF&lt;br /&gt;
&lt;br /&gt;
* 0x8700&lt;br /&gt;
* 0x8731...0x8740&lt;br /&gt;
* 0x8771...0x8780&lt;br /&gt;
* 0x87B1...0x87C0&lt;br /&gt;
* 0x87F1...0x87FF&lt;br /&gt;
&lt;br /&gt;
* 0x8B00&lt;br /&gt;
* 0x8B19...0x8B40&lt;br /&gt;
* 0x8B59...0x8B80&lt;br /&gt;
* 0x8B99...0x8BC0&lt;br /&gt;
* 0x8BD9...0x8BFF&lt;br /&gt;
&lt;br /&gt;
* 0x8F00&lt;br /&gt;
* 0x8F19...0x8F40&lt;br /&gt;
* 0x8F59...0x8F80&lt;br /&gt;
* 0x8F99...0x8FC0&lt;br /&gt;
* 0x8FD9...0x8FFF&lt;br /&gt;
&lt;br /&gt;
* 0x9300&lt;br /&gt;
* 0x930D...0x9340&lt;br /&gt;
* 0x934D...0x9380&lt;br /&gt;
* 0x938D...0x93C0&lt;br /&gt;
* 0x93CD...0x93FF&lt;br /&gt;
&lt;br /&gt;
* 0x9700&lt;br /&gt;
* 0x970D...0x9740&lt;br /&gt;
* 0x974D...0x9780&lt;br /&gt;
* 0x978D...0x97C0&lt;br /&gt;
* 0x97CD...0x97FF&lt;br /&gt;
&lt;br /&gt;
* 0x9B00&lt;br /&gt;
* 0x9B07...0x9B40&lt;br /&gt;
* 0x9B47...0x9B80&lt;br /&gt;
* 0x9B87...0x9BC0&lt;br /&gt;
* 0x9BC7...0x9BFF&lt;br /&gt;
&lt;br /&gt;
* 0x9F00&lt;br /&gt;
* 0x9F07...0x9F40&lt;br /&gt;
* 0x9F47...0x9F80&lt;br /&gt;
* 0x9F87...0x9FC0&lt;br /&gt;
* 0x9FC7...0x9FFF&lt;br /&gt;
&lt;br /&gt;
* 0xA300&lt;br /&gt;
* 0xA331...0xA340&lt;br /&gt;
* 0xA371...0xA380&lt;br /&gt;
* 0xA3B1...0xA3C0&lt;br /&gt;
* 0xA3F1...0xA3FF&lt;br /&gt;
&lt;br /&gt;
* 0xA700&lt;br /&gt;
* 0xA731...0xA740&lt;br /&gt;
* 0xA771...0xA780&lt;br /&gt;
* 0xA7B1...0xA7C0&lt;br /&gt;
* 0xA7F1...0xA7FF&lt;br /&gt;
&lt;br /&gt;
* 0xAB00&lt;br /&gt;
* 0xAB19...0xAB40&lt;br /&gt;
* 0xAB59...0xAB80&lt;br /&gt;
* 0xAB99...0xABC0&lt;br /&gt;
* 0xABD9...0xABFF&lt;br /&gt;
&lt;br /&gt;
* 0xAF00&lt;br /&gt;
* 0xAF19...0xAF40&lt;br /&gt;
* 0xAF59...0xAF80&lt;br /&gt;
* 0xAF99...0xAFC0&lt;br /&gt;
* 0xAFD9...0xAFFF&lt;br /&gt;
&lt;br /&gt;
* 0xB300&lt;br /&gt;
* 0xB30D...0xB340&lt;br /&gt;
* 0xB34D...0xB380&lt;br /&gt;
* 0xB38D...0xB3C0&lt;br /&gt;
* 0xB3CD...0xB3FF&lt;br /&gt;
&lt;br /&gt;
* 0xB700&lt;br /&gt;
* 0xB70D...0xB740&lt;br /&gt;
* 0xB74D...0xB780&lt;br /&gt;
* 0xB78D...0xB7C0&lt;br /&gt;
* 0xB7CD...0xB7FF&lt;br /&gt;
&lt;br /&gt;
* 0xBB00&lt;br /&gt;
* 0xBB07...0xBB40&lt;br /&gt;
* 0xBB47...0xBB80&lt;br /&gt;
* 0xBB87...0xBBC0&lt;br /&gt;
* 0xBBC7...0xBBFF&lt;br /&gt;
&lt;br /&gt;
* 0xBF00&lt;br /&gt;
* 0xBF07...0xBF40&lt;br /&gt;
* 0xBF47...0xBF80&lt;br /&gt;
* 0xBF87...0xBFC0&lt;br /&gt;
* 0xBFC7...0xBFFF&lt;br /&gt;
&lt;br /&gt;
* 0xC300&lt;br /&gt;
* 0xC331...0xC340&lt;br /&gt;
* 0xC371...0xC380&lt;br /&gt;
* 0xC3B1...0xC3C0&lt;br /&gt;
* 0xC3F1...0xC3FF&lt;br /&gt;
&lt;br /&gt;
* 0xC700&lt;br /&gt;
* 0xC731...0xC740&lt;br /&gt;
* 0xC771...0xC780&lt;br /&gt;
* 0xC7B1...0xC7C0&lt;br /&gt;
* 0xC7F1...0xC7FF&lt;br /&gt;
&lt;br /&gt;
* 0xCB00&lt;br /&gt;
* 0xCB19...0xCB40&lt;br /&gt;
* 0xCB59...0xCB80&lt;br /&gt;
* 0xCB99...0xCBC0&lt;br /&gt;
* 0xCBD9...0xCBFF&lt;br /&gt;
&lt;br /&gt;
* 0xCF00&lt;br /&gt;
* 0xCF19...0xCF40&lt;br /&gt;
* 0xCF59...0xCF80&lt;br /&gt;
* 0xCF99...0xCFC0&lt;br /&gt;
* 0xCFD9...0xCFFF&lt;br /&gt;
&lt;br /&gt;
* 0xD300&lt;br /&gt;
* 0xD30D...0xD340&lt;br /&gt;
* 0xD34D...0xD380&lt;br /&gt;
* 0xD38D...0xD3C0&lt;br /&gt;
* 0xD3CD...0xD3FF&lt;br /&gt;
&lt;br /&gt;
* 0xD700&lt;br /&gt;
* 0xD70D...0xD740&lt;br /&gt;
* 0xD74D...0xD780&lt;br /&gt;
* 0xD78D...0xD7C0&lt;br /&gt;
* 0xD7CD...0xD7FF&lt;br /&gt;
&lt;br /&gt;
* 0xDB00&lt;br /&gt;
* 0xDB07...0xDB40&lt;br /&gt;
* 0xDB47...0xDB80&lt;br /&gt;
* 0xDB87...0xDBC0&lt;br /&gt;
* 0xDBC7...0xDBFF&lt;br /&gt;
&lt;br /&gt;
* 0xDF00&lt;br /&gt;
* 0xDF07...0xDF40&lt;br /&gt;
* 0xDF47...0xDF80&lt;br /&gt;
* 0xDF87...0xDFC0&lt;br /&gt;
* 0xDFC7...0xDFFF&lt;br /&gt;
&lt;br /&gt;
* 0xE300&lt;br /&gt;
* 0xE331...0xE340&lt;br /&gt;
* 0xE371...0xE380&lt;br /&gt;
* 0xE3B1...0xE3C0&lt;br /&gt;
* 0xE3F1...0xE3FF&lt;br /&gt;
&lt;br /&gt;
* 0xE700&lt;br /&gt;
* 0xE731...0xE740&lt;br /&gt;
* 0xE771...0xE780&lt;br /&gt;
* 0xE7B1...0xE7C0&lt;br /&gt;
* 0xE7F1...0xE7FF&lt;br /&gt;
&lt;br /&gt;
* 0xEB00&lt;br /&gt;
* 0xEB19...0xEB40&lt;br /&gt;
* 0xEB59...0xEB80&lt;br /&gt;
* 0xEB99...0xEBC0&lt;br /&gt;
* 0xEBD9...0xEBFF&lt;br /&gt;
&lt;br /&gt;
* 0xEF00&lt;br /&gt;
* 0xEF19...0xEF40&lt;br /&gt;
* 0xEF59...0xEF80&lt;br /&gt;
* 0xEF99...0xEFC0&lt;br /&gt;
* 0xEFD9...0xEFFF&lt;br /&gt;
&lt;br /&gt;
* 0xF300&lt;br /&gt;
* 0xF30D...0xF340&lt;br /&gt;
* 0xF34D...0xF380&lt;br /&gt;
* 0xF38D...0xF3C0&lt;br /&gt;
* 0xF3CD...0xF3FF&lt;br /&gt;
&lt;br /&gt;
* 0xF700&lt;br /&gt;
* 0xF70D...0xF740&lt;br /&gt;
* 0xF74D...0xF780&lt;br /&gt;
* 0xF78D...0xF7C0&lt;br /&gt;
* 0xF7CD...0xF7FF&lt;br /&gt;
&lt;br /&gt;
* 0xFB00&lt;br /&gt;
* 0xFB07...0xFB40&lt;br /&gt;
* 0xFB47...0xFB80&lt;br /&gt;
* 0xFB87...0xFBC0&lt;br /&gt;
* 0xFBC7...0xFBFF&lt;br /&gt;
&lt;br /&gt;
* 0xFF00&lt;br /&gt;
* 0xFF07...0xFF40&lt;br /&gt;
* 0xFF47...0xFF80&lt;br /&gt;
* 0xFF87...0xFFC0&lt;br /&gt;
* 0xFFC7...0xFFFF&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=MatroskaOpus&amp;diff=16347</id>
		<title>MatroskaOpus</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=MatroskaOpus&amp;diff=16347"/>
		<updated>2016-05-01T04:10:35Z</updated>

		<summary type="html">&lt;p&gt;MarkH: RFC 7845&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{draft}}&lt;br /&gt;
This is an encapsulation spec for the [[Opus]] codec in [http://matroska.org/ Matroska]. There are a number of outstanding functional issues with muxing Opus in Matroska, and until those are resolved, use of this spec is NOT RECOMMENDED.&lt;br /&gt;
&lt;br /&gt;
* CodecID is A_OPUS&lt;br /&gt;
* SampleFrequecy is 48000&lt;br /&gt;
* Channels is number of output PCM channels&lt;br /&gt;
* SeekPreRoll is set to 80000000&lt;br /&gt;
* CodecPrivate consists of the &#039;OpusHead&#039; packet, identical to the Ogg mapping.&lt;br /&gt;
&lt;br /&gt;
The &#039;OpusHead&#039; format is defined by the [https://tools.ietf.org/html/rfc7845 Ogg Opus] mapping. In particular it includes pre-skip, gain, and the channel mapping table required for correct surround output.&lt;br /&gt;
&lt;br /&gt;
The second &#039;OpusTags&#039; header packet from Ogg Opus is not used in the Matroska encapsulation. Matroska has its own system for tag metadata, and this avoids duplicating it and the need for sub-framing to index multiple packets within the CodecPrivate element.&lt;br /&gt;
&lt;br /&gt;
SeekPreRoll [56][BB] is a new unsigned integer element added to the TrackEntry element. The value is the number of nanoseconds that must be discarded, for that stream, after a seek until the decoded data is valid to render.&lt;br /&gt;
&lt;br /&gt;
CodecDelay [56][AA] is a new unsigned integer element added to the TrackEntry element. The value is the number of nanoseconds that must be discarded, for that stream, from the start of that stream. The value is also the number of nanoseconds that all encoded timestamps for that stream must be shifted to get the presentation timestamp. (This will fix Vorbis encoding as well.)&lt;br /&gt;
&lt;br /&gt;
DiscardPadding [75][A2] is a new signed integer element added to the BlockGroup element. DiscardPadding is the duration in nanoseconds of the silent data added to the Block (padding at the end of the block). The duration of DiscardPadding is not calculated in the duration of the Track and should be discarded during playback. (This will fix Vorbis encoding as well.)&lt;br /&gt;
&lt;br /&gt;
== Muxing Recommendations ==&lt;br /&gt;
&lt;br /&gt;
In order to prevent extraneous parsing of muxed content for the players that want to start playback at exactly time T, we will recommend muxers create files with another Cluster within N-1 at T-SeekPreRoll, where T is the start time of Cluster N. Then add CuePoints for all the new T-SeekPreRoll Clusters with a CueTrack of the audio stream. The CuePoints for the video stream will not change. &lt;br /&gt;
&lt;br /&gt;
For example, a file is a muxed MKV with the following characteristics: &lt;br /&gt;
* 5 second interval between video keyframes&lt;br /&gt;
* Each video keyframe begins a new Cluster&lt;br /&gt;
* Cues will contain video keyframe CuePoints&lt;br /&gt;
* For each video keyframe at time T there will be new Cluster at T-SeekPreRoll&lt;br /&gt;
* Cues will contain audio CuePoints for T-SeekPreRoll Clusters&lt;br /&gt;
* Audio and video are interleaved in monotonically increasing order&lt;br /&gt;
&lt;br /&gt;
Assume SeekPreRoll is 80 milliseconds, the first Cluster starts at 0 milliseconds with a video keyframe Block and has a duration of 4920 milliseconds. The second Cluster starts at 4920 milliseconds with an audio Block and has a duration of 80 milliseconds. Just to be clear, the second Cluster can contain Blocks from all streams. The third Cluster starts at 5000 milliseconds with a video keyframe Block and has a duration of 4920 milliseconds. The fourth Cluster starts at 9920 milliseconds with an audio Block and has a duration of 80 milliseconds.&lt;br /&gt;
&lt;br /&gt;
With this recommendation players that want audio and video to start playback at time T can seek to Cluster T-SeekPreRoll and start decoding the audio stream. This will work the same for both local and HTTP playback.&lt;br /&gt;
&lt;br /&gt;
== Open Questions ==&lt;br /&gt;
&lt;br /&gt;
* Should we say muxers MAY or SHOULD NOT produce simple streams without filling in CodecPrivate?&lt;br /&gt;
** If the CodecPrivate is empty or not present and Channels is 1 or 2, players MAY treat it as a sane set of defaults, I guess. e.g. channel mapping family 0, no pre-skip or gain.&lt;br /&gt;
** For Channels &amp;gt; 2 the track MUST be rejected, since there&#039;s no way to map the encoded substreams to channels.&lt;br /&gt;
** We would also have to decide on a default value for OutputGain.&lt;br /&gt;
** Version must be 1.&lt;br /&gt;
* How can sample-accurate end-time trimming work in Matroska?&lt;br /&gt;
** We defined a new element added to a BlockGroup, DiscardPadding (previously PostPadding), which is defined as the number of nanoseconds to discard from the Block.&lt;br /&gt;
** Currently all software encapsulating Vorbis in Matroska is broken in this regard, and muxing a Vorbis file in Matroska causes it to get longer (i.e., produce more audio output than the original Ogg file). It would be unfortunate to repeat this disaster for Opus. This needs a new element specifying the number of samples to trim, perhaps a new BlockGroup child.&lt;br /&gt;
*** This has been addressed with DiscardPadding for Opus. DiscardPadding was speced to fix Vorbis (as well as other codecs) too.&lt;br /&gt;
* If new elements are required, can they be defined so as to enable correct seeking in rolling intra (a.k.a intra refresh) video as well?&lt;br /&gt;
** SeekPreRoll should work for rolling intra video.&lt;br /&gt;
&lt;br /&gt;
== Handling Pre-skip data ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;On [http://lists.matroska.org/cgi-bin/mailman/listinfo/matroska-devel Matroska-dev] we decided to implement proposal one ([http://lists.matroska.org/pipermail/matroska-devel/2013-June/004475.html ref]).&#039;&#039;&#039;&lt;br /&gt;
* Use Cases: &lt;br /&gt;
** UC1: Playback starts from the beginning of the stream. Source stream time starts at 0.&lt;br /&gt;
** UC2: Playback starts from the beginning of the stream. Pre-skip data ends in middle of compressed packet.&lt;br /&gt;
** UC3: Playback starts from the middle of the stream &amp;gt; SeekPreRoll time.&lt;br /&gt;
** UC4: Playback starts from the middle of the stream &amp;lt; SeekPreRoll time.&lt;br /&gt;
** UC5: Encode source stream to Opus, mux to Matroksa, then decode Opus stream, must have same number of samples as source stream.&lt;br /&gt;
&lt;br /&gt;
* one: Timeshift the timestamps by pre-skip data.&lt;br /&gt;
** The Opus audio stream pre-skip data starts from time 0 and adds the pre-skip time to the normal audio time, like how Opus files are muxed into ogg files. We would add a new element to the TrackEntry element, CodecDelay, and the player would adjust the timestamps of the decoded samples by subtracting CodecDelay. All use cases should be covered.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** The timestamp of the Block does not match the timestamp of the playback position.&lt;br /&gt;
*** Does not generalize known &amp;quot;decode, but not render&amp;quot; data.&lt;br /&gt;
*** Forces the player to handle the pre-skip samples. I.e. not the decoder.&lt;br /&gt;
&lt;br /&gt;
* two: Add pre-skip data to CodecPrivate.&lt;br /&gt;
** On every discontinuity the decoder would need to decode and throw away the pre-skip data.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** UC2 will throw away valid data and the AV sync will be off.&lt;br /&gt;
*** UC3 will redundantly decode the pre-skip data.&lt;br /&gt;
&lt;br /&gt;
* three: Add TimeToDiscard to Block.&lt;br /&gt;
** Add an element to the Block element, TimeToDiscard in nanoseconds. A value of -1 would not render the whole Block, which would have the same effect as setting the invisible bit. How would this affect the Block timestamp? Maybe the new element should be SamplesToDiscard or DataToDiscard?&lt;br /&gt;
** Cons:&lt;br /&gt;
&lt;br /&gt;
* four: Blocks that contain pre-skip data will set invisible flag.&lt;br /&gt;
** Blocks that contain pre-skip data have timestamps from the beginning of the stream. Blocks that only contain normal data have timestamps from the playback position.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** Forces the player to handle the pre-skip samples. I.e. not the decoder.&lt;br /&gt;
*** UC2 will throw away valid data and the AV sync will be off. Other use cases should be fine.&lt;br /&gt;
&lt;br /&gt;
* five: Force pre-skip packets to be prepended to the first normal packet in the first Block.&lt;br /&gt;
** The first Block&#039;s timestmap will be set to the start time of the source playback position. We would add a new element to the TrackEntry element, CodecDelay. All use cases should be covered.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** Does not generalize known &amp;quot;decode, but not render&amp;quot; data.&lt;br /&gt;
*** Forces the player to handle the pre-skip samples. I.e. not the decoder.&lt;br /&gt;
&lt;br /&gt;
* six: Create a new codec, OPUS_MKV.&lt;br /&gt;
** Basically the codec will wrap Opus packets with data telling the decoder what type of Opus packet it contains. Essentially we would be creating a new codec to handle pre-skip data within the decoder.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** There will be two types of Opus data streams!&lt;br /&gt;
*** Does not generalize known &amp;quot;decode, but not render&amp;quot; data.&lt;br /&gt;
&lt;br /&gt;
* seven: Negative timestamps.&lt;br /&gt;
** The SimpleBlock timestamp is signed 16 bits, so the format can signal about half of the pre-skip if playback timestamps are to start at zero.&lt;br /&gt;
** One could set an incorrect timestamp on the skipped blocks, and rely on the decoder to drop them based on the OpusHead preskip value. As long as the initial blocks are timestamped &amp;lt;= start of output this shouldn&#039;t affect seeking.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** Moritz suggests this won&#039;t work because the resolution of the timestamps is controlled by the muxer, so the SimpleBlock timestamp offset isn&#039;t sample accurate anyway ([http://lists.matroska.org/pipermail/matroska-devel/2012-September/004254.html ref]).&lt;br /&gt;
&lt;br /&gt;
* eight: &amp;lt;!-- Proposal 8 needs a title, here. --&amp;gt;&lt;br /&gt;
** The Ogg format uses granule positions which are converted to presentation timecodes using codec specific information on a per logical stream basis.&lt;br /&gt;
** The Matroska format uses absolute timecodes with an arbitrary per segement accuracy for all tracks in the segment.&lt;br /&gt;
** It is the belief of this tikiman that using a timecode offset of any kind in MKV is unholy.&lt;br /&gt;
** The preskip is communicated to the media software via the Opus header in the codec private data. At the begining of the track, the track timecode is not increased until prekip samples are in track frames.&lt;br /&gt;
** From then on audio is muxed as normal, however the audio should be muxed &amp;gt;= 3840 samples behind video frames.&lt;br /&gt;
*** i.e. Cluster Timecode: 5.000 seconds&lt;br /&gt;
*** Video Track Key Frame 5.000 seconds&lt;br /&gt;
*** Opus Track Frame 4.920 seconds&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=MIME_Types_and_File_Extensions&amp;diff=16346</id>
		<title>MIME Types and File Extensions</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=MIME_Types_and_File_Extensions&amp;diff=16346"/>
		<updated>2016-05-01T04:09:10Z</updated>

		<summary type="html">&lt;p&gt;MarkH: RFC 7845&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;STATUS: [http://www.ietf.org/rfc/rfc5334.txt RFC 5334] encapsulates the below listed policies. More details are [http://wiki.xiph.org/index.php/MIMETypesCodecs here], which also include a specification of the codecs parameter of the MIME types. Use the correct file extensions straight away.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
IMPLEMENTATION recommendations and patches: see [[MIME-Migration]].&lt;br /&gt;
&lt;br /&gt;
== .ogg - audio/ogg ==&lt;br /&gt;
&lt;br /&gt;
* Ogg Vorbis I Profile&lt;br /&gt;
* .ogg applies now for Vorbis I files only&lt;br /&gt;
* .ogg has more recently also been used for Ogg FLAC and for Theora, too &amp;amp;mdash; these uses are deprecated now in favor of .oga and .ogv respectively&lt;br /&gt;
* has been defined in RFC 3534 for application/ogg, so rfc 3534 will be re-defined&lt;br /&gt;
&lt;br /&gt;
RATIONALE: .ogg has traditionally been used for Vorbis I files, in particular in HW players, hence it is kept for backwards-compatibility&lt;br /&gt;
&lt;br /&gt;
== .ogv - video/ogg ==&lt;br /&gt;
&lt;br /&gt;
* Ogg Video Profile (a/v in Ogg container)&lt;br /&gt;
* apps supporting .oga, .ogv SHOULD support decoding from muxed Ogg streams&lt;br /&gt;
* covers e.g. [[Theora]], Theora + Vorbis, Theora + Speex, Theora + FLAC, [[Dirac]] + Vorbis, [[OggMNG|MNG]] + FLAC, [[OggUVS]] inside Ogg&lt;br /&gt;
* This list is not exhaustive (for example, [[Dirac]] + FLAC is acceptable too)&lt;br /&gt;
* SHOULD contain a Skeleton track and/or MAY contain a CMML logical bitstream.&lt;br /&gt;
&lt;br /&gt;
== .opus - audio/ogg ==&lt;br /&gt;
&lt;br /&gt;
* Ogg Opus profile&lt;br /&gt;
* Defined by https://tools.ietf.org/html/rfc7845&lt;br /&gt;
&lt;br /&gt;
== .oga - audio/ogg ==&lt;br /&gt;
&lt;br /&gt;
* Ogg Audio Profile (audio in Ogg container)&lt;br /&gt;
* Applications supporting .oga, .ogv SHOULD support decoding from muxed Ogg streams&lt;br /&gt;
* Covers Ogg [[FLAC]], [[Ghost]], and [[OggPCM]] &lt;br /&gt;
* Although they share the same MIME type, Vorbis, Opus and Speex use different file extensions.&lt;br /&gt;
* SHOULD contain a Skeleton logical bitstream.&lt;br /&gt;
* Vorbis and Speex may use .oga, but it is not the prefered method of distributing these files because of backwards-compatibility issues.&lt;br /&gt;
&lt;br /&gt;
== .ogx - application/ogg ==&lt;br /&gt;
&lt;br /&gt;
* Ogg Multiplex Profile (anything in [[Ogg]])&lt;br /&gt;
* can contain any logical bitstreams multiplexed together in an ogg container&lt;br /&gt;
* will replace the .ogg extension from RFC 3534&lt;br /&gt;
* random multitrack files MUST contain a [[Skeleton]] track to identify all containing logical bitstreams&lt;br /&gt;
* apps that identify a logical bitstream which they cannot decode SHOULD ignore it but MAY still decode the ones they can&lt;br /&gt;
* thus, e.g. an annodex file can gracefully degrade to .ogx if an app cannot decode [[CMML]] and/or [[Skeleton]]&lt;br /&gt;
* USE: application/ogg has been registered, so can be used immediately&lt;br /&gt;
&lt;br /&gt;
== .spx - audio/ogg ==&lt;br /&gt;
&lt;br /&gt;
* Ogg Speex Profile&lt;br /&gt;
* .spx has traditionally been used for Speex files within Ogg and should be considered for backwards-compatibility&lt;br /&gt;
&lt;br /&gt;
== .flac - audio/flac ==&lt;br /&gt;
&lt;br /&gt;
* FLAC in native encapsulation format&lt;br /&gt;
&lt;br /&gt;
== .anx - application/annodex ==&lt;br /&gt;
&lt;br /&gt;
* THIS FILE FORMAT IS DEPRECATED.&lt;br /&gt;
* Profile for multiplexed Ogg that includes a skeleton track and at least one CMML logical bitstream&lt;br /&gt;
* apps that identify a logical bitstream which they cannot decode SHOULD ignore it but MAY still decode the ones they can&lt;br /&gt;
* apps that come across an annodex file and cannot decode CMML and/or Skeleton, but can deal with the others SHOULD gracefully degrade by ignoring these&lt;br /&gt;
&lt;br /&gt;
== .axa - audio/annodex ==&lt;br /&gt;
&lt;br /&gt;
* THIS FILE FORMAT IS DEPRECATED.&lt;br /&gt;
* Profile for audio in Annodex &lt;br /&gt;
* covers e.g. [[Vorbis]], [[Speex]], [[FLAC]], [[Opus]], [[Ghost]], [[OggPCM]] inside Ogg with Skeleton and CMML&lt;br /&gt;
&lt;br /&gt;
== .axv - video/annodex ==&lt;br /&gt;
&lt;br /&gt;
* THIS FILE FORMAT IS DEPRECATED.&lt;br /&gt;
* Profile for video in Annodex &lt;br /&gt;
* covers e.g. [[Theora]], Theora + Vorbis, Theora + Speex, Theora + FLAC, [[Dirac]] + Vorbis, [[OggMNG|MNG]] + FLAC, [[OggUVS]] inside Ogg with Skeleton and CMML&lt;br /&gt;
&lt;br /&gt;
== .xspf - application/xspf+xml ==&lt;br /&gt;
&lt;br /&gt;
* Profile for XSPF&lt;br /&gt;
* Covers [[XSPF]], while being used through XML&lt;br /&gt;
* Does not cover [[JSPF]], which is XSPF but on JSON&lt;br /&gt;
&lt;br /&gt;
== Ogg Kate files - application/kate ==&lt;br /&gt;
&lt;br /&gt;
* Binary representation of Kate encapsulated in Ogg&lt;br /&gt;
* may have a skeleton&lt;br /&gt;
* can be used to identify the mime type of the track itself (e.g. in skeleton)&lt;br /&gt;
* uses .ogx extension when in a file by itself&lt;br /&gt;
* is subdued by the dominant mime type if in a audio or video file to become audio/ogg or video/ogg&lt;br /&gt;
&lt;br /&gt;
== Codec MIME types ==&lt;br /&gt;
&lt;br /&gt;
Codecs need their own MIME types for streaming in RTP and to be used in multitrack ogg files using skeleton:&lt;br /&gt;
&lt;br /&gt;
* audio/vorbis for Vorbis without container&lt;br /&gt;
* video/theora for Theora without container&lt;br /&gt;
* audio/speex for Speex without container&lt;br /&gt;
* audio/flac for FLAC without and in native container&lt;br /&gt;
* audio/opus for Opus without container&lt;br /&gt;
* text/cmml for CMML without container&lt;br /&gt;
* application/kate for the textual representation of Kate (.kate files)&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OggOpus&amp;diff=16345</id>
		<title>OggOpus</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OggOpus&amp;diff=16345"/>
		<updated>2016-05-01T04:05:38Z</updated>

		<summary type="html">&lt;p&gt;MarkH: draft is now RFC 7845&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Superceded by [https://tools.ietf.org/html/rfc7845 RFC 7845].&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Ogg Mapping for Opus ==&lt;br /&gt;
&lt;br /&gt;
The IETF Opus codec is a low-latency audio codec optimized for both voice and general-purpose audio. See the [https://tools.ietf.org/html/rfc6716 Opus Specification] for technical details.&lt;br /&gt;
&lt;br /&gt;
Almost everything about Opus is either fixed or dynamically switchable, so most of the usual ID and setup header parameters in the header packets of an Ogg encapsulation aren&#039;t needed. In particular, bitrate, packet duration, mono/stereo flags, and coding modes are all dynamically switchable from packet to packet. The first one or two bytes in each data packet, the start of the &#039;TOC sequence&#039; that defines the layout of the packet, specifies all of these parameters for that particular packet. See Section 3 of the Opus Specification for the exact format of the TOC sequence.&lt;br /&gt;
&lt;br /&gt;
The remaining parameters that must be signaled are&lt;br /&gt;
&lt;br /&gt;
* The magic number for stream identification,&lt;br /&gt;
* The stream count and coupling for multichannel audio, and&lt;br /&gt;
* Any metadata or tags.&lt;br /&gt;
&lt;br /&gt;
=== Content Type ===&lt;br /&gt;
&lt;br /&gt;
The recommended mime-type for Ogg Opus files is &#039;&#039;&#039;audio/ogg&#039;&#039;&#039;, defined in [https://www.ietf.org/rfc/rfc5334.txt RFC 5334].&lt;br /&gt;
&lt;br /&gt;
If more specificity is desired, one can distinguish Opus files as &#039;audio/ogg; codecs=opus&#039;.&lt;br /&gt;
&lt;br /&gt;
The recommended filename extension for Ogg Opus files is &#039;&#039;&#039;.opus&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Packet Organization ===&lt;br /&gt;
&lt;br /&gt;
Opus is framed in a continuous logical [https://www.xiph.org/ogg/doc/framing.html Ogg stream]. &lt;br /&gt;
&lt;br /&gt;
There are two mandatory headers. The granule position of the pages containing these headers MUST be zero.&lt;br /&gt;
&lt;br /&gt;
The first packet in the logical Ogg stream MUST contain the identification header, which uniquely identifies a stream as Opus audio. It MUST begin with the 8 bytes &amp;quot;OpusHead&amp;quot;. It MUST be placed alone in the first page of the logical Ogg stream. This page MUST have the ’beginning of stream’ flag set.&lt;br /&gt;
&lt;br /&gt;
The second Opus packet MUST contain the comment header. It must begin with the 8 bytes &amp;quot;OpusTags&amp;quot;. It MAY span one or more pages, beginning on the second page of the logical stream. However many pages it spans, the comment header packet MUST finish the page on which it ends.&lt;br /&gt;
&lt;br /&gt;
All subsequent pages are audio data pages and the packets they contain are audio data packets. The first audio page SHOULD NOT have the &#039;continued packet&#039; flag set (which would indicate the first audio packet is continued from a previous page). Packets MUST be placed into Ogg pages in order until the end of stream. Audio packets MAY span page boundaries. A decoder MUST treat a zero-byte audio packet as if it were an Opus packet with an illegal TOC sequence. The last page SHOULD have the &#039;end of stream&#039; flag set, but implementations should be prepared to deal with truncated streams which do not have a page marked &#039;end of stream&#039;. The final packet SHOULD complete on the last page, i.e., the final lacing value should be less than 255. There MUST NOT be any more pages in an Opus logical stream after a page marked &#039;end of stream&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Granule Position ===&lt;br /&gt;
&lt;br /&gt;
The granule position of an audio page encodes the total number of PCM samples in the stream up to and including the last fully-decodable sample from the last packet &#039;&#039;completed&#039;&#039; on that page. A page that is entirely spanned by a single packet (that completes on a subsequent page) has no granule position, and the granule position field MUST be set to the special value ’-1’ in two&#039;s complement.&lt;br /&gt;
&lt;br /&gt;
The granule position of an audio page is in units of PCM audio samples at a fixed rate of 48 kHz (per channel; a stereo stream’s granule position does not increment at twice the speed of a mono stream). It is possible to run a decoder at other sampling rates, but the format and this specification always count samples assuming a 48 kHz decoding rate.&lt;br /&gt;
&lt;br /&gt;
The duration of an Opus packet may be any multiple of 2.5 ms, up to a maximum of 120 ms. This duration is encoded in the TOC sequence at the beginning of each packet. The number of samples returned by a decoder corresponds to this duration exactly, even for the first few packets. For example, a 20 ms packet fed to a decoder running at 48 kHz will always return 960 samples. A demuxer can parse these TOC sequences to work backwards or forwards from a packet with a known granule position (i.e., the last packet completed on some page) in order to assign granule positions to every packet, or even every individual sample. The one exception is the last page in the stream, as described below.&lt;br /&gt;
&lt;br /&gt;
All other pages with completed packets after the first MUST have a granule position equal to the number of samples contained in packets that complete on that page plus the granule position of the most recent page with completed packets. This guarantees that a demuxer can assign individual packets the same granule position when working forwards as when working backwards. There must not be any gaps. In order to support capturing a stream that uses discontinuous transmission (DTX), an encoder SHOULD emit packets that explicitly request the use of Packet Loss Concealment (PLC) (i.e., with a frame length of 0, as defined in Section 3.2.1 of the Opus Specification) in place of the packets that were not transmitted.&lt;br /&gt;
&lt;br /&gt;
There is some amount of latency introduced during the decoding process, to allow for overlap in the MDCT modes, stereo mixing in the LP modes, and resampling, and the encoder will introduce even more latency (though the exact amount is not specified). Therefore the first few samples produced by the decoder do not correspond to any real, input audio, but are instead composed of padding inserted by the encoder to compensate for this latency. These samples must be stored and decoded, as Opus is an asymptotically convergent predictive codec, meaning the decoded contents of each frame depend on the recent history of decoder inputs. A &#039;pre-skip&#039; field in the ID header signals the number of samples which should be skipped at the beginning of the stream. This provides sufficient history to the decoder so that it has already converged before the stream&#039;s output begins. It may also be used to perform sample-accurate cropping of existing encoded streams. This amount need not be a multiple of 2.5 ms, may be smaller than a single packet, or may span the contents of several packets.&lt;br /&gt;
&lt;br /&gt;
The PCM sample position is determined from the granule position using the formula&lt;br /&gt;
&lt;br /&gt;
 &#039;PCM sample position&#039; = &#039;granule position&#039; - &#039;pre-skip&#039; .&lt;br /&gt;
&lt;br /&gt;
For example, if the granule position of the first page is 59971, and the pre-skip is 11971, then the PCM sample position of the last decoded sample from the first page is 48000. This may be converted into a playback time using the formula&lt;br /&gt;
&lt;br /&gt;
                   &#039;PCM sample position&#039;&lt;br /&gt;
 &#039;playback time&#039; = --------------------- .&lt;br /&gt;
                          48000.0&lt;br /&gt;
&lt;br /&gt;
The initial PCM sample position before any samples are played is normally &#039;0&#039;. In this case, the PCM sample position of the first audio sample to be played starts at &#039;1&#039;, because it marks the time on the clock &#039;&#039;after&#039;&#039; that sample has been played, and a stream that is exactly one second long has a final PCM sample position of &#039;48000&#039;, as in the example here.&lt;br /&gt;
&lt;br /&gt;
Vorbis streams use a granule position smaller than the number of audio samples contained in the first page to indicate that some of those samples must be trimmed from the output. However, to do so it requires that the first page contains exactly two packets, in order to allow the decoder to perform PCM position adjustments before needing to return any PCM data. Opus uses the pre-skip mechanism for this purpose instead, since the encoder may introduce more than a single packet&#039;s worth of latency, and since very large packets in streams with a very large number of channels may not fit on a single page.&lt;br /&gt;
&lt;br /&gt;
The page with the &#039;end of stream&#039; flag set MAY have a granule position that indicates the page contains less audio data than would normally be returned by decoding up through the final packet. This is used to end the stream somewhere other than an even frame boundary. The granule position of the most recent audio page with completed packets is used to make this determination, or &#039;0&#039; is used if there were no previous audio pages with a completed packet. The difference between these granule positions indicates how many samples to keep after decoding the packets that completed on the final page. The remaining samples are discarded. The number of discarded samples SHOULD be smaller than the number decoded from the last packet.&lt;br /&gt;
&lt;br /&gt;
The granule position of the first audio page with a completed packet MAY be larger than the number of samples contained in packets that complete on that page, however it MUST NOT be smaller, unless that page has the &#039;end of stream&#039; flag set. Allowing a granule position larger than the number of samples allows the beginning of a stream to be cropped without rewriting the granule position of all the remaining pages. This means that the PCM sample position just before the first sample to be played may be larger than &#039;0&#039;, but the PCM sample position relative to &#039;0&#039; should still be used for the purposes of synchronization when multiplexing with other logical streams. This does not affect the behavior of pre-skip: exactly &#039;pre-skip&#039; samples should be skipped from the beginning of the decoded output, even if the initial PCM sample position is greater than zero.&lt;br /&gt;
&lt;br /&gt;
On the other hand, a granule position that is smaller than the number of decoded samples prevents a demuxer from working backwards to assign each packet or each individual sample a valid granule position, since granule positions must be non-negative. A decoder MUST reject as invalid any stream where the granule position is smaller than the number of samples contained in packets that complete on the first page with a completed packet, unless that page has the &#039;end of stream&#039; flag set. It MAY defer this action until it decodes the last packet completed on that page. If that page has the &#039;end of stream&#039; flag set, a demuxer can work forwards from the granule position &#039;0&#039;, but MUST reject as invalid any stream where the granule position is smaller than the &#039;pre-skip&#039; amount. This would indicate that more samples should be skipped from the initial decoded output than exist in the stream.&lt;br /&gt;
&lt;br /&gt;
==== ID Header ====&lt;br /&gt;
&lt;br /&gt;
      0                   1                   2                   3&lt;br /&gt;
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
     |       &#039;O&#039;     |      &#039;p&#039;      |     &#039;u&#039;       |     &#039;s&#039;       |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
     |       &#039;H&#039;     |       &#039;e&#039;     |     &#039;a&#039;       |     &#039;d&#039;       |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
     |  version = 1  | channel count |           pre-skip            |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
     |                original input sample rate in Hz               |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
     |    output gain Q7.8 in dB     |  channel map  |               |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               :&lt;br /&gt;
     |                                                               |&lt;br /&gt;
     :          optional channel mapping table...                    :&lt;br /&gt;
     |                                                               |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
&lt;br /&gt;
Brief description of each field:&lt;br /&gt;
&lt;br /&gt;
 - Magic signature: &amp;quot;OpusHead&amp;quot; (64 bits)&lt;br /&gt;
 - Version number (8 bits unsigned): 0x01 for this spec&lt;br /&gt;
 - Channel count &#039;c&#039; (8 bits unsigned): MUST be &amp;gt; 0&lt;br /&gt;
 - Pre-skip (16 bits unsigned, little endian)&lt;br /&gt;
 - Input sample rate (32 bits unsigned, little endian): informational only&lt;br /&gt;
 - Output gain (16 bits, little endian, signed Q7.8 in dB) to apply when&lt;br /&gt;
   decoding&lt;br /&gt;
 - Channel mapping family (8 bits unsigned)&lt;br /&gt;
  --  0 = one stream: mono or L,R stereo&lt;br /&gt;
  --  1 = channels in vorbis spec order: mono or L,R stereo or ... or FL,C,FR,RL,RR,LFE, ...&lt;br /&gt;
  --  2..254 = reserved (treat as 255)&lt;br /&gt;
  --  255 = no defined channel meaning&lt;br /&gt;
 If channel mapping family &amp;gt; 0&lt;br /&gt;
 - Stream count &#039;N&#039; (8 bits unsigned): MUST be &amp;gt; 0&lt;br /&gt;
 - Two-channel stream count &#039;M&#039; (8 bits unsigned): MUST satisfy M &amp;lt;= N, M+N &amp;lt;= 255&lt;br /&gt;
 - Channel mapping (8*c bits)&lt;br /&gt;
   -- one stream index (8 bits unsigned) per channel (255 means silent throughout the file)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Detailed definition of each field:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Magic signature&#039;&#039;&#039;&lt;br /&gt;
The magic signature &amp;quot;OpusHead&amp;quot; allows codec identification and is human readable. Starting with &#039;Op&#039; helps distinguish it from data packets, as this is an invalid TOC sequence.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Version&#039;&#039;&#039;&lt;br /&gt;
The version number MUST always be &#039;1&#039; for this version of the encapsulation specification.&lt;br /&gt;
&lt;br /&gt;
Implementations SHOULD treat streams where the upper four bits of the version number match a recognized specification as backwards-compatible with that specification. That is, the version number can be considered split into &amp;quot;major&amp;quot; and &amp;quot;minor&amp;quot; version sub-fields, with changes to the &amp;quot;minor&amp;quot; sub-field in the lower four bits signaling compatible changes. For example, a decoder implementing this specification SHOULD accept any stream with a version number 15 or less, and SHOULD assume any stream with a version number 16 or greater is incompatible. The initial version &#039;1&#039; was chosen to keep implementations from relying on this byte as a null terminator for the OpusHead string.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Channel count&#039;&#039;&#039; &#039;c&#039;&lt;br /&gt;
The number of channels byte specifies the number of output channels (1...255) for this Ogg Opus stream.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Pre-skip&#039;&#039;&#039;&lt;br /&gt;
This is the number of samples (at 48 kHz) to discard from the decoder output when starting playback, and also the number to subtract from a page&#039;s granule position to calculate its PCM sample position.&lt;br /&gt;
&lt;br /&gt;
When constructing cropped Ogg Opus streams, a pre-skip of at least 3840 samples (80 ms) is RECOMMENDED to ensure complete convergence.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Input sample rate&#039;&#039;&#039;&lt;br /&gt;
This is &#039;&#039;not&#039;&#039; the sample rate to use for playback of the encoded data.&lt;br /&gt;
&lt;br /&gt;
Opus has a handful of coding modes, with internal audio bandwidths of 4, 6, 8, 12, and 20 kHz. Each packet in the stream may have a different audio bandwidth. Regardless of the audio bandwidth, the reference decoder supports decoding any stream at a sample rate of 8, 12, 16, 24, or 48 kHz. The original sample rate of the encoder input is not preserved by the lossy compression.&lt;br /&gt;
&lt;br /&gt;
An Ogg Opus player SHOULD select the playback sample rate according to the following procedure:&lt;br /&gt;
* If the hardware supports 48 kHz playback, decode at 48 kHz,&lt;br /&gt;
* else if the hardware&#039;s highest available sample rate is a supported rate, decode at this sample rate,&lt;br /&gt;
* else if the hardware&#039;s highest available sample rate is less than 48 kHz, decode at the next higher supported rate and resample,&lt;br /&gt;
* else decode at 48 kHz and resample.&lt;br /&gt;
&lt;br /&gt;
However, the &#039;input sample rate&#039; field allows the encoder to pass the sample rate of the original input stream as metadata. This may be useful when the user requires the output sample rate to match the input sample rate. For example, a non-player decoder writing PCM format to disk might choose to resample the output audio back to the original input rate to reduce surprise to the user, who might reasonably expect to get back a file with the same sample rate as the one they fed to the encoder.&lt;br /&gt;
&lt;br /&gt;
A value of zero indicates &#039;unspecified&#039;. Encoders SHOULD write the actual input rate or zero, but decoder implementations which do something with this field SHOULD take care to behave sanely if given crazy values (e.g. don&#039;t &lt;br /&gt;
actually upsample the output to 10 MHz if requested).&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Output gain&#039;&#039;&#039;&lt;br /&gt;
This is a gain to be applied by the decoder. Virtually all players and media frameworks should apply it by default. If a player chooses to apply any volume adjustment or gain modification, such as the R128_TRACK_GAIN or a user-facing volume knob, the adjustment MUST be applied &#039;&#039;in addition&#039;&#039; to this output gain in order to achieve playback at the desired volume.&lt;br /&gt;
&lt;br /&gt;
An encoder SHOULD set the output gain to zero, and instead apply any gain prior to encoding, when this is possible and does not conflict with the user&#039;s wishes. The output gain should only be nonzero when the gain is adjusted after encoding, or when the user wishes to adjust the gain for playback while preserving the ability to recover the original signal amplitude.&lt;br /&gt;
&lt;br /&gt;
Although the output gain has enormous range (+/- 128 dB, enough to amplify inaudible sounds to the threshold of physical pain), most applications can only reasonably use a small portion of this range around zero. The large range serves in part to ensure that gain can always be losslessly transferred between OpusHead and R128_TRACK_GAIN (see below) without saturating.&lt;br /&gt;
&lt;br /&gt;
The gain is the 20 log&amp;lt;sub&amp;gt;10&amp;lt;/sub&amp;gt; ratio of output to input sample values to be applied to the decoder output. E.g. &amp;lt;code&amp;gt;sample *= pow(10, header.gain/(20.*256))&amp;lt;/code&amp;gt; where header.gain is the raw 16 bit Q7.8 value from the header.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Channel mapping family&#039;&#039;&#039;&lt;br /&gt;
This byte indicates the order and semantic meaning of the various channels encoded in each Opus packet.  &lt;br /&gt;
&lt;br /&gt;
Each possible value of this byte indicates a &#039;&#039;mapping family&#039;&#039;, which defines a set of allowed numbers of channels, and the ordered set of channel names for each allowed number of channels. Currently there are three defined mapping families, although more may be added:&lt;br /&gt;
&lt;br /&gt;
* Family 0 (RTP mapping)&lt;br /&gt;
** Allowed numbers of channels: 1 or 2&lt;br /&gt;
** 1 channel: monophonic (mono)&lt;br /&gt;
** 2 channels: stereo (left, right)&lt;br /&gt;
** &#039;&#039;&#039;Special mapping&#039;&#039;&#039;: this channel mapping value also indicates that the contents consists of a single Opus stream that is stereo if and only if c==2, with stream index 0 mapped to channel 0, and (if stereo) stream index 1 mapped to channel 1.  When the channel mapping byte has this value, no further fields are present in OpusHead.&lt;br /&gt;
* Family 1 ([https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9 Vorbis channel order])&lt;br /&gt;
** Allowed numbers of channels: 1 ... 8&lt;br /&gt;
** Channel meanings depend on the number of channels, see the Vorbis mapping for details.&lt;br /&gt;
* Family 255 (no defined channel meaning)&lt;br /&gt;
** Allowed numbers of channels: 1...255&lt;br /&gt;
** Channels are unidentified.  General-purpose players SHOULD NOT attempt to play these streams, and offline decoders MAY deinterleave the output into separate PCM files, one per channel. Decoders SHOULD NOT produce output for channels mapped to stream index 255 (pure silence) unless they have no other way to indicate the index of non-silent channels.&lt;br /&gt;
&lt;br /&gt;
The remaining channel mapping families (2...254) are reserved. A decoder encountering a reserved mapping byte should act as though the mapping byte is 255.&lt;br /&gt;
&lt;br /&gt;
An Ogg Opus player MUST play any Ogg Opus stream with a channel mapping family of 0 or 1, even if the number of channels does not match the physically connected audio hardware. Players SHOULD perform channel mixing to increase or reduce the number of channels as needed.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Stream count&#039;&#039;&#039; &#039;N&#039;&lt;br /&gt;
This field indicates the total number of streams so the decoder can correctly parse the packed Opus packets inside the Ogg packet.&lt;br /&gt;
&lt;br /&gt;
For channel mapping family 0, this value defaults to 1, and is not coded.&lt;br /&gt;
&lt;br /&gt;
A multi-channel Opus file is composed of one or more individual Opus streams, each of which produce one or two channels of decoded data. Each Ogg packet contains one Opus packet from each stream. The first N-1 Opus packets are packed using the self-delimiting framing from Appendix B of the Opus Specification. The remaining Opus packet is packed using the regular, undelimited framing from Section 3 of the Opus Specification. All the Opus packets in a single Ogg packet MUST be constrained to produce the same number of decoded samples. A decoder SHOULD treat any Opus packet whose duration is different from that of the first Opus packet in an Ogg packet as if it were an Opus packet with an illegal TOC sequence.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Two-channel stream count&#039;&#039;&#039; &#039;M&#039;&lt;br /&gt;
Describes the number of streams whose decoders should be configured to produce two channels. This must be no larger than the number of total streams.&lt;br /&gt;
&lt;br /&gt;
For channel mapping family 0, this value defaults to c-1 (i.e., 0 for mono and 1 for stereo), and is not coded.&lt;br /&gt;
&lt;br /&gt;
Each packet in an Opus stream has an internal channel count of 1 or 2, which can change from packet to packet. This is selected by the encoder depending on the bitrate and the contents being encoded. The original channel count of the encoder input is not preserved by the lossy compression.&lt;br /&gt;
&lt;br /&gt;
Regardless of the internal channel count, any Opus stream may be decoded as mono (a single channel) or stereo (two channels) by appropriate initialization of the decoder. The &amp;quot;two-channel stream count&amp;quot; field indicates that the first M Opus decoders should be initialized in stereo mode, and the remaining N-M decoders should be initialized in mono mode. The total number of decoded channels (M+N) MUST be no larger than 255, as there is no way to index more channels than that in the channel mapping.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Channel mapping&#039;&#039;&#039;&lt;br /&gt;
Contains one index per output channel indicating which decoded channel should be used. If the index is less than 2*M, the output MUST be taken from decoding stream (index/2) as stereo and selecting the left channel if index is even, and the right channel if index is odd. If the index is 2*M or larger, the output MUST be taken from decoding stream (index-M) as mono. As a special case, an index of 255 means that the corresponding output channel MUST contain pure silence.&lt;br /&gt;
&lt;br /&gt;
For channel mapping family 0, the first index defaults to 0, and if c==2, the second index defaults to 1. Neither index is coded.&lt;br /&gt;
&lt;br /&gt;
The number of output channels (c) is not constrained to match the number of decoded channels (M+N). A single index MAY appear multiple times, i.e., the same decoded channel may be mapped to multiple output channels. Some decoded channels might not be assigned to any output channel, as well.&lt;br /&gt;
&lt;br /&gt;
==== Comment Header ====&lt;br /&gt;
&lt;br /&gt;
 - 8 byte &#039;OpusTags&#039; magic signature (64 bits)&lt;br /&gt;
 - The remaining data follows the vorbis-comment header design used in OggVorbis (without the &amp;quot;framing-bit&amp;quot;), OggTheora, and Speex:&lt;br /&gt;
  * Vendor string (always present).&lt;br /&gt;
  ** 4-byte little-endian length field, followed by length bytes of UTF-8 vendor string.&lt;br /&gt;
  * TAG=value metadata strings (zero or more).&lt;br /&gt;
  ** 4-byte little-endian string count.&lt;br /&gt;
  ** Count strings consisting of 4-byte little-endian length and length bytes of UTF-8 string in &amp;quot;tag=value&amp;quot; form.&lt;br /&gt;
&lt;br /&gt;
One new comment field is introduced for Ogg Opus:&lt;br /&gt;
 R128_TRACK_GAIN=-573  &lt;br /&gt;
representing the volume shift needed to normalize the track&#039;s volume. The gain is a Q7.8 fixed point number in dB, as in the OpusHead &amp;quot;output gain&amp;quot; field. This field is similar to the [[VorbisComment#Replay_Gain|REPLAYGAIN_TRACK_GAIN field in Vorbis]], although the normal volume reference is the [https://tech.ebu.ch/loudness EBU-R128] standard.&lt;br /&gt;
&lt;br /&gt;
An Ogg Opus file MUST NOT have more than one such field, and if present its value MUST be an integer from -32768 to +32767 inclusive, represented in ASCII with no whitespace. If present, it MUST correctly represent the R128 normalization gain (relative to the OpusHead output gain). If a player chooses to make use of the TRACK_GAIN, it MUST be applied &#039;&#039;in addition&#039;&#039; to the OpusHead output gain. If an encoder populates the TRACK_GAIN field, and the output gain is not otherwise constrained or specified, the encoder SHOULD write the R128 gain into the OpusHead output gain and write &amp;quot;R128_TRACK_GAIN=0&amp;quot;. If a tool modifies the OpusHead &amp;quot;output gain&amp;quot; field, it MUST also update or remove the R128_TRACK_GAIN comment field.&lt;br /&gt;
&lt;br /&gt;
There is no comment field corresponding to Replaygain&#039;s ALBUM_GAIN; that information should instead be stored in the OpusHead &#039;output gain&#039; field.&lt;br /&gt;
&lt;br /&gt;
To avoid confusion with multiple normalization schemes, an OpusTags packet SHOULD NOT contain any of the REPLAYGAIN_TRACK_GAIN, REPLAYGAIN_TRACK_PEAK, REPLAYGAIN_ALBUM_GAIN, or REPLAYGAIN_ALBUM_PEAK fields.&lt;br /&gt;
&lt;br /&gt;
== Other Implementation Notes ==&lt;br /&gt;
&lt;br /&gt;
When seeking within an Ogg Opus stream, the decoder should start decoding (and discarding the output) at least 3840 samples (80 ms) prior to the seek point in order to ensure that the output audio is correct at the seek point.&lt;br /&gt;
&lt;br /&gt;
Technically valid Opus packets can be arbitrarily large due to the padding format, although the amount of non-padding data they can contain is bounded. These packets may be spread over a similarly enormous number of Ogg pages. Encoders SHOULD use no more padding than required to make a variable bitrate (VBR) stream constant bitrate (CBR). Decoders SHOULD avoid attempting to allocate excessive amounts of memory when presented with a very large packet. The presence of an extremely large packet in the stream could indicate a potential memory exhaustion attack or stream corruption. Decoders should reject a packet that is too large to process, and print a warning message.&lt;br /&gt;
&lt;br /&gt;
In an Ogg Opus stream, the largest possible valid packet that does not use padding has a size of (61,298*N - 2) bytes, or about 60 kB per Opus stream. With 255 streams, this is 15,630,988 bytes (14.9 MB) and can span up to 61,298 Ogg pages, all but one of which will have a granulepos of -1. This is of course a very extreme packet, consisting of 255 streams, each containing 120 ms of audio encoded as 2.5 ms frames, each frame using the maximum possible number of bytes (1275) and stored in the least efficient manner allowed (a VBR code 3 Opus packet). Even in such a packet, most of the data will be zeros, as 2.5 ms frames, which are required to run in the MDCT mode, cannot actually use all 1275 bytes. The largest packet consisting entirely of useful data is (15,326*N - 2) bytes, or about 15 kB per stream. This corresponds to 120 ms of audio encoded as 10 ms frames in either LP or Hybrid mode, but at a data rate of over 1 Mbps, which makes little sense for the quality achieved. A more reasonable limit is (7,664*N - 2) bytes, or about 7.5 kB per stream. This corresponds to 120 ms of audio encoded as 20 ms stereo MDCT-mode frames, with a total bitrate just under 511 kbps (not counting the Ogg encapsulation overhead). With N=8, the maximum useful number of streams for the channel meanings currently defined by mapping family 1, this gives a maximum packet size of 61,310 bytes, or just under 60 kB. This is still quite conservative, as it assumes each output channel is taken from one decoded channel of a stereo packet. An implementation could reasonably choose any of these numbers for its internal limits.&lt;br /&gt;
&lt;br /&gt;
== Test Vectors ==&lt;br /&gt;
&lt;br /&gt;
* [[OggOpus/testvectors|Planned test vectors for OggOpus]]&lt;br /&gt;
* Opus test vectors&lt;br /&gt;
&lt;br /&gt;
[[Category:Ogg]]&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusTodo&amp;diff=16344</id>
		<title>OpusTodo</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusTodo&amp;diff=16344"/>
		<updated>2016-04-30T04:15:54Z</updated>

		<summary type="html">&lt;p&gt;MarkH: Ogg mapping now published as RFC 7845&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== For 1.1.3 ==&lt;br /&gt;
* aarch64 and AVX optimizations&lt;br /&gt;
&lt;br /&gt;
== For 1.2 ==&lt;br /&gt;
* Low bitrate quality improvements&lt;br /&gt;
* Fix compilation as a single module for gecko&lt;br /&gt;
&lt;br /&gt;
== Spec ==&lt;br /&gt;
* Matroska mapping. See: [[MatroskaOpus]] And firefox/ffmpeg implementation&lt;br /&gt;
* RTP payload format. Mono/stereo mapping is complete [[https://tools.ietf.org/html/rfc7587 RFC 7587]], no multichannel mapping yet.&lt;br /&gt;
* mp4 mapping. See [[https://opus-codec.org/docs/opus_in_isobmff.html ISO Base Media File Format draft]]&lt;br /&gt;
&lt;br /&gt;
== Website ==&lt;br /&gt;
* De-uglify webpage - some suggestions:&lt;br /&gt;
** write about codecs obsoleted by OPUS (Speex, CELT, Vorbis(?) and the proprietary ones)&lt;br /&gt;
** write about implementations (libopus encoder/decoder, libavcodec decoder, any others?)&lt;br /&gt;
** [https://en.wikipedia.org/wiki/Comparison_of_audio_coding_formats audio codec comparison table] (Opus, Vorbis, Speex, ..., MP5) of features (channels, freq, bits per sample, license, language (C89), integer impl. (Vorbis decoder only, Opus YES, ...)&lt;br /&gt;
** future use in video files (Theora? Dirac? WebM? other future codecs...)&lt;br /&gt;
** audio files for storage (like Vorbis, no raw Opus defined, only inside OGG), ... &lt;br /&gt;
* Promotional material (some nice free/public-domain sounds/radio stations in Opus format)&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
* Oggz-validate (should also validate opus toc)&lt;br /&gt;
&lt;br /&gt;
== Opus-tools ==&lt;br /&gt;
* Port opusdec to libopusfile/libopusurl.&lt;br /&gt;
* A simple real time streaming example tool&lt;br /&gt;
** Start with opusrtp.c in [https://git.xiph.org/?p=opus-tools.git opus-tools]&lt;br /&gt;
** Make &amp;lt;code&amp;gt;opusrtp rtp://example.com:5431/&amp;lt;/code&amp;gt; listen to that host and port and mux packets from there. Generalize the cpac bases --sniff implementation&lt;br /&gt;
** Make sending similarly generic. Maybe just &amp;lt;code&amp;gt;opusrtp source.opus -o rtp://example.com:5431/&amp;lt;/code&amp;gt; to send source.opus out to the destination?&lt;br /&gt;
** Make --sniff save one file per&lt;br /&gt;
** Implement DTLS-SRTP. See webrtc.&lt;br /&gt;
** audio capture/encode, decode/playback?&lt;br /&gt;
** Parse and act on sdp for convenience and testing.&lt;br /&gt;
&lt;br /&gt;
* EBU R128/Replaygain (half done— needs a gain tool)&lt;br /&gt;
&lt;br /&gt;
== Surround work ==&lt;br /&gt;
&lt;br /&gt;
* Apply spreading to energy masking&lt;br /&gt;
* More conservative energy masking (not just mean difference) and dynalloc&lt;br /&gt;
* Allow SILK/hybrid on center channel for voice?&lt;br /&gt;
&lt;br /&gt;
== Psychoacoustic stuff ==&lt;br /&gt;
&lt;br /&gt;
* Adaptive width narrowing and forced intensity stereo bands&lt;br /&gt;
&lt;br /&gt;
== Optimisations ==&lt;br /&gt;
&lt;br /&gt;
* Vectorising comb_filter()&lt;br /&gt;
* Use 16-bit mul plus shift in denormalise_bands()&lt;br /&gt;
* Optimise MDCT somehow&lt;br /&gt;
&lt;br /&gt;
== Third-Party tool enhancements ==&lt;br /&gt;
* mutagen: [https://bitbucket.org/lazka/mutagen/issue/202/oggopus-support-in-place-rewrites-for support padding in comments header], [https://bitbucket.org/lazka/mutagen/issue/203/oggopus-allow-updating-the-output_gain allow updating output gain in ID header]&lt;br /&gt;
&lt;br /&gt;
== Future work ==&lt;br /&gt;
* psymodel based VBR&lt;br /&gt;
* Remove copy in inverse MDCT&lt;br /&gt;
* Save some float&amp;lt;-&amp;gt;int conversions&lt;br /&gt;
* Improvements to LP mode CBR (greg has some code)&lt;br /&gt;
* Unconstrained SILK VBR&lt;br /&gt;
* Better handling for the case where FEC has a different bandwidth than the current mode&lt;br /&gt;
* PLC transitions on unprotected SILK-SILK bandwidth changes?&lt;br /&gt;
* Figure out how to use speech/music detection optimally&lt;br /&gt;
** find optimal switching time (low energy/tonality)&lt;br /&gt;
* Improve variable frame size&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OggOpusImplementation&amp;diff=16343</id>
		<title>OggOpusImplementation</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OggOpusImplementation&amp;diff=16343"/>
		<updated>2016-04-30T04:09:32Z</updated>

		<summary type="html">&lt;p&gt;MarkH: Ogg Opus draft is now RFC 7845&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Implementation Status ==&lt;br /&gt;
&lt;br /&gt;
Implementation status of [https://tools.ietf.org/html/rfc7845 RFC 7845]. This Internet Standards Track document describes encapsulation of Opus audio in the Ogg container to make &amp;lt;tt&amp;gt;.opus&amp;lt;/tt&amp;gt; files and streams.&lt;br /&gt;
&lt;br /&gt;
What follows is a brief summary of major implementations of the RFC, and their status.&lt;br /&gt;
This is intended to help understand the status of each portion of the RFC, per [https://tools.ietf.org/html/rfc6982 RFC 6982].&lt;br /&gt;
&lt;br /&gt;
=== opus-tools ===&lt;br /&gt;
&lt;br /&gt;
The initial development implementation of this RFC was in the opusenc, opusdec, and opusinfo command-line utilities, part of the opus-tools package and repository.&lt;br /&gt;
While still &#039;development&#039; status (pre-1.0) these utilities are in active public use, and have shipped with Linux distributions as well as homebrew and MacPorts for OS X.&lt;br /&gt;
Together they implement basic read, write and playback support of Ogg Opus files including metadata, multichannel, start and end trimming, the gain field, live streams, and chained files, but currently do not support seeking.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://git.xiph.org/?p=opus-tools.git&lt;br /&gt;
* http://www.opus-codec.org/downloads/&lt;br /&gt;
&lt;br /&gt;
=== opusfile ===&lt;br /&gt;
&lt;br /&gt;
The opusfile library is a separate implementation of this RFC as a helper library for demuxing and decoding.&lt;br /&gt;
Like opus-tools, it supports metadata, multichannel, start and end trimming, the gain field, live streams, and chained files.&lt;br /&gt;
Its primary focus is efficient seeking, including over HTTP(S) and in chained streams.&lt;br /&gt;
It currently does not create Ogg Opus files.&lt;br /&gt;
This library is in early development and is not widely deployed, though several projects are currently using it, including xmms2, taglib, and cmus, and it is shipped in some Linux distributions and in homebrew.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://git.xiph.org/?p=opusfile.git&lt;br /&gt;
* http://www.opus-codec.org/downloads/&lt;br /&gt;
&lt;br /&gt;
=== Firefox ===&lt;br /&gt;
&lt;br /&gt;
The Firefox web browser is a widely deployed implementation of this RFC.&lt;br /&gt;
Basic playback support with the HTML5 &amp;amp;lt;audio&amp;amp;gt; element, including start and end trimming, the gain field, live streams, multiplexing with other streams (for, e.g., the &amp;amp;lt;video&amp;amp;gt; tag), and seeking, was added in Firefox 15, in production release starting August 28, 2012.&lt;br /&gt;
Multichannel support was added in Firefox 17, in production release starting November 20, 2012.&lt;br /&gt;
Metadata support was added in Firefox 18, in production release starting January 8, 2013.&lt;br /&gt;
Chained file support (as streams only, with seeking disabled) was added in Firefox 20, in production release starting April 2, 2013.&lt;br /&gt;
Encoding support was added in Firefox 26, in production release starting December 10, 2013.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://mozilla.org/firefox/&lt;br /&gt;
* https://hacks.mozilla.org/2012/08/opus-support-for-webrtc/&lt;br /&gt;
* https://bugzilla.mozilla.org/show_bug.cgi?id=674225&lt;br /&gt;
* https://bugzilla.mozilla.org/show_bug.cgi?id=748144&lt;br /&gt;
* https://bugzilla.mozilla.org/show_bug.cgi?id=778050&lt;br /&gt;
* https://bugzilla.mozilla.org/show_bug.cgi?id=455165&lt;br /&gt;
* https://bugzilla.mozilla.org/show_bug.cgi?id=842243&lt;br /&gt;
&lt;br /&gt;
=== Chrome ===&lt;br /&gt;
&lt;br /&gt;
Google Chrome is a widely distributed implementation of this RFC. It added support with the HTML5 &amp;lt;audio&amp;gt; element in M25 and enabled it by default in M33 released in February 2014.&lt;br /&gt;
This implementation currently does not support chained files.&lt;br /&gt;
Prior to M33 support required passing --enable-opus-playback on the command line when invoking the executable.&lt;br /&gt;
&lt;br /&gt;
This implementation is based on open source code in Chromium, Blink, and FFmpeg.&lt;br /&gt;
&lt;br /&gt;
* https://www.google.com/intl/en/chrome/browser/&lt;br /&gt;
* https://www.google.com/intl/en/chrome/browser/canary.html&lt;br /&gt;
* https://code.google.com/p/chromium/issues/detail?id=104241&lt;br /&gt;
&lt;br /&gt;
=== GStreamer ===&lt;br /&gt;
&lt;br /&gt;
The GStreamer media framework includes an implementation of this RFC.&lt;br /&gt;
It supports metadata, multichannel, start and end trimming, the gain field, live streams, chained files, multiplexing with other streams (e.g., video), and seeking.&lt;br /&gt;
Support was first added in early 2011, and is part of the 0.11 and 1.0.x releases.&lt;br /&gt;
The code implementing this RFC is in the gst-plugins-bad collection, which generally indicates unsupported and/or experimental code, despite its release status.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* http://gstreamer.net/&lt;br /&gt;
* http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/&lt;br /&gt;
&lt;br /&gt;
=== FFmpeg ===&lt;br /&gt;
&lt;br /&gt;
The popular media framework and conversion tool FFmpeg implements this RFC. It supports encoding and decoding, multiplexing and demultiplexing with other streams, metadata, multichannel, start and end trimming, the gain field, live streams, and seeking.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://ffmpeg.org/&lt;br /&gt;
&lt;br /&gt;
=== libav ===&lt;br /&gt;
&lt;br /&gt;
The development repository for libav implements this RFC, similar to FFmpeg.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://libav.org/&lt;br /&gt;
&lt;br /&gt;
=== VLC ===&lt;br /&gt;
&lt;br /&gt;
VLC is another widely deployed implementation of demuxing, decoding, and playback support for this RFC.&lt;br /&gt;
It supports metadata, multichannel, start and end trimming, the gain field, live streams, seeking, chained files (though seeking does not work correctly with chained files), and multiplexing with other streams (e.g., video).&lt;br /&gt;
Opus support was added in version 2.0.4, released on October 18, 2012.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://www.videolan.org/vlc/&lt;br /&gt;
* https://git.videolan.org/?p=vlc.git&lt;br /&gt;
* https://trac.videolan.org/vlc/ticket/7185&lt;br /&gt;
&lt;br /&gt;
=== foobar2000 ===&lt;br /&gt;
&lt;br /&gt;
A popular Windows application, foobar2000 implements read, write, and playback support for this RFC.&lt;br /&gt;
It supports metadata, multichannel, start and end trimming, the gain field, live streams, chained files, and seeking.&lt;br /&gt;
Opus support was added in version 1.1.14, released on August 17, 2012.&lt;br /&gt;
Encoding support is implemented using opusenc from opus-tools.&lt;br /&gt;
&lt;br /&gt;
This implementation is closed source.&lt;br /&gt;
&lt;br /&gt;
* http://www.foobar2000.org/&lt;br /&gt;
&lt;br /&gt;
=== Rockbox ===&lt;br /&gt;
&lt;br /&gt;
Rockbox is an established alternative firmware for portable music players (typically small, embedded devices) that implements demuxing, decoding, and playback support for this RFC starting with version 3.13 released March 5, 2013.&lt;br /&gt;
It supports metadata, start and end trimming, the gain field, and seeking.&lt;br /&gt;
It does not currently support multichannel or chained files.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* http://www.rockbox.org/&lt;br /&gt;
* http://git.rockbox.org/?p=rockbox.git&lt;br /&gt;
* http://gerrit.rockbox.org/r/#/c/300/&lt;br /&gt;
&lt;br /&gt;
=== Youki3 ===&lt;br /&gt;
&lt;br /&gt;
Youki3 is a media player for the Android mobile operating system. It provides OPUS metadata reading support via TagLib [(c) Scott Wheeler; ported to Android] and playback via LibVLC [also see the VLC section above please; (C) VideoLAN developers].&lt;br /&gt;
&lt;br /&gt;
* https://play.google.com/store/apps/details?id=net.mderezynski.youki3&lt;br /&gt;
&lt;br /&gt;
The app source is currently closed, however since it utilizes LibVLC for playback, the respective source is open.&lt;br /&gt;
&lt;br /&gt;
=== Mutagen ===&lt;br /&gt;
&lt;br /&gt;
Mutagen is a Python module to handle audio metadata, supporting Ogg Opus among many other media formats. It has support for editing the vorbis-style comment fields in Ogg Opus since version 1.21 (2013-01). In 2014-11 (unreleased at time of writing) it added support for preserving marked comment padding as specified in the RFC. It is used by the MusicBrainz Picard tagger, Beets music library manager, Ex Falso and Quod Libet tagger and player, among many other applications.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source, licensed under the GPL-2.&lt;br /&gt;
&lt;br /&gt;
* https://mutagen.readthedocs.org/&lt;br /&gt;
* https://bitbucket.org/lazka/mutagen&lt;br /&gt;
&lt;br /&gt;
[[Category:Ogg]]&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=16340</id>
		<title>OpusFAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=16340"/>
		<updated>2016-04-28T23:07:20Z</updated>

		<summary type="html">&lt;p&gt;MarkH: update Opus RTP reference&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;If you are looking for info not covered in this FAQ, try the [http://opus-codec.org main Opus website] or the pages included in the [[:Category:Opus|Opus category]] of this wiki.&lt;br /&gt;
&lt;br /&gt;
[[Image:Opus logo trans.png|right]]&lt;br /&gt;
&lt;br /&gt;
== General Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What is Opus? Who created it? ===&lt;br /&gt;
&lt;br /&gt;
Opus is a totally open, royalty-free, highly versatile audio codec.&lt;br /&gt;
&lt;br /&gt;
It is primarily designed for interactive speech and music transmission over the Internet, but is also applicable to storage and streaming applications. It incorporates technology from Skype&#039;s &#039;&#039;&#039;[https://en.wikipedia.org/wiki/SILK SILK]&#039;&#039;&#039; codec and Xiph.Org&#039;s &#039;&#039;&#039;[http://celt-codec.org/ CELT]&#039;&#039;&#039; codec. It has been standardized by the Internet Engineering Task Force (IETF) as &#039;&#039;&#039;[http://tools.ietf.org/html/rfc6716 RFC 6716]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Opus has been in development since early 2007. Programmers associated with &#039;&#039;&#039;[http://xiph.org/ Xiph.Org]&#039;&#039;&#039;, &#039;&#039;&#039;[https://www.skype.com/ Skype]&#039;&#039;&#039; and several other organizations have contributed to its development and to the standardization process as part of the &#039;&#039;&#039;[https://datatracker.ietf.org/wg/codec/charter/ IETF&#039;s Codec Working Group]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== How does Opus compare to other codecs? ===&lt;br /&gt;
&lt;br /&gt;
Opus is distinguished from most high quality formats (eg: AAC, [[Vorbis]], MP3) by having &#039;&#039;&#039;low delay&#039;&#039;&#039; (5 ~ 66.5 ms) and distinguished from most low delay formats (eg: G.711, GSM, Speex) by supporting &#039;&#039;&#039;high audio quality&#039;&#039;&#039; ([https://tools.ietf.org/html/rfc6716#section-2.1.1 details here]).&lt;br /&gt;
&lt;br /&gt;
It meets or exceeds existing codecs&#039; quality across a wide range of bitrates, and it operates at lower delay than virtually any existing compressed format.&lt;br /&gt;
&lt;br /&gt;
Most importantly, the Opus format and its reference implementation are both available under &#039;&#039;&#039;[http://opus-codec.com/license/ liberal, royalty-free licenses]&#039;&#039;&#039;.&amp;lt;br /&amp;gt;&lt;br /&gt;
This makes it:&lt;br /&gt;
* easy to adopt&lt;br /&gt;
* compatible with free software&lt;br /&gt;
* suitable for use as part of the basic infrastructure of the Internet&lt;br /&gt;
&lt;br /&gt;
See the Opus &#039;&#039;&#039;[http://opus-codec.org/comparison comparison page]&#039;&#039;&#039; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus make all those other lossy codecs obsolete? ===&lt;br /&gt;
&lt;br /&gt;
Theoretically, yes.&lt;br /&gt;
&lt;br /&gt;
From a technical point of view (loss, delay, bitrates, ...) it should replace both [[Vorbis]] and [[Speex]], and the common proprietary codecs too.&lt;br /&gt;
&lt;br /&gt;
=== Will Opus replace Vorbis in video files? ===&lt;br /&gt;
&lt;br /&gt;
For Ogg [[Theora]] video files, it can, just the overall size reduction will be minimal and it will break compatibility with existing players.&lt;br /&gt;
&lt;br /&gt;
For WebM video files, the convention is to use the VP9 video codec when using Opus as an audio codec.&lt;br /&gt;
&lt;br /&gt;
=== How do I use Opus? What programs support Opus? ===&lt;br /&gt;
&lt;br /&gt;
Opus decoding support is now included in &#039;&#039;&#039;[http://caniuse.com/opus some Internet browsers]&#039;&#039;&#039; and many applications, including &#039;&#039;&#039;[https://www.mozilla.org/firefox Firefox]&#039;&#039;&#039;, &#039;&#039;&#039;[https://www.foobar2000.org/ foobar2000]&#039;&#039;&#039; and &#039;&#039;&#039;[https://www.videolan.org/vlc/ VLC]&#039;&#039;&#039;, as well as in frameworks such as &#039;&#039;&#039;[http://gstreamer.freedesktop.org/ GStreamer]&#039;&#039;&#039; and &#039;&#039;&#039;[https://ffmpeg.org/ FFmpeg]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
For now, the best way to &#039;&#039;&#039;encode&#039;&#039;&#039; Opus files is to use the &#039;&#039;&#039;opusenc&#039;&#039;&#039; command-line tool from the &#039;&#039;&#039;[http://opus-codec.com/downloads/ opus-tools package]&#039;&#039;&#039;.&lt;br /&gt;
If you want to encode many files at once (e.g. your music library), you can also try the &#039;&#039;&#039;[http://lamexp.sourceforge.net/ LameXP]&#039;&#039;&#039; converter.&lt;br /&gt;
&lt;br /&gt;
For real-time applications, Opus support is available in &#039;&#039;&#039;[http://www.webrtc.org/ Google&#039;s WebRTC codebase]&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
Opus is a relatively new codec: many more applications will support it in the near future.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus support higher sampling rates, such as 96 kHz or 192 kHz? ===&lt;br /&gt;
&lt;br /&gt;
Yes and no.&lt;br /&gt;
&lt;br /&gt;
Opus encoding tools like opusenc will happily encode input files that are sampled at 96 or 192 kHz.&lt;br /&gt;
&lt;br /&gt;
However, files at these rates are internally &#039;&#039;&#039;converted to 48 kHz&#039;&#039;&#039; and then only frequencies &#039;&#039;&#039;up to 20 kHz&#039;&#039;&#039; are encoded.&lt;br /&gt;
&lt;br /&gt;
The reason is simple: lossy codecs are designed to preserve audible details while discarding irrelevant information. Since the human ear can only hear up to 20 kHz at best (usually lower than that), frequency content above 20 kHz is the first thing to go.&lt;br /&gt;
&lt;br /&gt;
See Monty&#039;s &#039;&#039;&#039;[http://people.xiph.org/~xiphmont/demo/neil-young.html article]&#039;&#039;&#039; for more details.&lt;br /&gt;
&lt;br /&gt;
If you want a codec to handle higher sampling rates losslessly, use &#039;&#039;&#039;[[FLAC]]&#039;&#039;&#039;!&lt;br /&gt;
&lt;br /&gt;
=== What are the licensing requirements? ===&lt;br /&gt;
&lt;br /&gt;
The reference Opus source code is released under a three-clause BSD license, which is a very permissive Open Source license. Commercial use and distribution (including in proprietary software) is permitted, provided that some basic conditions specified in the license are met. &lt;br /&gt;
&lt;br /&gt;
Opus is also covered by some patents, for which royalty-free usage rights are granted, under conditions that the authors believe are compatible with (hopefully) all open source licenses, including the GPL (v2 and v3).&lt;br /&gt;
&lt;br /&gt;
See the &#039;&#039;&#039;[http://www.opus-codec.org/license/ Opus Licensing]&#039;&#039;&#039; page for details.&lt;br /&gt;
&lt;br /&gt;
=== Why make Opus free? ===&lt;br /&gt;
&lt;br /&gt;
On the Internet, protocol and codec standards are part of the common infrastructure everyone builds upon.&lt;br /&gt;
&lt;br /&gt;
Most of the value of a high-quality standard is the innovation and inter-operation provided by the systems built on top of it. When a few parties have monopoly rights to monetize a standard, that infrastructure stops being so common and everyone else has more reason to use their own solution instead, increasing cost and reducing efficiency.&lt;br /&gt;
&lt;br /&gt;
Imagine a road system where each type of car could only drive on its own manufacturer&#039;s pavement. We all benefit from living in a world where all the roads are connected.&lt;br /&gt;
&lt;br /&gt;
This is why Opus, unlike many codecs, is free.&lt;br /&gt;
&lt;br /&gt;
=== Is the SILK part of Opus compatible with the SILK implementation shipped in Skype? ===&lt;br /&gt;
&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
The SILK codec, as submitted by Skype to the IETF, was heavily modified as part of its integration within Opus. The modifications are significant enough that it is not possible to just write a &amp;quot;translator&amp;quot;. Even sharing code between Opus and the &amp;quot;old SILK&amp;quot; would be highly complex.&lt;br /&gt;
&lt;br /&gt;
=== Why not keep the SILK and CELT codecs separate? ===&lt;br /&gt;
Opus is more than just two independent codecs with a switch.&lt;br /&gt;
&lt;br /&gt;
In addition to a [https://en.wikipedia.org/wiki/Linear_predictive_coding Linear Prediction] &#039;&#039;&#039;SILK mode&#039;&#039;&#039; and an [https://en.wikipedia.org/wiki/Modified_discrete_cosine_transform MDCT] &#039;&#039;&#039;CELT mode&#039;&#039;&#039; it has a &#039;&#039;&#039;hybrid mode&#039;&#039;&#039;, where speech frequencies up to 8 kHz are encoded with LP while those between 8 and 20 kHz are encoded with MDCT. This is what allows Opus to have such high speech quality around 32 kbps.&lt;br /&gt;
&lt;br /&gt;
Another advantage of the integration is the ability to switch between these 3 modes seamlessly, without any audible &amp;quot;glitches&amp;quot; and without any out-of-band signalling.&lt;br /&gt;
&lt;br /&gt;
=== Now that Opus is standardized, will its development stop, or can it be further improved? ===&lt;br /&gt;
Yes, Opus &#039;&#039;&#039;can&#039;&#039;&#039; and &#039;&#039;&#039;should&#039;&#039;&#039; be improved, because unlike most ITU-T codecs, Opus is only defined in terms of its decoder.&lt;br /&gt;
&lt;br /&gt;
The encoder can keep evolving as long as the bitstream it produces can be decoded by the reference decoder. This is what made it possible for modern MP3 encoders (e.g. &#039;&#039;&#039;[https://en.wikipedia.org/wiki/LAME LAME]&#039;&#039;&#039;) to improve far beyond the original &#039;&#039;&#039;[https://en.wikipedia.org/wiki/L3enc L3enc]&#039;&#039;&#039; and &#039;&#039;&#039;dist10&#039;&#039;&#039; reference implementations.&lt;br /&gt;
&lt;br /&gt;
Although it is unlikely that Opus encoders will see such a spectacular evolution, we certainly hope that future encoders will become much better than the reference encoder.&lt;br /&gt;
&lt;br /&gt;
In fact, the 1.1 libopus release significantly improves on the reference encoder&#039;s quality. See &#039;&#039;&#039;[https://people.xiph.org/~xiphmont/demo/opus/demo3.shtml Monty&#039;s demo]&#039;&#039;&#039; for more details.&lt;br /&gt;
&lt;br /&gt;
=== Will all future Opus releases comply with the [http://tools.ietf.org/html/rfc6716 Opus specification]? ===&lt;br /&gt;
&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
=== In what ways is Opus optimized for the Internet? ===&lt;br /&gt;
&lt;br /&gt;
Opus has good packet loss robustness and concealment, but its optimisations go further.&lt;br /&gt;
&lt;br /&gt;
One of the first things we&#039;ve been asked when designing Opus was to make the rate &#039;&#039;&#039;really&#039;&#039;&#039; adaptable because we never know what kind of rates will be available. This not only meant having a wide range of bitrates, but also being able to vary in small increments.&lt;br /&gt;
&lt;br /&gt;
This is why Opus scales from about &#039;&#039;&#039;6 &#039;&#039;&#039; to &#039;&#039;&#039;512 kb/s&#039;&#039;&#039;, in increments of &#039;&#039;&#039;0.4 kb/s&#039;&#039;&#039; (one byte with 20 ms frames). Opus can have &#039;&#039;&#039;more than 1200 possible bitrates&#039;&#039;&#039; while spending only &#039;&#039;&#039;11 bits&#039;&#039;&#039; signalling the bitrate because UDP already encodes the packet size.&lt;br /&gt;
&lt;br /&gt;
One last aspect is that Opus is simple to transport over RTP, as can be seen from the [http://tools.ietf.org/html/rfc7587 Opus RTP payload format]. For example, it&#039;s possible to decode RTP packets without having even seen the SDP or any out-of-band signalling.&lt;br /&gt;
&lt;br /&gt;
=== What applications for Android can play Opus? ===&lt;br /&gt;
&lt;br /&gt;
Right now, there are just a few but that list is fast growing. Please reference [http://android.stackexchange.com/q/37970/7425 this question on android.stackexchange.com]. Feel free to suggest other applications.&lt;br /&gt;
&lt;br /&gt;
=== When will the next version be released? ===&lt;br /&gt;
&lt;br /&gt;
When it&#039;s done. Seriously, we do not know.&lt;br /&gt;
&lt;br /&gt;
Opus is not a large project with a fixed release schedule.&lt;br /&gt;
&lt;br /&gt;
That being said, our [http://www.opus-codec.org/downloads/ pre-releases] and even the [https://git.xiph.org/?p=opus.git git repository] are generally pretty stable and given proper testing (which you should always do anyway), are safe to distribute.&lt;br /&gt;
&lt;br /&gt;
Just be aware that the API of new features (that have never been included in a stable release) could potentially still change.&lt;br /&gt;
&lt;br /&gt;
== Software Developers&#039; Questions ==&lt;br /&gt;
&lt;br /&gt;
=== On what platforms does Opus run? ===&lt;br /&gt;
&lt;br /&gt;
The Opus code base is written in C89 and should run on the vast majority of recent (and not so recent) CPUs.&lt;br /&gt;
&lt;br /&gt;
Some of the platforms &#039;&#039;&#039;[https://mf4.xiph.org/jenkins/view/opus/ on which Opus has been tested]&#039;&#039;&#039; include x86, x86-64, ARM, Itanium, Blackfin, and SPARC.&lt;br /&gt;
&lt;br /&gt;
=== Is there a fixed-point implementation? ===&lt;br /&gt;
&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
The fixed-point and floating-point decoder and encoder implementations are part of the same code base.&lt;br /&gt;
&lt;br /&gt;
The code defaults to float, so you need to configure with &#039;&#039;&#039;--enable-fixed-point&#039;&#039;&#039; (or define &#039;&#039;&#039;FIXED_POINT&#039;&#039;&#039; if not using the configure script) to build the code for fixed-point.&lt;br /&gt;
&lt;br /&gt;
=== Which implementation should I use? ===&lt;br /&gt;
&lt;br /&gt;
While the implementation in RFC 6716 is what &#039;&#039;defines&#039;&#039; the standard, it is likely not the best and most up-to-date implementation.&lt;br /&gt;
&lt;br /&gt;
The [http://opus-codec.org/ Opus] website was set up for the purpose of continually improving the implementation — in terms of speed, encoding quality, device compatibility, etc — while still conforming to the standard.&lt;br /&gt;
&lt;br /&gt;
All Opus implementations are compatible by definition.&lt;br /&gt;
&lt;br /&gt;
=== How is supporting Opus different from supporting Speex/G.711/MP3? ===&lt;br /&gt;
&lt;br /&gt;
Opus has variable frame durations which can change on the fly, so an Opus decoder needs to be ready to accept packets with durations that are &#039;&#039;&#039;any multiple of 2.5ms&#039;&#039;&#039; up to a &#039;&#039;&#039;maximum of 120ms&#039;&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
The opus encoder and decoder do not need to have matched sampling rates or channel counts.  It is recommended to always just decode at the highest rate the hardware supports (e.g. 48kHz stereo) so the user gets the full quality of whatever the far end is sending.&lt;br /&gt;
&lt;br /&gt;
=== My application doesn&#039;t work. Can anyone help me? ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to get help, but before doing so, there are a few basic things to try:&lt;br /&gt;
&lt;br /&gt;
* Implement your application with uncompressed audio instead of Opus. If it still doesn&#039;t work, then the problem isn&#039;t related to Opus.&lt;br /&gt;
* Read the [http://www.opus-codec.org/docs/ Opus documentation].&lt;br /&gt;
* Read the [https://git.xiph.org/?p=opus.git;a=blob;f=src/opus_demo.c opus_demo.c] source code to see how to use the encoder and decoder.&lt;br /&gt;
&lt;br /&gt;
If you still can&#039;t solve the problem, the best option is to ask for help on the [http://lists.xiph.org/mailman/listinfo/opus mailing list] or on the &#039;&#039;&#039;#opus&#039;&#039;&#039; IRC channel on &#039;&#039;&#039;irc.freenode.net&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== How do I report a bug? ===&lt;br /&gt;
&lt;br /&gt;
If you think you have found a bug in Opus (and not in your application), please [https://trac.xiph.org/newticket?component=Opus file a bug report].&lt;br /&gt;
&lt;br /&gt;
Please include a way for us to reproduce the problem. The best way to do this is to provide an input file, along with the opusenc/opusdec/opus_demo command line that causes the bug to occur.&lt;br /&gt;
&lt;br /&gt;
If the bug cannot be triggered by the command line tools, please provide a simple patch or C file that can help reproduce it. Please also provide any other relevant information, such as OS, CPU, build options, etc.&lt;br /&gt;
&lt;br /&gt;
Don&#039;t hesitate to also contact us on the [http://lists.xiph.org/mailman/listinfo/opus mailing list] or on [irc://irc.freenode.net/opus IRC].&lt;br /&gt;
&lt;br /&gt;
=== What is Opus Custom? ===&lt;br /&gt;
&lt;br /&gt;
Opus Custom is an &#039;&#039;&#039;optional&#039;&#039;&#039; part of the Opus standard that allows for sampling rates other than 8, 12, 16, 24, or 48 kHz and frame sizes other than multiples of 2.5 ms.&lt;br /&gt;
&lt;br /&gt;
Opus Custom requires additional out-of-band signalling that Opus does not normally require and disables many of Opus&#039; coding modes. Also, because it is an optional part of the specification, using Opus Custom may lead to compatibility problems.&lt;br /&gt;
&lt;br /&gt;
For these reasons, its use is discouraged outside of very specific applications, for example:&lt;br /&gt;
* ultra low delay applications where synchronization with the soundcard buffer is important. &lt;br /&gt;
* low-power embedded applications where compatibility with others is not important.&lt;br /&gt;
&lt;br /&gt;
For almost all other types of applications, Opus Custom should not be used.&lt;br /&gt;
&lt;br /&gt;
=== How do I use 44.1 kHz or some other sampling rate not directly supported by Opus? ===&lt;br /&gt;
&lt;br /&gt;
Tools which read or write Opus should inter-operate with other sampling rates by transparently performing sample rate conversion behind the scenes whenever necessary. In particular, software developers should not use Opus Custom for 44.1 kHz support, except in the very specific circumstances outlined above.&lt;br /&gt;
&lt;br /&gt;
Note that it&#039;s generally preferable for a decoder to output at 48kHz, even when you know the original input was 44.1kHz. This is not only because you can skip resampling, but also because many cheaper audio interfaces have poor quality output for 44.1kHz.&lt;br /&gt;
&lt;br /&gt;
The &#039;&#039;&#039;[https://opus-codec.org/downloads/ opus-tools]&#039;&#039;&#039; package source code contains a small, high quality, high performance, BSD licensed resampler which can be used where resampling is required.&lt;br /&gt;
&lt;br /&gt;
=== How is the bitrate setting used in VBR mode? ===&lt;br /&gt;
&lt;br /&gt;
Variable bitrate (VBR) mode allows the bitrate to automatically vary over time based on the audio being encoded, in order to achieve a consistent quality.&lt;br /&gt;
&lt;br /&gt;
The bitrate setting controls the desired quality, on a scale that is calibrated to closely approximate the average bitrate that would be obtained over a large and diverse collection of audio.  The actual bitrate of any particular audio stream may be higher or lower than this average.&lt;br /&gt;
&lt;br /&gt;
=== What frame size should I use? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;20ms&#039;&#039;&#039; frame size works well for most applications.&lt;br /&gt;
&lt;br /&gt;
Smaller frame sizes may be used to achieve lower latency, but have lower quality at a given bitrate.&lt;br /&gt;
&lt;br /&gt;
Sizes greater than 20 ms increase latency and are generally beneficial only at fairly low bitrates, or when used to reduce external overhead (e.g. by reducing the number of packets that are sent).&lt;br /&gt;
&lt;br /&gt;
=== Forward Error correction (FEC) doesn&#039;t appear to do anything! HELP! ===&lt;br /&gt;
&lt;br /&gt;
The in-band FEC feature of Opus helps reduce the harm of packet loss by encoding some information about the prior packet.&lt;br /&gt;
&lt;br /&gt;
In order to make use of in-band FEC the decoder must delay its output by at least one frame so that it can call the decoder with the decode_fec argument on the &#039;&#039;next&#039;&#039; frame in order to reconstruct the missed frame. This works best if it&#039;s integrated with a jitter buffer.&lt;br /&gt;
&lt;br /&gt;
FEC is only used by the encoder under certain conditions:&lt;br /&gt;
* the feature must be enabled via the OPUS_SET_INBAND_FEC CTL&lt;br /&gt;
* the encoder must be told to expect loss via the OPUS_SET_PACKET_LOSS_PERC CTL&lt;br /&gt;
* the codec must be operated in any of the linear prediction or Hybrid modes&lt;br /&gt;
&lt;br /&gt;
Frame durations shorter than 10ms and very high bitrates will use the MDCT modes, where FEC is not available.&lt;br /&gt;
&lt;br /&gt;
Even when FEC is not used, telling the encoder about the expected level of loss will help it make more intelligent decisions. By default the implementation assumes there is no loss.&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t use malloc or much stack on my embedded platform. How do I make Opus work? ===&lt;br /&gt;
&lt;br /&gt;
A normal build of libopus only uses &amp;lt;tt&amp;gt;malloc/free&amp;lt;/tt&amp;gt; in the &amp;lt;tt&amp;gt;_create()&amp;lt;/tt&amp;gt; and &amp;lt;tt&amp;gt;_destroy()&amp;lt;/tt&amp;gt; calls, making it safe for realtime use as long as the codec state is pre-created.&lt;br /&gt;
&lt;br /&gt;
To build Opus without the references to &amp;lt;tt&amp;gt;malloc/free&amp;lt;/tt&amp;gt;, you must:&lt;br /&gt;
&lt;br /&gt;
* use &amp;lt;tt&amp;gt;init()&amp;lt;/tt&amp;gt; calls rather than &amp;lt;tt&amp;gt;create()&amp;lt;/tt&amp;gt; calls in your application&lt;br /&gt;
* compile with &amp;lt;tt&amp;gt;CFLAGS=&amp;quot;-DOVERRIDE_OPUS_ALLOC -DOVERRIDE_OPUS_FREE  -D&#039;opus_alloc(x)=NULL&#039; -D&#039;opus_free(x)=NULL&#039; &amp;quot;&amp;lt;/tt&amp;gt;.&lt;br /&gt;
&lt;br /&gt;
If libopus is built with &amp;lt;tt&amp;gt;-DNONTHREADSAFE_PSEUDOSTACK&amp;lt;/tt&amp;gt; (instead of &amp;lt;tt&amp;gt;VAR_ARRAYS&amp;lt;/tt&amp;gt;, or &amp;lt;tt&amp;gt;USE_ALLOCA&amp;lt;/tt&amp;gt;), it will use a user-provided block of heap instead of stack for many things, resulting in much lower stack usage.&amp;lt;br&amp;gt;&lt;br /&gt;
This makes the resulting library &#039;&#039;&#039;non-threadsafe&#039;&#039;&#039; and is &#039;&#039;&#039;not recommended&#039;&#039;&#039; on anything except limited embedded platforms.&lt;br /&gt;
&lt;br /&gt;
=== How can I ensure that my software interoperates with other software implementing Opus? ===&lt;br /&gt;
&lt;br /&gt;
For applications using Ogg files, there are some [http://people.xiph.org/~greg/opus_testvectors/ Ogg Opus testvectors] to test decoders and you can test encoders with opusdec. For RTP applications, the opusrtp tool can be useful.&lt;br /&gt;
&lt;br /&gt;
In general, here&#039;s a list of specific issues to check:&lt;br /&gt;
* Can your application handle all frame sizes, including changing the frame size from frame to frame?&lt;br /&gt;
* Does your application properly react to lost packet by calling the decoder with a NULL packet?&lt;br /&gt;
&lt;br /&gt;
=== What is the complexity of Opus? ===&lt;br /&gt;
&lt;br /&gt;
The complexity of Opus varies by a large amount based on the settings used.&lt;br /&gt;
&lt;br /&gt;
It depends on the mode, audio bandwidth, number of channels, and even a &amp;quot;complexity knob&amp;quot; that can trade complexity for quality. It will run easily on any recent PC or smartphone. &lt;br /&gt;
&lt;br /&gt;
For slower embedded CPUs/DSPs, the amount of CPU required will vary depending on the configuration and the exact CPU, so you will need to experiment. Do not expect Opus to run quickly on really slow devices like 8-bit micro-controllers.&lt;br /&gt;
&lt;br /&gt;
=== Opus is using too much CPU for my application. What can I do? ===&lt;br /&gt;
&lt;br /&gt;
First don&#039;t panic and don&#039;t start writing assembly just yet.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible that you&#039;re just not using the right set of options.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re targeting an embedded/mobile platform, chances are the fixed-point build will be faster, so make sure you&#039;re using &#039;&#039;&#039;--enable-fixed-point&#039;&#039;&#039; or defining &#039;&#039;&#039;FIXED_POINT&#039;&#039;&#039; in the build system.&lt;br /&gt;
&lt;br /&gt;
Opus also has a complexity option that can trade quality for complexity. The default is highest quality and highest complexity. You can control this using &#039;&#039;&#039;OPUS_SET_COMPLEXITY()&#039;&#039;&#039; (see the &#039;&#039;&#039;[http://www.opus-codec.org/docs/ Documentation]&#039;&#039;&#039; for details).&lt;br /&gt;
&lt;br /&gt;
If all else fails and you need to optimize the Opus code, see the next question.&lt;br /&gt;
&lt;br /&gt;
=== I would like to optimize/improve/help with Opus. Where should I start? ===&lt;br /&gt;
&lt;br /&gt;
Please &#039;&#039;&#039;[http://www.opus-codec.org/contact/ contact us]&#039;&#039;&#039; before you start, or at least before you get too far.&lt;br /&gt;
&lt;br /&gt;
This will help coordinate the efforts made on Opus and reduce the probability of wasting your time on duplicated effort or going down the wrong path.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus have an echo canceller like Speex does? ===&lt;br /&gt;
&lt;br /&gt;
Echo cancellation is completely independent from codecs.&lt;br /&gt;
&lt;br /&gt;
You can use any echo canceller (including the one from libspeexdsp) along with Opus.&lt;br /&gt;
&lt;br /&gt;
That being said, among the free acoustic echo cancelers (AEC) we&#039;re aware of, the best is probably the Google AEC from the [https://code.google.com/p/webrtc/ WebRTC codebase].&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusTodo&amp;diff=16174</id>
		<title>OpusTodo</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusTodo&amp;diff=16174"/>
		<updated>2016-01-12T18:42:26Z</updated>

		<summary type="html">&lt;p&gt;MarkH: update for 1.1.2&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== For 1.1.3 ==&lt;br /&gt;
* aarch64 and AVX optimizations&lt;br /&gt;
&lt;br /&gt;
== For 1.2 ==&lt;br /&gt;
* Low bitrate quality improvements&lt;br /&gt;
&lt;br /&gt;
== Spec ==&lt;br /&gt;
* Ogg mapping. See [[https://tools.ietf.org/html/draft-ietf-codec-oggopus IETF draft]]&lt;br /&gt;
* Matroska mapping. See: [[MatroskaOpus]] And firefox/ffmpeg implementation&lt;br /&gt;
* RTP payload format. Mono/stereo mapping is complete [[https://tools.ietf.org/html/rfc7587 RFC 7587]], no multichannel mapping yet.&lt;br /&gt;
&lt;br /&gt;
== Website ==&lt;br /&gt;
* De-uglify webpage - some suggestions:&lt;br /&gt;
** write about codecs obsoleted by OPUS (Speex, CELT, Vorbis(?), and the prop. ones)&lt;br /&gt;
** write about implementations (libopus encoder/decoder, libavcodec decoder, any others?)&lt;br /&gt;
** comparison table (Opus, Vorbis, Speex, ..., MP5) of features (channels, freq, bits per sample, license, language (C89), integer impl. (Vorbis decoder only, Opus YES, ...)&lt;br /&gt;
** future use in video files (Theora? Dirac? WebM? other future codecs...)&lt;br /&gt;
** audio files for storage (like Vorbis, no raw Opus defined, only inside OGG), ... &lt;br /&gt;
* Promotional material (some nice free/public-domain sounds/radio stations in Opus format)&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
* Oggz-validate (should also validate opus toc)&lt;br /&gt;
&lt;br /&gt;
== Opus-tools ==&lt;br /&gt;
* Port opusdec to libopusfile/libopusurl.&lt;br /&gt;
* A simple real time streaming example tool&lt;br /&gt;
** Start with opusrtp.c in [https://git.xiph.org/?p=opus-tools.git opus-tools]&lt;br /&gt;
** Make &amp;lt;code&amp;gt;opusrtp rtp://example.com:5431/&amp;lt;/code&amp;gt; listen to that host and port and mux packets from there. Generalize the cpac bases --sniff implementation&lt;br /&gt;
** Make sending similarly generic. Maybe just &amp;lt;code&amp;gt;opusrtp source.opus -o rtp://example.com:5431/&amp;lt;/code&amp;gt; to send source.opus out to the destination?&lt;br /&gt;
** Make --sniff save one file per&lt;br /&gt;
** Implement DTLS-SRTP. See webrtc.&lt;br /&gt;
** audio capture/encode, decode/playback?&lt;br /&gt;
** Parse and act on sdp for convenience and testing.&lt;br /&gt;
&lt;br /&gt;
* EBU R128/Replaygain (half done— needs a gain tool)&lt;br /&gt;
&lt;br /&gt;
== Surround work ==&lt;br /&gt;
&lt;br /&gt;
* Apply spreading to energy masking&lt;br /&gt;
* More conservative energy masking (not just mean difference) and dynalloc&lt;br /&gt;
* Allow SILK/hybrid on center channel for voice?&lt;br /&gt;
&lt;br /&gt;
== Psychoacoustic stuff ==&lt;br /&gt;
&lt;br /&gt;
* Adaptive width narrowing and forced intensity stereo bands&lt;br /&gt;
&lt;br /&gt;
== Optimisations ==&lt;br /&gt;
&lt;br /&gt;
* Vectorising comb_filter()&lt;br /&gt;
* Use 16-bit mul plus shift in denormalise_bands()&lt;br /&gt;
* Optimise MDCT somehow&lt;br /&gt;
&lt;br /&gt;
== Third-Party tool enhancements ==&lt;br /&gt;
* mutagen: [https://bitbucket.org/lazka/mutagen/issue/202/oggopus-support-in-place-rewrites-for support padding in comments header], [https://bitbucket.org/lazka/mutagen/issue/203/oggopus-allow-updating-the-output_gain allow updating output gain in ID header]&lt;br /&gt;
&lt;br /&gt;
== Future work ==&lt;br /&gt;
* psymodel based VBR&lt;br /&gt;
* Remove copy in inverse MDCT&lt;br /&gt;
* Save some float&amp;lt;-&amp;gt;int conversions&lt;br /&gt;
* Improvements to LP mode CBR (greg has some code)&lt;br /&gt;
* Unconstrained SILK VBR&lt;br /&gt;
* Better handling for the case where FEC has a different bandwidth than the current mode&lt;br /&gt;
* PLC transitions on unprotected SILK-SILK bandwidth changes?&lt;br /&gt;
* Figure out how to use speech/music detection optimally&lt;br /&gt;
** find optimal switching time (low energy/tonality)&lt;br /&gt;
* Improve variable frame size&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=MatroskaOpus&amp;diff=16173</id>
		<title>MatroskaOpus</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=MatroskaOpus&amp;diff=16173"/>
		<updated>2015-12-31T04:56:23Z</updated>

		<summary type="html">&lt;p&gt;MarkH: update URL&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{{draft}}&lt;br /&gt;
This is an encapsulation spec for the [[Opus]] codec in [http://matroska.org/ Matroska]. There are a number of outstanding functional issues with muxing Opus in Matroska, and until those are resolved, use of this spec is NOT RECOMMENDED.&lt;br /&gt;
&lt;br /&gt;
* CodecID is A_OPUS&lt;br /&gt;
* SampleFrequecy is 48000&lt;br /&gt;
* Channels is number of output PCM channels&lt;br /&gt;
* SeekPreRoll is set to 80000000&lt;br /&gt;
* CodecPrivate consists of the &#039;OpusHead&#039; packet, identical to the Ogg mapping.&lt;br /&gt;
&lt;br /&gt;
The &#039;OpusHead&#039; format is defined by the [https://tools.ietf.org/html/draft-ietf-codec-oggopus Ogg Opus] mapping. In particular it includes pre-skip, gain, and the channel mapping table required for correct surround output.&lt;br /&gt;
&lt;br /&gt;
The second &#039;OpusTags&#039; header packet from Ogg Opus is not used in the Matroska encapsulation. Matroska has its own system for tag metadata, and this avoids duplicating it and the need for sub-framing to index multiple packets within the CodecPrivate element.&lt;br /&gt;
&lt;br /&gt;
SeekPreRoll [56][BB] is a new unsigned integer element added to the TrackEntry element. The value is the number of nanoseconds that must be discarded, for that stream, after a seek until the decoded data is valid to render.&lt;br /&gt;
&lt;br /&gt;
CodecDelay [56][AA] is a new unsigned integer element added to the TrackEntry element. The value is the number of nanoseconds that must be discarded, for that stream, from the start of that stream. The value is also the number of nanoseconds that all encoded timestamps for that stream must be shifted to get the presentation timestamp. (This will fix Vorbis encoding as well.)&lt;br /&gt;
&lt;br /&gt;
DiscardPadding [75][A2] is a new signed integer element added to the BlockGroup element. DiscardPadding is the duration in nanoseconds of the silent data added to the Block (padding at the end of the block). The duration of DiscardPadding is not calculated in the duration of the Track and should be discarded during playback. (This will fix Vorbis encoding as well.)&lt;br /&gt;
&lt;br /&gt;
== Muxing Recommendations ==&lt;br /&gt;
&lt;br /&gt;
In order to prevent extraneous parsing of muxed content for the players that want to start playback at exactly time T, we will recommend muxers create files with another Cluster within N-1 at T-SeekPreRoll, where T is the start time of Cluster N. Then add CuePoints for all the new T-SeekPreRoll Clusters with a CueTrack of the audio stream. The CuePoints for the video stream will not change. &lt;br /&gt;
&lt;br /&gt;
For example, a file is a muxed MKV with the following characteristics: &lt;br /&gt;
* 5 second interval between video keyframes&lt;br /&gt;
* Each video keyframe begins a new Cluster&lt;br /&gt;
* Cues will contain video keyframe CuePoints&lt;br /&gt;
* For each video keyframe at time T there will be new Cluster at T-SeekPreRoll&lt;br /&gt;
* Cues will contain audio CuePoints for T-SeekPreRoll Clusters&lt;br /&gt;
* Audio and video are interleaved in monotonically increasing order&lt;br /&gt;
&lt;br /&gt;
Assume SeekPreRoll is 80 milliseconds, the first Cluster starts at 0 milliseconds with a video keyframe Block and has a duration of 4920 milliseconds. The second Cluster starts at 4920 milliseconds with an audio Block and has a duration of 80 milliseconds. Just to be clear, the second Cluster can contain Blocks from all streams. The third Cluster starts at 5000 milliseconds with a video keyframe Block and has a duration of 4920 milliseconds. The fourth Cluster starts at 9920 milliseconds with an audio Block and has a duration of 80 milliseconds.&lt;br /&gt;
&lt;br /&gt;
With this recommendation players that want audio and video to start playback at time T can seek to Cluster T-SeekPreRoll and start decoding the audio stream. This will work the same for both local and HTTP playback.&lt;br /&gt;
&lt;br /&gt;
== Open Questions ==&lt;br /&gt;
&lt;br /&gt;
* Should we say muxers MAY or SHOULD NOT produce simple streams without filling in CodecPrivate?&lt;br /&gt;
** If the CodecPrivate is empty or not present and Channels is 1 or 2, players MAY treat it as a sane set of defaults, I guess. e.g. channel mapping family 0, no pre-skip or gain.&lt;br /&gt;
** For Channels &amp;gt; 2 the track MUST be rejected, since there&#039;s no way to map the encoded substreams to channels.&lt;br /&gt;
** We would also have to decide on a default value for OutputGain.&lt;br /&gt;
** Version must be 1.&lt;br /&gt;
* How can sample-accurate end-time trimming work in Matroska?&lt;br /&gt;
** We defined a new element added to a BlockGroup, DiscardPadding (previously PostPadding), which is defined as the number of nanoseconds to discard from the Block.&lt;br /&gt;
** Currently all software encapsulating Vorbis in Matroska is broken in this regard, and muxing a Vorbis file in Matroska causes it to get longer (i.e., produce more audio output than the original Ogg file). It would be unfortunate to repeat this disaster for Opus. This needs a new element specifying the number of samples to trim, perhaps a new BlockGroup child.&lt;br /&gt;
*** This has been addressed with DiscardPadding for Opus. DiscardPadding was speced to fix Vorbis (as well as other codecs) too.&lt;br /&gt;
* If new elements are required, can they be defined so as to enable correct seeking in rolling intra (a.k.a intra refresh) video as well?&lt;br /&gt;
** SeekPreRoll should work for rolling intra video.&lt;br /&gt;
&lt;br /&gt;
== Handling Pre-skip data ==&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;On [http://lists.matroska.org/cgi-bin/mailman/listinfo/matroska-devel Matroska-dev] we decided to implement proposal one ([http://lists.matroska.org/pipermail/matroska-devel/2013-June/004475.html ref]).&#039;&#039;&#039;&lt;br /&gt;
* Use Cases: &lt;br /&gt;
** UC1: Playback starts from the beginning of the stream. Source stream time starts at 0.&lt;br /&gt;
** UC2: Playback starts from the beginning of the stream. Pre-skip data ends in middle of compressed packet.&lt;br /&gt;
** UC3: Playback starts from the middle of the stream &amp;gt; SeekPreRoll time.&lt;br /&gt;
** UC4: Playback starts from the middle of the stream &amp;lt; SeekPreRoll time.&lt;br /&gt;
** UC5: Encode source stream to Opus, mux to Matroksa, then decode Opus stream, must have same number of samples as source stream.&lt;br /&gt;
&lt;br /&gt;
* one: Timeshift the timestamps by pre-skip data.&lt;br /&gt;
** The Opus audio stream pre-skip data starts from time 0 and adds the pre-skip time to the normal audio time, like how Opus files are muxed into ogg files. We would add a new element to the TrackEntry element, CodecDelay, and the player would adjust the timestamps of the decoded samples by subtracting CodecDelay. All use cases should be covered.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** The timestamp of the Block does not match the timestamp of the playback position.&lt;br /&gt;
*** Does not generalize known &amp;quot;decode, but not render&amp;quot; data.&lt;br /&gt;
*** Forces the player to handle the pre-skip samples. I.e. not the decoder.&lt;br /&gt;
&lt;br /&gt;
* two: Add pre-skip data to CodecPrivate.&lt;br /&gt;
** On every discontinuity the decoder would need to decode and throw away the pre-skip data.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** UC2 will throw away valid data and the AV sync will be off.&lt;br /&gt;
*** UC3 will redundantly decode the pre-skip data.&lt;br /&gt;
&lt;br /&gt;
* three: Add TimeToDiscard to Block.&lt;br /&gt;
** Add an element to the Block element, TimeToDiscard in nanoseconds. A value of -1 would not render the whole Block, which would have the same effect as setting the invisible bit. How would this affect the Block timestamp? Maybe the new element should be SamplesToDiscard or DataToDiscard?&lt;br /&gt;
** Cons:&lt;br /&gt;
&lt;br /&gt;
* four: Blocks that contain pre-skip data will set invisible flag.&lt;br /&gt;
** Blocks that contain pre-skip data have timestamps from the beginning of the stream. Blocks that only contain normal data have timestamps from the playback position.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** Forces the player to handle the pre-skip samples. I.e. not the decoder.&lt;br /&gt;
*** UC2 will throw away valid data and the AV sync will be off. Other use cases should be fine.&lt;br /&gt;
&lt;br /&gt;
* five: Force pre-skip packets to be prepended to the first normal packet in the first Block.&lt;br /&gt;
** The first Block&#039;s timestmap will be set to the start time of the source playback position. We would add a new element to the TrackEntry element, CodecDelay. All use cases should be covered.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** Does not generalize known &amp;quot;decode, but not render&amp;quot; data.&lt;br /&gt;
*** Forces the player to handle the pre-skip samples. I.e. not the decoder.&lt;br /&gt;
&lt;br /&gt;
* six: Create a new codec, OPUS_MKV.&lt;br /&gt;
** Basically the codec will wrap Opus packets with data telling the decoder what type of Opus packet it contains. Essentially we would be creating a new codec to handle pre-skip data within the decoder.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** There will be two types of Opus data streams!&lt;br /&gt;
*** Does not generalize known &amp;quot;decode, but not render&amp;quot; data.&lt;br /&gt;
&lt;br /&gt;
* seven: Negative timestamps.&lt;br /&gt;
** The SimpleBlock timestamp is signed 16 bits, so the format can signal about half of the pre-skip if playback timestamps are to start at zero.&lt;br /&gt;
** One could set an incorrect timestamp on the skipped blocks, and rely on the decoder to drop them based on the OpusHead preskip value. As long as the initial blocks are timestamped &amp;lt;= start of output this shouldn&#039;t affect seeking.&lt;br /&gt;
** Cons:&lt;br /&gt;
*** Moritz suggests this won&#039;t work because the resolution of the timestamps is controlled by the muxer, so the SimpleBlock timestamp offset isn&#039;t sample accurate anyway ([http://lists.matroska.org/pipermail/matroska-devel/2012-September/004254.html ref]).&lt;br /&gt;
&lt;br /&gt;
* eight: &amp;lt;!-- Proposal 8 needs a title, here. --&amp;gt;&lt;br /&gt;
** The Ogg format uses granule positions which are converted to presentation timecodes using codec specific information on a per logical stream basis.&lt;br /&gt;
** The Matroska format uses absolute timecodes with an arbitrary per segement accuracy for all tracks in the segment.&lt;br /&gt;
** It is the belief of this tikiman that using a timecode offset of any kind in MKV is unholy.&lt;br /&gt;
** The preskip is communicated to the media software via the Opus header in the codec private data. At the begining of the track, the track timecode is not increased until prekip samples are in track frames.&lt;br /&gt;
** From then on audio is muxed as normal, however the audio should be muxed &amp;gt;= 3840 samples behind video frames.&lt;br /&gt;
*** i.e. Cluster Timecode: 5.000 seconds&lt;br /&gt;
*** Video Track Key Frame 5.000 seconds&lt;br /&gt;
*** Opus Track Frame 4.920 seconds&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OggOpus&amp;diff=16172</id>
		<title>OggOpus</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OggOpus&amp;diff=16172"/>
		<updated>2015-12-31T04:55:06Z</updated>

		<summary type="html">&lt;p&gt;MarkH: spelling, update URLs&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;&#039;&#039;&#039;Superceded by [https://tools.ietf.org/html/draft-ietf-codec-oggopus the IETF draft].&#039;&#039;&#039;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== Ogg Mapping for Opus ==&lt;br /&gt;
&lt;br /&gt;
The IETF Opus codec is a low-latency audio codec optimized for both voice and general-purpose audio. See the [https://tools.ietf.org/html/rfc6716 Opus Specification] for technical details.&lt;br /&gt;
&lt;br /&gt;
Almost everything about Opus is either fixed or dynamically switchable, so most of the usual ID and setup header parameters in the header packets of an Ogg encapsulation aren&#039;t needed. In particular, bitrate, packet duration, mono/stereo flags, and coding modes are all dynamically switchable from packet to packet. The first one or two bytes in each data packet, the start of the &#039;TOC sequence&#039; that defines the layout of the packet, specifies all of these parameters for that particular packet. See Section 3 of the Opus Specification for the exact format of the TOC sequence.&lt;br /&gt;
&lt;br /&gt;
The remaining parameters that must be signaled are&lt;br /&gt;
&lt;br /&gt;
* The magic number for stream identification,&lt;br /&gt;
* The stream count and coupling for multichannel audio, and&lt;br /&gt;
* Any metadata or tags.&lt;br /&gt;
&lt;br /&gt;
=== Content Type ===&lt;br /&gt;
&lt;br /&gt;
The recommended mime-type for Ogg Opus files is &#039;&#039;&#039;audio/ogg&#039;&#039;&#039;, defined in [https://www.ietf.org/rfc/rfc5334.txt RFC 5334].&lt;br /&gt;
&lt;br /&gt;
If more specificity is desired, one can distinguish Opus files as &#039;audio/ogg; codecs=opus&#039;.&lt;br /&gt;
&lt;br /&gt;
The recommended filename extension for Ogg Opus files is &#039;&#039;&#039;.opus&#039;&#039;&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Packet Organization ===&lt;br /&gt;
&lt;br /&gt;
Opus is framed in a continuous logical [https://www.xiph.org/ogg/doc/framing.html Ogg stream]. &lt;br /&gt;
&lt;br /&gt;
There are two mandatory headers. The granule position of the pages containing these headers MUST be zero.&lt;br /&gt;
&lt;br /&gt;
The first packet in the logical Ogg stream MUST contain the identification header, which uniquely identifies a stream as Opus audio. It MUST begin with the 8 bytes &amp;quot;OpusHead&amp;quot;. It MUST be placed alone in the first page of the logical Ogg stream. This page MUST have the ’beginning of stream’ flag set.&lt;br /&gt;
&lt;br /&gt;
The second Opus packet MUST contain the comment header. It must begin with the 8 bytes &amp;quot;OpusTags&amp;quot;. It MAY span one or more pages, beginning on the second page of the logical stream. However many pages it spans, the comment header packet MUST finish the page on which it ends.&lt;br /&gt;
&lt;br /&gt;
All subsequent pages are audio data pages and the packets they contain are audio data packets. The first audio page SHOULD NOT have the &#039;continued packet&#039; flag set (which would indicate the first audio packet is continued from a previous page). Packets MUST be placed into Ogg pages in order until the end of stream. Audio packets MAY span page boundaries. A decoder MUST treat a zero-byte audio packet as if it were an Opus packet with an illegal TOC sequence. The last page SHOULD have the &#039;end of stream&#039; flag set, but implementations should be prepared to deal with truncated streams which do not have a page marked &#039;end of stream&#039;. The final packet SHOULD complete on the last page, i.e., the final lacing value should be less than 255. There MUST NOT be any more pages in an Opus logical stream after a page marked &#039;end of stream&#039;.&lt;br /&gt;
&lt;br /&gt;
=== Granule Position ===&lt;br /&gt;
&lt;br /&gt;
The granule position of an audio page encodes the total number of PCM samples in the stream up to and including the last fully-decodable sample from the last packet &#039;&#039;completed&#039;&#039; on that page. A page that is entirely spanned by a single packet (that completes on a subsequent page) has no granule position, and the granule position field MUST be set to the special value ’-1’ in two&#039;s complement.&lt;br /&gt;
&lt;br /&gt;
The granule position of an audio page is in units of PCM audio samples at a fixed rate of 48 kHz (per channel; a stereo stream’s granule position does not increment at twice the speed of a mono stream). It is possible to run a decoder at other sampling rates, but the format and this specification always count samples assuming a 48 kHz decoding rate.&lt;br /&gt;
&lt;br /&gt;
The duration of an Opus packet may be any multiple of 2.5 ms, up to a maximum of 120 ms. This duration is encoded in the TOC sequence at the beginning of each packet. The number of samples returned by a decoder corresponds to this duration exactly, even for the first few packets. For example, a 20 ms packet fed to a decoder running at 48 kHz will always return 960 samples. A demuxer can parse these TOC sequences to work backwards or forwards from a packet with a known granule position (i.e., the last packet completed on some page) in order to assign granule positions to every packet, or even every individual sample. The one exception is the last page in the stream, as described below.&lt;br /&gt;
&lt;br /&gt;
All other pages with completed packets after the first MUST have a granule position equal to the number of samples contained in packets that complete on that page plus the granule position of the most recent page with completed packets. This guarantees that a demuxer can assign individual packets the same granule position when working forwards as when working backwards. There must not be any gaps. In order to support capturing a stream that uses discontinuous transmission (DTX), an encoder SHOULD emit packets that explicitly request the use of Packet Loss Concealment (PLC) (i.e., with a frame length of 0, as defined in Section 3.2.1 of the Opus Specification) in place of the packets that were not transmitted.&lt;br /&gt;
&lt;br /&gt;
There is some amount of latency introduced during the decoding process, to allow for overlap in the MDCT modes, stereo mixing in the LP modes, and resampling, and the encoder will introduce even more latency (though the exact amount is not specified). Therefore the first few samples produced by the decoder do not correspond to any real, input audio, but are instead composed of padding inserted by the encoder to compensate for this latency. These samples must be stored and decoded, as Opus is an asymptotically convergent predictive codec, meaning the decoded contents of each frame depend on the recent history of decoder inputs. A &#039;pre-skip&#039; field in the ID header signals the number of samples which should be skipped at the beginning of the stream. This provides sufficient history to the decoder so that it has already converged before the stream&#039;s output begins. It may also be used to perform sample-accurate cropping of existing encoded streams. This amount need not be a multiple of 2.5 ms, may be smaller than a single packet, or may span the contents of several packets.&lt;br /&gt;
&lt;br /&gt;
The PCM sample position is determined from the granule position using the formula&lt;br /&gt;
&lt;br /&gt;
 &#039;PCM sample position&#039; = &#039;granule position&#039; - &#039;pre-skip&#039; .&lt;br /&gt;
&lt;br /&gt;
For example, if the granule position of the first page is 59971, and the pre-skip is 11971, then the PCM sample position of the last decoded sample from the first page is 48000. This may be converted into a playback time using the formula&lt;br /&gt;
&lt;br /&gt;
                   &#039;PCM sample position&#039;&lt;br /&gt;
 &#039;playback time&#039; = --------------------- .&lt;br /&gt;
                          48000.0&lt;br /&gt;
&lt;br /&gt;
The initial PCM sample position before any samples are played is normally &#039;0&#039;. In this case, the PCM sample position of the first audio sample to be played starts at &#039;1&#039;, because it marks the time on the clock &#039;&#039;after&#039;&#039; that sample has been played, and a stream that is exactly one second long has a final PCM sample position of &#039;48000&#039;, as in the example here.&lt;br /&gt;
&lt;br /&gt;
Vorbis streams use a granule position smaller than the number of audio samples contained in the first page to indicate that some of those samples must be trimmed from the output. However, to do so it requires that the first page contains exactly two packets, in order to allow the decoder to perform PCM position adjustments before needing to return any PCM data. Opus uses the pre-skip mechanism for this purpose instead, since the encoder may introduce more than a single packet&#039;s worth of latency, and since very large packets in streams with a very large number of channels may not fit on a single page.&lt;br /&gt;
&lt;br /&gt;
The page with the &#039;end of stream&#039; flag set MAY have a granule position that indicates the page contains less audio data than would normally be returned by decoding up through the final packet. This is used to end the stream somewhere other than an even frame boundary. The granule position of the most recent audio page with completed packets is used to make this determination, or &#039;0&#039; is used if there were no previous audio pages with a completed packet. The difference between these granule positions indicates how many samples to keep after decoding the packets that completed on the final page. The remaining samples are discarded. The number of discarded samples SHOULD be smaller than the number decoded from the last packet.&lt;br /&gt;
&lt;br /&gt;
The granule position of the first audio page with a completed packet MAY be larger than the number of samples contained in packets that complete on that page, however it MUST NOT be smaller, unless that page has the &#039;end of stream&#039; flag set. Allowing a granule position larger than the number of samples allows the beginning of a stream to be cropped without rewriting the granule position of all the remaining pages. This means that the PCM sample position just before the first sample to be played may be larger than &#039;0&#039;, but the PCM sample position relative to &#039;0&#039; should still be used for the purposes of synchronization when multiplexing with other logical streams. This does not affect the behavior of pre-skip: exactly &#039;pre-skip&#039; samples should be skipped from the beginning of the decoded output, even if the initial PCM sample position is greater than zero.&lt;br /&gt;
&lt;br /&gt;
On the other hand, a granule position that is smaller than the number of decoded samples prevents a demuxer from working backwards to assign each packet or each individual sample a valid granule position, since granule positions must be non-negative. A decoder MUST reject as invalid any stream where the granule position is smaller than the number of samples contained in packets that complete on the first page with a completed packet, unless that page has the &#039;end of stream&#039; flag set. It MAY defer this action until it decodes the last packet completed on that page. If that page has the &#039;end of stream&#039; flag set, a demuxer can work forwards from the granule position &#039;0&#039;, but MUST reject as invalid any stream where the granule position is smaller than the &#039;pre-skip&#039; amount. This would indicate that more samples should be skipped from the initial decoded output than exist in the stream.&lt;br /&gt;
&lt;br /&gt;
==== ID Header ====&lt;br /&gt;
&lt;br /&gt;
      0                   1                   2                   3&lt;br /&gt;
      0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 6 7 8 9 0 1&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
     |       &#039;O&#039;     |      &#039;p&#039;      |     &#039;u&#039;       |     &#039;s&#039;       |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
     |       &#039;H&#039;     |       &#039;e&#039;     |     &#039;a&#039;       |     &#039;d&#039;       |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
     |  version = 1  | channel count |           pre-skip            |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
     |                original input sample rate in Hz               |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
     |    output gain Q7.8 in dB     |  channel map  |               |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+               :&lt;br /&gt;
     |                                                               |&lt;br /&gt;
     :          optional channel mapping table...                    :&lt;br /&gt;
     |                                                               |&lt;br /&gt;
     +-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+-+&lt;br /&gt;
&lt;br /&gt;
Brief description of each field:&lt;br /&gt;
&lt;br /&gt;
 - Magic signature: &amp;quot;OpusHead&amp;quot; (64 bits)&lt;br /&gt;
 - Version number (8 bits unsigned): 0x01 for this spec&lt;br /&gt;
 - Channel count &#039;c&#039; (8 bits unsigned): MUST be &amp;gt; 0&lt;br /&gt;
 - Pre-skip (16 bits unsigned, little endian)&lt;br /&gt;
 - Input sample rate (32 bits unsigned, little endian): informational only&lt;br /&gt;
 - Output gain (16 bits, little endian, signed Q7.8 in dB) to apply when&lt;br /&gt;
   decoding&lt;br /&gt;
 - Channel mapping family (8 bits unsigned)&lt;br /&gt;
  --  0 = one stream: mono or L,R stereo&lt;br /&gt;
  --  1 = channels in vorbis spec order: mono or L,R stereo or ... or FL,C,FR,RL,RR,LFE, ...&lt;br /&gt;
  --  2..254 = reserved (treat as 255)&lt;br /&gt;
  --  255 = no defined channel meaning&lt;br /&gt;
 If channel mapping family &amp;gt; 0&lt;br /&gt;
 - Stream count &#039;N&#039; (8 bits unsigned): MUST be &amp;gt; 0&lt;br /&gt;
 - Two-channel stream count &#039;M&#039; (8 bits unsigned): MUST satisfy M &amp;lt;= N, M+N &amp;lt;= 255&lt;br /&gt;
 - Channel mapping (8*c bits)&lt;br /&gt;
   -- one stream index (8 bits unsigned) per channel (255 means silent throughout the file)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Detailed definition of each field:&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Magic signature&#039;&#039;&#039;&lt;br /&gt;
The magic signature &amp;quot;OpusHead&amp;quot; allows codec identification and is human readable. Starting with &#039;Op&#039; helps distinguish it from data packets, as this is an invalid TOC sequence.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Version&#039;&#039;&#039;&lt;br /&gt;
The version number MUST always be &#039;1&#039; for this version of the encapsulation specification.&lt;br /&gt;
&lt;br /&gt;
Implementations SHOULD treat streams where the upper four bits of the version number match a recognized specification as backwards-compatible with that specification. That is, the version number can be considered split into &amp;quot;major&amp;quot; and &amp;quot;minor&amp;quot; version sub-fields, with changes to the &amp;quot;minor&amp;quot; sub-field in the lower four bits signaling compatible changes. For example, a decoder implementing this specification SHOULD accept any stream with a version number 15 or less, and SHOULD assume any stream with a version number 16 or greater is incompatible. The initial version &#039;1&#039; was chosen to keep implementations from relying on this byte as a null terminator for the OpusHead string.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Channel count&#039;&#039;&#039; &#039;c&#039;&lt;br /&gt;
The number of channels byte specifies the number of output channels (1...255) for this Ogg Opus stream.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Pre-skip&#039;&#039;&#039;&lt;br /&gt;
This is the number of samples (at 48 kHz) to discard from the decoder output when starting playback, and also the number to subtract from a page&#039;s granule position to calculate its PCM sample position.&lt;br /&gt;
&lt;br /&gt;
When constructing cropped Ogg Opus streams, a pre-skip of at least 3840 samples (80 ms) is RECOMMENDED to ensure complete convergence.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Input sample rate&#039;&#039;&#039;&lt;br /&gt;
This is &#039;&#039;not&#039;&#039; the sample rate to use for playback of the encoded data.&lt;br /&gt;
&lt;br /&gt;
Opus has a handful of coding modes, with internal audio bandwidths of 4, 6, 8, 12, and 20 kHz. Each packet in the stream may have a different audio bandwidth. Regardless of the audio bandwidth, the reference decoder supports decoding any stream at a sample rate of 8, 12, 16, 24, or 48 kHz. The original sample rate of the encoder input is not preserved by the lossy compression.&lt;br /&gt;
&lt;br /&gt;
An Ogg Opus player SHOULD select the playback sample rate according to the following procedure:&lt;br /&gt;
* If the hardware supports 48 kHz playback, decode at 48 kHz,&lt;br /&gt;
* else if the hardware&#039;s highest available sample rate is a supported rate, decode at this sample rate,&lt;br /&gt;
* else if the hardware&#039;s highest available sample rate is less than 48 kHz, decode at the next higher supported rate and resample,&lt;br /&gt;
* else decode at 48 kHz and resample.&lt;br /&gt;
&lt;br /&gt;
However, the &#039;input sample rate&#039; field allows the encoder to pass the sample rate of the original input stream as metadata. This may be useful when the user requires the output sample rate to match the input sample rate. For example, a non-player decoder writing PCM format to disk might choose to resample the output audio back to the original input rate to reduce surprise to the user, who might reasonably expect to get back a file with the same sample rate as the one they fed to the encoder.&lt;br /&gt;
&lt;br /&gt;
A value of zero indicates &#039;unspecified&#039;. Encoders SHOULD write the actual input rate or zero, but decoder implementations which do something with this field SHOULD take care to behave sanely if given crazy values (e.g. don&#039;t &lt;br /&gt;
actually upsample the output to 10 MHz if requested).&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Output gain&#039;&#039;&#039;&lt;br /&gt;
This is a gain to be applied by the decoder. Virtually all players and media frameworks should apply it by default. If a player chooses to apply any volume adjustment or gain modification, such as the R128_TRACK_GAIN or a user-facing volume knob, the adjustment MUST be applied &#039;&#039;in addition&#039;&#039; to this output gain in order to achieve playback at the desired volume.&lt;br /&gt;
&lt;br /&gt;
An encoder SHOULD set the output gain to zero, and instead apply any gain prior to encoding, when this is possible and does not conflict with the user&#039;s wishes. The output gain should only be nonzero when the gain is adjusted after encoding, or when the user wishes to adjust the gain for playback while preserving the ability to recover the original signal amplitude.&lt;br /&gt;
&lt;br /&gt;
Although the output gain has enormous range (+/- 128 dB, enough to amplify inaudible sounds to the threshold of physical pain), most applications can only reasonably use a small portion of this range around zero. The large range serves in part to ensure that gain can always be losslessly transferred between OpusHead and R128_TRACK_GAIN (see below) without saturating.&lt;br /&gt;
&lt;br /&gt;
The gain is the 20 log&amp;lt;sub&amp;gt;10&amp;lt;/sub&amp;gt; ratio of output to input sample values to be applied to the decoder output. E.g. &amp;lt;code&amp;gt;sample *= pow(10, header.gain/(20.*256))&amp;lt;/code&amp;gt; where header.gain is the raw 16 bit Q7.8 value from the header.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Channel mapping family&#039;&#039;&#039;&lt;br /&gt;
This byte indicates the order and semantic meaning of the various channels encoded in each Opus packet.  &lt;br /&gt;
&lt;br /&gt;
Each possible value of this byte indicates a &#039;&#039;mapping family&#039;&#039;, which defines a set of allowed numbers of channels, and the ordered set of channel names for each allowed number of channels. Currently there are three defined mapping families, although more may be added:&lt;br /&gt;
&lt;br /&gt;
* Family 0 (RTP mapping)&lt;br /&gt;
** Allowed numbers of channels: 1 or 2&lt;br /&gt;
** 1 channel: monophonic (mono)&lt;br /&gt;
** 2 channels: stereo (left, right)&lt;br /&gt;
** &#039;&#039;&#039;Special mapping&#039;&#039;&#039;: this channel mapping value also indicates that the contents consists of a single Opus stream that is stereo if and only if c==2, with stream index 0 mapped to channel 0, and (if stereo) stream index 1 mapped to channel 1.  When the channel mapping byte has this value, no further fields are present in OpusHead.&lt;br /&gt;
* Family 1 ([https://www.xiph.org/vorbis/doc/Vorbis_I_spec.html#x1-810004.3.9 Vorbis channel order])&lt;br /&gt;
** Allowed numbers of channels: 1 ... 8&lt;br /&gt;
** Channel meanings depend on the number of channels, see the Vorbis mapping for details.&lt;br /&gt;
* Family 255 (no defined channel meaning)&lt;br /&gt;
** Allowed numbers of channels: 1...255&lt;br /&gt;
** Channels are unidentified.  General-purpose players SHOULD NOT attempt to play these streams, and offline decoders MAY deinterleave the output into separate PCM files, one per channel. Decoders SHOULD NOT produce output for channels mapped to stream index 255 (pure silence) unless they have no other way to indicate the index of non-silent channels.&lt;br /&gt;
&lt;br /&gt;
The remaining channel mapping families (2...254) are reserved. A decoder encountering a reserved mapping byte should act as though the mapping byte is 255.&lt;br /&gt;
&lt;br /&gt;
An Ogg Opus player MUST play any Ogg Opus stream with a channel mapping family of 0 or 1, even if the number of channels does not match the physically connected audio hardware. Players SHOULD perform channel mixing to increase or reduce the number of channels as needed.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Stream count&#039;&#039;&#039; &#039;N&#039;&lt;br /&gt;
This field indicates the total number of streams so the decoder can correctly parse the packed Opus packets inside the Ogg packet.&lt;br /&gt;
&lt;br /&gt;
For channel mapping family 0, this value defaults to 1, and is not coded.&lt;br /&gt;
&lt;br /&gt;
A multi-channel Opus file is composed of one or more individual Opus streams, each of which produce one or two channels of decoded data. Each Ogg packet contains one Opus packet from each stream. The first N-1 Opus packets are packed using the self-delimiting framing from Appendix B of the Opus Specification. The remaining Opus packet is packed using the regular, undelimited framing from Section 3 of the Opus Specification. All the Opus packets in a single Ogg packet MUST be constrained to produce the same number of decoded samples. A decoder SHOULD treat any Opus packet whose duration is different from that of the first Opus packet in an Ogg packet as if it were an Opus packet with an illegal TOC sequence.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Two-channel stream count&#039;&#039;&#039; &#039;M&#039;&lt;br /&gt;
Describes the number of streams whose decoders should be configured to produce two channels. This must be no larger than the number of total streams.&lt;br /&gt;
&lt;br /&gt;
For channel mapping family 0, this value defaults to c-1 (i.e., 0 for mono and 1 for stereo), and is not coded.&lt;br /&gt;
&lt;br /&gt;
Each packet in an Opus stream has an internal channel count of 1 or 2, which can change from packet to packet. This is selected by the encoder depending on the bitrate and the contents being encoded. The original channel count of the encoder input is not preserved by the lossy compression.&lt;br /&gt;
&lt;br /&gt;
Regardless of the internal channel count, any Opus stream may be decoded as mono (a single channel) or stereo (two channels) by appropriate initialization of the decoder. The &amp;quot;two-channel stream count&amp;quot; field indicates that the first M Opus decoders should be initialized in stereo mode, and the remaining N-M decoders should be initialized in mono mode. The total number of decoded channels (M+N) MUST be no larger than 255, as there is no way to index more channels than that in the channel mapping.&lt;br /&gt;
&lt;br /&gt;
* &#039;&#039;&#039;Channel mapping&#039;&#039;&#039;&lt;br /&gt;
Contains one index per output channel indicating which decoded channel should be used. If the index is less than 2*M, the output MUST be taken from decoding stream (index/2) as stereo and selecting the left channel if index is even, and the right channel if index is odd. If the index is 2*M or larger, the output MUST be taken from decoding stream (index-M) as mono. As a special case, an index of 255 means that the corresponding output channel MUST contain pure silence.&lt;br /&gt;
&lt;br /&gt;
For channel mapping family 0, the first index defaults to 0, and if c==2, the second index defaults to 1. Neither index is coded.&lt;br /&gt;
&lt;br /&gt;
The number of output channels (c) is not constrained to match the number of decoded channels (M+N). A single index MAY appear multiple times, i.e., the same decoded channel may be mapped to multiple output channels. Some decoded channels might not be assigned to any output channel, as well.&lt;br /&gt;
&lt;br /&gt;
==== Comment Header ====&lt;br /&gt;
&lt;br /&gt;
 - 8 byte &#039;OpusTags&#039; magic signature (64 bits)&lt;br /&gt;
 - The remaining data follows the vorbis-comment header design used in OggVorbis (without the &amp;quot;framing-bit&amp;quot;), OggTheora, and Speex:&lt;br /&gt;
  * Vendor string (always present).&lt;br /&gt;
  ** 4-byte little-endian length field, followed by length bytes of UTF-8 vendor string.&lt;br /&gt;
  * TAG=value metadata strings (zero or more).&lt;br /&gt;
  ** 4-byte little-endian string count.&lt;br /&gt;
  ** Count strings consisting of 4-byte little-endian length and length bytes of UTF-8 string in &amp;quot;tag=value&amp;quot; form.&lt;br /&gt;
&lt;br /&gt;
One new comment field is introduced for Ogg Opus:&lt;br /&gt;
 R128_TRACK_GAIN=-573  &lt;br /&gt;
representing the volume shift needed to normalize the track&#039;s volume. The gain is a Q7.8 fixed point number in dB, as in the OpusHead &amp;quot;output gain&amp;quot; field. This field is similar to the [[VorbisComment#Replay_Gain|REPLAYGAIN_TRACK_GAIN field in Vorbis]], although the normal volume reference is the [https://tech.ebu.ch/loudness EBU-R128] standard.&lt;br /&gt;
&lt;br /&gt;
An Ogg Opus file MUST NOT have more than one such field, and if present its value MUST be an integer from -32768 to +32767 inclusive, represented in ASCII with no whitespace. If present, it MUST correctly represent the R128 normalization gain (relative to the OpusHead output gain). If a player chooses to make use of the TRACK_GAIN, it MUST be applied &#039;&#039;in addition&#039;&#039; to the OpusHead output gain. If an encoder populates the TRACK_GAIN field, and the output gain is not otherwise constrained or specified, the encoder SHOULD write the R128 gain into the OpusHead output gain and write &amp;quot;R128_TRACK_GAIN=0&amp;quot;. If a tool modifies the OpusHead &amp;quot;output gain&amp;quot; field, it MUST also update or remove the R128_TRACK_GAIN comment field.&lt;br /&gt;
&lt;br /&gt;
There is no comment field corresponding to Replaygain&#039;s ALBUM_GAIN; that information should instead be stored in the OpusHead &#039;output gain&#039; field.&lt;br /&gt;
&lt;br /&gt;
To avoid confusion with multiple normalization schemes, an OpusTags packet SHOULD NOT contain any of the REPLAYGAIN_TRACK_GAIN, REPLAYGAIN_TRACK_PEAK, REPLAYGAIN_ALBUM_GAIN, or REPLAYGAIN_ALBUM_PEAK fields.&lt;br /&gt;
&lt;br /&gt;
== Other Implementation Notes ==&lt;br /&gt;
&lt;br /&gt;
When seeking within an Ogg Opus stream, the decoder should start decoding (and discarding the output) at least 3840 samples (80 ms) prior to the seek point in order to ensure that the output audio is correct at the seek point.&lt;br /&gt;
&lt;br /&gt;
Technically valid Opus packets can be arbitrarily large due to the padding format, although the amount of non-padding data they can contain is bounded. These packets may be spread over a similarly enormous number of Ogg pages. Encoders SHOULD use no more padding than required to make a variable bitrate (VBR) stream constant bitrate (CBR). Decoders SHOULD avoid attempting to allocate excessive amounts of memory when presented with a very large packet. The presence of an extremely large packet in the stream could indicate a potential memory exhaustion attack or stream corruption. Decoders should reject a packet that is too large to process, and print a warning message.&lt;br /&gt;
&lt;br /&gt;
In an Ogg Opus stream, the largest possible valid packet that does not use padding has a size of (61,298*N - 2) bytes, or about 60 kB per Opus stream. With 255 streams, this is 15,630,988 bytes (14.9 MB) and can span up to 61,298 Ogg pages, all but one of which will have a granulepos of -1. This is of course a very extreme packet, consisting of 255 streams, each containing 120 ms of audio encoded as 2.5 ms frames, each frame using the maximum possible number of bytes (1275) and stored in the least efficient manner allowed (a VBR code 3 Opus packet). Even in such a packet, most of the data will be zeros, as 2.5 ms frames, which are required to run in the MDCT mode, cannot actually use all 1275 bytes. The largest packet consisting entirely of useful data is (15,326*N - 2) bytes, or about 15 kB per stream. This corresponds to 120 ms of audio encoded as 10 ms frames in either LP or Hybrid mode, but at a data rate of over 1 Mbps, which makes little sense for the quality achieved. A more reasonable limit is (7,664*N - 2) bytes, or about 7.5 kB per stream. This corresponds to 120 ms of audio encoded as 20 ms stereo MDCT-mode frames, with a total bitrate just under 511 kbps (not counting the Ogg encapsulation overhead). With N=8, the maximum useful number of streams for the channel meanings currently defined by mapping family 1, this gives a maximum packet size of 61,310 bytes, or just under 60 kB. This is still quite conservative, as it assumes each output channel is taken from one decoded channel of a stereo packet. An implementation could reasonably choose any of these numbers for its internal limits.&lt;br /&gt;
&lt;br /&gt;
== Test Vectors ==&lt;br /&gt;
&lt;br /&gt;
* [[OggOpus/testvectors|Planned test vectors for OggOpus]]&lt;br /&gt;
* Opus test vectors&lt;br /&gt;
&lt;br /&gt;
[[Category:Ogg]]&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusTodo&amp;diff=16158</id>
		<title>OpusTodo</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusTodo&amp;diff=16158"/>
		<updated>2015-11-26T02:59:34Z</updated>

		<summary type="html">&lt;p&gt;MarkH: update to reflect 1.1.1 release&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== For 1.1.2 ==&lt;br /&gt;
* aarch64 and AVX optimizations&lt;br /&gt;
&lt;br /&gt;
== For 1.2 ==&lt;br /&gt;
* Quality improvements&lt;br /&gt;
&lt;br /&gt;
== Spec ==&lt;br /&gt;
* Ogg mapping. See [[https://tools.ietf.org/html/draft-ietf-codec-oggopus IETF draft]]&lt;br /&gt;
* Matroska mapping. See: [[MatroskaOpus]] And firefox/ffmpeg implementation&lt;br /&gt;
* RTP payload format. Mono/stereo mapping is complete [[https://tools.ietf.org/html/rfc7587 RFC 7587]], no multichannel mapping yet.&lt;br /&gt;
&lt;br /&gt;
== Website ==&lt;br /&gt;
* De-uglify webpage - some suggestions:&lt;br /&gt;
** write about codecs obsoleted by OPUS (Speex, CELT, Vorbis(?), and the prop. ones)&lt;br /&gt;
** write about implementations (libopus encoder/decoder, libavcodec decoder, any others?)&lt;br /&gt;
** comparison table (Opus, Vorbis, Speex, ..., MP5) of features (channels, freq, bits per sample, license, language (C89), integer impl. (Vorbis decoder only, Opus YES, ...)&lt;br /&gt;
** future use in video files (Theora? Dirac? WebM? other future codecs...)&lt;br /&gt;
** audio files for storage (like Vorbis, no raw Opus defined, only inside OGG), ... &lt;br /&gt;
* Promotional material (some nice free/public-domain sounds/radio stations in Opus format)&lt;br /&gt;
&lt;br /&gt;
== Other ==&lt;br /&gt;
&lt;br /&gt;
* Oggz-validate (should also validate opus toc)&lt;br /&gt;
&lt;br /&gt;
== Opus-tools ==&lt;br /&gt;
* Port opusdec to libopusfile/libopusurl.&lt;br /&gt;
* A simple real time streaming example tool&lt;br /&gt;
** Start with opusrtp.c in [https://git.xiph.org/?p=opus-tools.git opus-tools]&lt;br /&gt;
** Make &amp;lt;code&amp;gt;opusrtp rtp://example.com:5431/&amp;lt;/code&amp;gt; listen to that host and port and mux packets from there. Generalize the cpac bases --sniff implementation&lt;br /&gt;
** Make sending similarly generic. Maybe just &amp;lt;code&amp;gt;opusrtp source.opus -o rtp://example.com:5431/&amp;lt;/code&amp;gt; to send source.opus out to the destination?&lt;br /&gt;
** Make --sniff save one file per&lt;br /&gt;
** Implement DTLS-SRTP. See webrtc.&lt;br /&gt;
** audio capture/encode, decode/playback?&lt;br /&gt;
** Parse and act on sdp for convenience and testing.&lt;br /&gt;
&lt;br /&gt;
* EBU R128/Replaygain (half done— needs a gain tool)&lt;br /&gt;
&lt;br /&gt;
== Surround work ==&lt;br /&gt;
&lt;br /&gt;
* Apply spreading to energy masking&lt;br /&gt;
* More conservative energy masking (not just mean difference) and dynalloc&lt;br /&gt;
* Allow SILK/hybrid on center channel for voice?&lt;br /&gt;
&lt;br /&gt;
== Psychoacoustic stuff ==&lt;br /&gt;
&lt;br /&gt;
* Adaptive width narrowing and forced intensity stereo bands&lt;br /&gt;
&lt;br /&gt;
== Optimisations ==&lt;br /&gt;
&lt;br /&gt;
* Vectorising comb_filter()&lt;br /&gt;
* Use 16-bit mul plus shift in denormalise_bands()&lt;br /&gt;
* Optimise MDCT somehow&lt;br /&gt;
&lt;br /&gt;
== Third-Party tool enhancements ==&lt;br /&gt;
* mutagen: [https://bitbucket.org/lazka/mutagen/issue/202/oggopus-support-in-place-rewrites-for support padding in comments header], [https://bitbucket.org/lazka/mutagen/issue/203/oggopus-allow-updating-the-output_gain allow updating output gain in ID header]&lt;br /&gt;
&lt;br /&gt;
== Future work ==&lt;br /&gt;
* psymodel based VBR&lt;br /&gt;
* Remove copy in inverse MDCT&lt;br /&gt;
* Save some float&amp;lt;-&amp;gt;int conversions&lt;br /&gt;
* Improvements to LP mode CBR (greg has some code)&lt;br /&gt;
* Unconstrained SILK VBR&lt;br /&gt;
* Better handling for the case where FEC has a different bandwidth than the current mode&lt;br /&gt;
* PLC transitions on unprotected SILK-SILK bandwidth changes?&lt;br /&gt;
* Figure out how to use speech/music detection optimally&lt;br /&gt;
** find optimal switching time (low energy/tonality)&lt;br /&gt;
* Improve variable frame size&lt;br /&gt;
&lt;br /&gt;
[[Category:Opus]]&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=XiphInfra:List_of_services&amp;diff=16051</id>
		<title>XiphInfra:List of services</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=XiphInfra:List_of_services&amp;diff=16051"/>
		<updated>2015-10-14T19:12:04Z</updated>

		<summary type="html">&lt;p&gt;MarkH: &lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Service&lt;br /&gt;
! URL&lt;br /&gt;
! VM&lt;br /&gt;
! Host&lt;br /&gt;
! Maintainer&lt;br /&gt;
|-&lt;br /&gt;
| [[XiphWiki:Features|Wiki]]&lt;br /&gt;
| wiki.xiph.org&lt;br /&gt;
| wiki&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| ePirat&lt;br /&gt;
|-&lt;br /&gt;
| Rietveld&lt;br /&gt;
| review.xiph.org&lt;br /&gt;
| jenkins&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| unlord&lt;br /&gt;
|-&lt;br /&gt;
| Git&lt;br /&gt;
| git.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| rillian&lt;br /&gt;
|-&lt;br /&gt;
| Subversion&lt;br /&gt;
| svn.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| rillian&lt;br /&gt;
|-&lt;br /&gt;
| [[AreWeCompressedYet]]&lt;br /&gt;
| arewecompressedyet.com&lt;br /&gt;
| awcy&lt;br /&gt;
| catfish.xiph.org&lt;br /&gt;
| TD-Linux&lt;br /&gt;
|-&lt;br /&gt;
| Opus boodler streams&lt;br /&gt;
| opus-codec.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| gmaxwell&lt;br /&gt;
|-&lt;br /&gt;
| Home pages&lt;br /&gt;
| people.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Media&lt;br /&gt;
| media.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| media.xiph.org&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Mail&lt;br /&gt;
| xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Trac&lt;br /&gt;
| trac.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| tbr&lt;br /&gt;
|-&lt;br /&gt;
| Jenkins&lt;br /&gt;
| jenkins.xiph.org&lt;br /&gt;
| jenkins&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| TD-Linux&lt;br /&gt;
|-&lt;br /&gt;
| XiphBot-ng&lt;br /&gt;
| XiphWiki on freenode&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| TD-Linux&lt;br /&gt;
|-&lt;br /&gt;
| Xiph-mirror&lt;br /&gt;
| github.com/xiph&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| rillian&lt;br /&gt;
|-&lt;br /&gt;
| Icecast directory&lt;br /&gt;
| dir.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| dir.xiph.org&lt;br /&gt;
| tbr&lt;br /&gt;
|-&lt;br /&gt;
| Icecast directory beta&lt;br /&gt;
| dir-test.xiph.org&lt;br /&gt;
| ?&lt;br /&gt;
| mailfish.xiph.org&lt;br /&gt;
| ePirat, tbr&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=XiphInfra:List_of_services&amp;diff=16047</id>
		<title>XiphInfra:List of services</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=XiphInfra:List_of_services&amp;diff=16047"/>
		<updated>2015-10-14T18:36:47Z</updated>

		<summary type="html">&lt;p&gt;MarkH: add xiph-mirror, icecast directory&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;{| class=&amp;quot;wikitable&amp;quot;&lt;br /&gt;
|-&lt;br /&gt;
! Service&lt;br /&gt;
! URL&lt;br /&gt;
! VM&lt;br /&gt;
! Host&lt;br /&gt;
! Maintainer&lt;br /&gt;
|-&lt;br /&gt;
| Wiki&lt;br /&gt;
| wiki.xiph.org&lt;br /&gt;
| wiki&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| ePirat&lt;br /&gt;
|-&lt;br /&gt;
| Rietveld&lt;br /&gt;
| review.xiph.org&lt;br /&gt;
| jenkins&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| unlord&lt;br /&gt;
|-&lt;br /&gt;
| Git&lt;br /&gt;
| git.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| rillian&lt;br /&gt;
|-&lt;br /&gt;
| Subversion&lt;br /&gt;
| svn.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| rillian&lt;br /&gt;
|-&lt;br /&gt;
| [[AreWeCompressedYet]]&lt;br /&gt;
| arewecompressedyet.com&lt;br /&gt;
| awcy&lt;br /&gt;
| catfish.xiph.org&lt;br /&gt;
| TD-Linux&lt;br /&gt;
|-&lt;br /&gt;
| Opus boodler streams&lt;br /&gt;
| opus-codec.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| gmaxwell&lt;br /&gt;
|-&lt;br /&gt;
| Home pages&lt;br /&gt;
| people.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Media&lt;br /&gt;
| media.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| media.xiph.org&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Mail&lt;br /&gt;
| xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Trac&lt;br /&gt;
| trac.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
|&lt;br /&gt;
|-&lt;br /&gt;
| Jenkins&lt;br /&gt;
| jenkins.xiph.org&lt;br /&gt;
| jenkins&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| TD-Linux&lt;br /&gt;
|-&lt;br /&gt;
| XiphBot-ng&lt;br /&gt;
| XiphWiki on freenode&lt;br /&gt;
| -&lt;br /&gt;
| mf4.xiph.org&lt;br /&gt;
| TD-Linux&lt;br /&gt;
|-&lt;br /&gt;
| Xiph-mirror&lt;br /&gt;
| github.com/xiph&lt;br /&gt;
| ?&lt;br /&gt;
| ?&lt;br /&gt;
| rillian&lt;br /&gt;
|-&lt;br /&gt;
| Icecast directory&lt;br /&gt;
| dir.xiph.org&lt;br /&gt;
| -&lt;br /&gt;
| dir.xiph.org&lt;br /&gt;
|&lt;br /&gt;
|}&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=15302</id>
		<title>OpusFAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=15302"/>
		<updated>2015-01-15T19:28:11Z</updated>

		<summary type="html">&lt;p&gt;MarkH: /* Does Opus support higher sampling rates, such as 96 kHz or 192 kHz? */ revert: this is a single 2-sentence item&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Opus logo trans.png|right]]&lt;br /&gt;
&lt;br /&gt;
== General Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What is Opus? Who created it? ===&lt;br /&gt;
&lt;br /&gt;
Opus is a totally open, royalty-free, highly versatile audio codec.&lt;br /&gt;
&lt;br /&gt;
It is primarily designed for interactive speech and music transmission over the Internet, but is also applicable to storage and streaming applications. It incorporates technology from Skype&#039;s SILK codec and Xiph.Org&#039;s CELT codec. It has been standardized by the Internet Engineering Task Force (IETF) as &#039;&#039;&#039;[http://tools.ietf.org/html/rfc6716 RFC 6716]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Opus has been in development since early 2007. Programmers associated with Xiph.Org, Skype, and several other organizations have contributed to its development and to the standardization process as part of the IETF&#039;s codec working group.&lt;br /&gt;
&lt;br /&gt;
=== How does Opus compare to other codecs? ===&lt;br /&gt;
&lt;br /&gt;
Opus is distinguished from most formats for high quality audio (AAC, Vorbis, MP3) by having low delay and it is distinguished from most low delay formats (G.711, GSM, Speex) by supporting high audio quality. It meets or exceeds existing codecs&#039; quality across a wide range of bitrates, and it operates at lower delay than virtually any existing compressed format.&lt;br /&gt;
&lt;br /&gt;
Further, the Opus format itself and the reference implementation are available under liberal royalty-free licenses, making it easy to adopt, compatible with free software, and suitable for usage as part of the basic infrastructure of the Internet.&lt;br /&gt;
&lt;br /&gt;
See the Opus [http://opus-codec.org/comparison comparison page] for more details.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus make all those other lossy codecs obsolete? ===&lt;br /&gt;
&lt;br /&gt;
Theoretically, yes.&lt;br /&gt;
&lt;br /&gt;
From a technical point of view (loss, delay, bitrates, ...) it should replace both [[Vorbis]] and [[Speex]], and the common proprietary codecs too.&lt;br /&gt;
&lt;br /&gt;
=== Will Opus replace Vorbis in video files? ===&lt;br /&gt;
&lt;br /&gt;
For OGG [[Theora]] video files, it can, just the overall size reduction will be minimal and it will break compatibility with existing players.&lt;br /&gt;
&lt;br /&gt;
For WebM video files, the convention is to use the VP9 video codec when using Opus as an audio codec.&lt;br /&gt;
&lt;br /&gt;
=== How do I use Opus? What programs support Opus? ===&lt;br /&gt;
&lt;br /&gt;
Opus decoding support is now included in many applications, including Firefox, foobar2000, and VLC, as well as in frameworks such as GStreamer and FFmpeg.&lt;br /&gt;
&lt;br /&gt;
For now, the best way to &#039;&#039;&#039;encode&#039;&#039;&#039; Opus files is to use the opusenc command-line tool from the opus-tools package.&lt;br /&gt;
&lt;br /&gt;
For real-time applications, Opus support is available in Google&#039;s WebRTC codebase.&lt;br /&gt;
&lt;br /&gt;
Opus is still a relatively new codec: many more applications will support it in the near future.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus support higher sampling rates, such as 96 kHz or 192 kHz? ===&lt;br /&gt;
&lt;br /&gt;
Yes and no.&lt;br /&gt;
&lt;br /&gt;
Opus encoding tools like opusenc will happily encode files that are sampled at 96 or 192 kHz.&lt;br /&gt;
&lt;br /&gt;
However, input files at these rates are internally &#039;&#039;&#039;converted to 48 kHz&#039;&#039;&#039; and then only frequencies &#039;&#039;&#039;up to 20 kHz&#039;&#039;&#039; are encoded.&lt;br /&gt;
&lt;br /&gt;
The reason is simple: lossy codecs are designed to preserve audible details while discarding irrelevant information. Since the human ear can only hear up to 20 kHz at best (usually lower than that), frequency content above 20 kHz is the first thing to go.&lt;br /&gt;
&lt;br /&gt;
See Monty&#039;s [http://people.xiph.org/~xiphmont/demo/neil-young.html 24/192 Music Downloads ...and why they make no sense] for more details.&lt;br /&gt;
&lt;br /&gt;
=== What are the licensing requirements? ===&lt;br /&gt;
&lt;br /&gt;
The reference Opus source code is released under a three-clause BSD license, which is a very permissive Open Source license. Commercial use and distribution (including in proprietary software) is permitted, provided that some basic conditions specified in the license are met. &lt;br /&gt;
&lt;br /&gt;
Opus is also covered by some patents, for which royalty-free usage rights are granted, under conditions that the authors believe are compatible with (hopefully) all open source licenses, including the GPL (v2 and v3).&lt;br /&gt;
&lt;br /&gt;
See the [http://www.opus-codec.org/license/ licensing page] for details.&lt;br /&gt;
&lt;br /&gt;
=== Why make Opus free? ===&lt;br /&gt;
&lt;br /&gt;
On the Internet, protocol and codec standards are part of the common infrastructure everyone builds upon.&lt;br /&gt;
&lt;br /&gt;
Most of the value of a high-quality standard is the innovation and inter-operation provided by the systems built on top of it. When a few parties have monopoly rights to monetize a standard, that infrastructure stops being so common and everyone else has more reason to use their own solution instead, increasing cost and reducing efficiency.&lt;br /&gt;
&lt;br /&gt;
Imagine a road system where each type of car could only drive on its own manufacturer&#039;s pavement. We all benefit from living in a world where all the roads are connected.&lt;br /&gt;
&lt;br /&gt;
This is why Opus, unlike many codecs, is free.&lt;br /&gt;
&lt;br /&gt;
=== Is the SILK part of Opus compatible with the SILK implementation shipped in Skype? ===&lt;br /&gt;
&lt;br /&gt;
No.&lt;br /&gt;
&lt;br /&gt;
The SILK codec, as submitted by Skype to the IETF, was heavily modified as part of its integration within Opus. The modifications are significant enough that it is not possible to just write a &amp;quot;translator&amp;quot;. Even sharing code between Opus and the &amp;quot;old SILK&amp;quot; would be highly complex.&lt;br /&gt;
&lt;br /&gt;
=== Why not keep the SILK and CELT codecs separate? ===&lt;br /&gt;
&lt;br /&gt;
Opus is more than just two independent codecs with a switch.&lt;br /&gt;
&lt;br /&gt;
In addition to a linear prediction &amp;quot;SILK mode&amp;quot; and a MDCT &amp;quot;CELT mode&amp;quot; it has a &amp;quot;hybrid mode,&amp;quot; where speech frequencies up to 8 kHz are encoded with LP while those above 8 kHz are encoded with MDCT. This is what allows Opus to have such high speech quality around 32 kb/s.&lt;br /&gt;
&lt;br /&gt;
Another advantage of the integration is the ability to switch between these modes seamlessly, without any &amp;quot;glitch&amp;quot; and without any out-of-band signalling.&lt;br /&gt;
&lt;br /&gt;
=== Now that Opus is standardized, will its development stop, or can it be further improved? ===&lt;br /&gt;
&lt;br /&gt;
Unlike most ITU-T codecs, Opus is only defined in terms of its decoder.&lt;br /&gt;
&lt;br /&gt;
The encoder can keep evolving as long as the bitstream it produces can be decoded by the reference decoder. This is what made it possible for MP3 encoders to improve far beyond the original l3enc and the dist10 reference implementation.&lt;br /&gt;
&lt;br /&gt;
Although it is unlikely that Opus encoders will see such spectacular evolution, we certainly hope that future encoders will become much better than the reference encoder. In fact, the 1.1 libopus release significantly improves on the reference encoder&#039;s quality.&lt;br /&gt;
&lt;br /&gt;
=== Will all future Opus releases comply with the [http://tools.ietf.org/html/rfc6716 Opus specification]? ===&lt;br /&gt;
&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
=== In what ways is Opus optimized for the Internet? ===&lt;br /&gt;
&lt;br /&gt;
Opus has good packet loss robustness and concealment, but its optimisations go further.&lt;br /&gt;
&lt;br /&gt;
One of the first things we&#039;ve been asked when designing Opus was to make the rate &#039;&#039;&#039;really&#039;&#039;&#039; adaptable because we never know what kind of rates will be available. This not only meant having a wide range of bitrates, but also being able to vary in small increments.&lt;br /&gt;
&lt;br /&gt;
This is why Opus scales from about &#039;&#039;&#039;6 kb/s&#039;&#039;&#039; to &#039;&#039;&#039;512 kb/s&#039;&#039;&#039;, in increments of 0.4 kb/s (one byte with 20 ms frames). The reason Opus can have more than 1200 possible bitrates while spending 11 bits signalling the bitrate is because UDP already encodes the packet size.&lt;br /&gt;
&lt;br /&gt;
One last aspect is that Opus is simple to transport over RTP, as can be seen from [http://tools.ietf.org/html/draft-spittka-payload-rtp-opus Opus RTP payload format]. For example, it&#039;s possible to decode RTP packets without having even seen the SDP or any out-of-band signalling.&lt;br /&gt;
&lt;br /&gt;
=== What applications for Android can play Opus? ===&lt;br /&gt;
&lt;br /&gt;
Right now, there are just a few but that list is fast growing. Please reference [http://android.stackexchange.com/q/37970/7425 this question on android.stackexchange.com]. Feel free to suggest other applications.&lt;br /&gt;
&lt;br /&gt;
=== When will the next version be released? ===&lt;br /&gt;
&lt;br /&gt;
When it&#039;s done. Seriously, we do not know.&lt;br /&gt;
&lt;br /&gt;
Opus is not a large project with a fixed release schedule.&lt;br /&gt;
&lt;br /&gt;
That being said, our [http://www.opus-codec.org/downloads/ pre-releases] and even the [https://git.xiph.org/?p=opus.git git repository] are generally pretty stable and given proper testing (which you should always do anyway), are safe to distribute.&lt;br /&gt;
&lt;br /&gt;
Just be aware that the API of new features (that have never been included in a stable release) could potentially still change.&lt;br /&gt;
&lt;br /&gt;
== Software Developers&#039; Questions ==&lt;br /&gt;
&lt;br /&gt;
=== On what platforms does Opus run? ===&lt;br /&gt;
&lt;br /&gt;
The Opus code base is written in C89 and should run on the vast majority of recent (and not so recent) CPUs.&lt;br /&gt;
&lt;br /&gt;
A few of the platforms on which Opus has been tested and is known to run include x86, x86-64, ARM, Itanium, Blackfin, and SPARC.&lt;br /&gt;
&lt;br /&gt;
=== Is there a fixed-point implementation? ===&lt;br /&gt;
&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
The fixed-point and floating-point decoder and encoder implementations are part of the same code base. The code defaults to float, so you need to configure with &#039;&#039;&#039;--enable-fixed-point&#039;&#039;&#039; (or defining FIXED_POINT if not using the configure script) to build the code for fixed-point.&lt;br /&gt;
&lt;br /&gt;
=== Which implementation should I use? ===&lt;br /&gt;
&lt;br /&gt;
While the implementation in RFC 6716 is what &#039;&#039;defines&#039;&#039; the standard, it is likely not the best and most up-to-date implementation.&lt;br /&gt;
&lt;br /&gt;
The [http://opus-codec.org/ Opus] website was set up for the purpose of continually improving the implementation — in terms of speed, encoding quality, device compatibility, etc — while still conforming to the standard.&lt;br /&gt;
&lt;br /&gt;
All Opus implementations are compatible by definition.&lt;br /&gt;
&lt;br /&gt;
=== How is supporting Opus different from supporting Speex/G.711/MP3? ===&lt;br /&gt;
&lt;br /&gt;
Opus has variable frame durations which can change on the fly, so an Opus decoder needs to be ready to accept packets with durations that are &#039;&#039;&#039;any multiple of 2.5ms&#039;&#039;&#039; up to a &#039;&#039;&#039;maximum of 120ms&#039;&#039;&#039;.  &lt;br /&gt;
&lt;br /&gt;
The opus encoder and decoder do not need to have matched sampling rates or channel counts.  It is recommended to always just decode at the highest rate the hardware supports (e.g. 48kHz stereo) so the user gets the full quality of whatever the far end is sending.&lt;br /&gt;
&lt;br /&gt;
=== My application doesn&#039;t work. Can anyone help me? ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to get help, but before doing so, there are a few basic things to try:&lt;br /&gt;
&lt;br /&gt;
* Implement the application with uncompressed audio instead of Opus. If it still doesn&#039;t work, then the problem isn&#039;t related to Opus.&lt;br /&gt;
* Read the [http://www.opus-codec.org/docs/ documentation].&lt;br /&gt;
* Read the [https://git.xiph.org/?p=opus.git;a=blob;f=src/opus_demo.c opus_demo.c] source code to see how to use the encoder and decoder.&lt;br /&gt;
&lt;br /&gt;
If you still can&#039;t solve the problem, the best option is to ask for help on the [http://lists.xiph.org/mailman/listinfo/opus mailing list].&lt;br /&gt;
&lt;br /&gt;
=== How do I report a bug? ===&lt;br /&gt;
&lt;br /&gt;
If you think you have found a bug in Opus (and not in your application), please [https://trac.xiph.org/newticket?component=Opus file a bug report].&lt;br /&gt;
&lt;br /&gt;
Please include a way for us to reproduce the problem. The best way to do this is to provide an input file, along with the opusenc/opusdec/opus_demo command line that causes the bug to occur.&lt;br /&gt;
&lt;br /&gt;
If the bug cannot be triggered by the command line tools, please provide a simple patch or C file that can help reproduce it. Please also provide any other relevant information, such as OS, CPU, build options, etc.&lt;br /&gt;
&lt;br /&gt;
Don&#039;t hesitate to also contact us on the [http://lists.xiph.org/mailman/listinfo/opus mailing list] or on [irc://irc.freenode.net/opus IRC].&lt;br /&gt;
&lt;br /&gt;
=== What is Opus Custom? ===&lt;br /&gt;
&lt;br /&gt;
Opus Custom is an &#039;&#039;&#039;optional&#039;&#039;&#039; part of the Opus standard that allows for sampling rates other than 8, 12, 16, 24, or 48 kHz and frame sizes other than multiples of 2.5 ms.&lt;br /&gt;
&lt;br /&gt;
Opus Custom requires additional out-of-band signalling that Opus does not normally require and disables many of Opus&#039; coding modes. Also, because it is an optional part of the specification, using Opus Custom may lead to compatibility problems.&lt;br /&gt;
&lt;br /&gt;
For these reasons, its use is discouraged outside of very specific applications, for example:&lt;br /&gt;
* ultra low delay applications where synchronization with the soundcard buffer is important. &lt;br /&gt;
* low-power embedded applications where compatibility with others is not important.&lt;br /&gt;
&lt;br /&gt;
For almost all other types of applications, Opus Custom should not be used.&lt;br /&gt;
&lt;br /&gt;
=== How do I use 44.1 kHz or some other sampling rate not directly supported by Opus? ===&lt;br /&gt;
&lt;br /&gt;
Tools which read or write Opus should inter-operate with other sampling rates by transparently performing sample rate conversion behind the scenes whenever necessary. In particular, software developers should not use Opus Custom for 44.1 kHz support, except in the very specific circumstances outlined above.&lt;br /&gt;
&lt;br /&gt;
Note that it&#039;s generally preferable for a decoder to output at 48kHz even when you know the original input was 44.1kHz, not only because you can skip resampling but also because many inexpensive audio interfaces have poor quality output for 44.1k.&lt;br /&gt;
&lt;br /&gt;
The opus-tools package source code contains a small, high quality, high performance, BSD licensed resampler which can be used where resampling is required.&lt;br /&gt;
&lt;br /&gt;
=== How is the bitrate setting used in VBR mode? ===&lt;br /&gt;
&lt;br /&gt;
Variable bitrate (VBR) mode allows the bitrate to automatically vary over time based on the audio being encoded, in order to achieve a consistent quality.&lt;br /&gt;
&lt;br /&gt;
The bitrate setting controls the desired quality, on a scale that is calibrated to closely approximate the average bitrate that would be obtained over a large and diverse collection of audio.  The actual bitrate of any particular audio stream may be higher or lower than this average.&lt;br /&gt;
&lt;br /&gt;
=== What frame size should I use? ===&lt;br /&gt;
&lt;br /&gt;
A &#039;&#039;&#039;20ms&#039;&#039;&#039; frame size works well for most applications.&lt;br /&gt;
&lt;br /&gt;
Smaller frame sizes may be used to achieve lower latency, but have lower quality at a given bitrate.&lt;br /&gt;
&lt;br /&gt;
Sizes greater than 20 ms increase latency and are generally beneficial only at fairly low bitrates, or when used to reduce external overhead (e.g. by reducing the number of packets that are sent).&lt;br /&gt;
&lt;br /&gt;
=== Forward Error correction (FEC) doesn&#039;t appear to do anything! HELP! ===&lt;br /&gt;
&lt;br /&gt;
The in-band FEC feature of Opus helps reduce the harm of packet loss by encoding some information about the prior packet.&lt;br /&gt;
&lt;br /&gt;
In order to make use of in-band FEC the decoder must delay its output by at least one frame so that it can call the decoder with the decode_fec argument on the &#039;&#039;next&#039;&#039; frame in order to reconstruct the missed frame. This works best if it&#039;s integrated with a jitter buffer.&lt;br /&gt;
&lt;br /&gt;
FEC is only used by the encoder under certain conditions:&lt;br /&gt;
* the feature must be enabled via the OPUS_SET_INBAND_FEC CTL&lt;br /&gt;
* the encoder must be told to expect loss via the OPUS_SET_PACKET_LOSS_PERC CTL&lt;br /&gt;
* the codec must be operated in any of the linear prediction or Hybrid modes&lt;br /&gt;
&lt;br /&gt;
Frame durations shorter than 10ms and very high bitrates will use the MDCT modes, where FEC is not available.&lt;br /&gt;
&lt;br /&gt;
Even when FEC is not used, telling the encoder about the expected level of loss will help it make more intelligent decisions. By default the implementation assumes there is no loss.&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t use malloc or much stack on my embedded platform. How do I make Opus work? ===&lt;br /&gt;
&lt;br /&gt;
A normal build of libopus only uses malloc/free in the _create() and _destroy() calls, so Opus is safe for realtime use so long as the codec state is pre-created.&lt;br /&gt;
&lt;br /&gt;
In order to build Opus without any reference to malloc/free at all use init() calls rather than the create() calls in your application and compile with &amp;lt;tt&amp;gt;CFLAGS=&amp;quot;-DOVERRIDE_OPUS_ALLOC -DOVERRIDE_OPUS_FREE  -D&#039;opus_alloc(x)=NULL&#039; -D&#039;opus_free(x)=NULL&#039; &amp;quot;&amp;lt;/tt&amp;gt; you will get a build which does not use malloc/free.&lt;br /&gt;
&lt;br /&gt;
If libopus is built with -DNONTHREADSAFE_PSEUDOSTACK (instead of VAR_ARRAYS, or USE_ALLOCA) it will use a user provided block of heap instead of stack for many things resulting in much lower the stack usage. However this makes the resulting library non-threadsafe and is not recommend on anything except limited embedded platforms.&lt;br /&gt;
&lt;br /&gt;
=== How can I ensure that my software interoperates with other software implementing Opus? ===&lt;br /&gt;
&lt;br /&gt;
For applications using Ogg files, there are some [http://people.xiph.org/~greg/opus_testvectors/ Ogg Opus testvectors] to test decoders and you can test encoders with opusdec. For RTP applications, the opusrtp tool can be useful.&lt;br /&gt;
&lt;br /&gt;
In general, here&#039;s a list of specific issues to check:&lt;br /&gt;
* Can your application handle all frame sizes, including changing the frame size from frame to frame?&lt;br /&gt;
* Does your application properly react to lost packet by calling the decoder with a NULL packet?&lt;br /&gt;
&lt;br /&gt;
=== What is the complexity of Opus? ===&lt;br /&gt;
&lt;br /&gt;
The complexity of Opus varies by a large amount based on the settings used.&lt;br /&gt;
&lt;br /&gt;
It depends on the mode, audio bandwidth, number of channels, and even a &amp;quot;complexity knob&amp;quot; that can trade complexity for quality. It will run easily on any recent PC or smartphone. &lt;br /&gt;
&lt;br /&gt;
For slower embedded CPUs/DSPs, the amount of CPU required will vary depending on the configuration and the exact CPU, so you will need to experiment. Do not expect Opus to run quickly on really slow devices like 8-bit micro-controllers.&lt;br /&gt;
&lt;br /&gt;
=== Opus is using too much CPU for my application. What can I do? ===&lt;br /&gt;
&lt;br /&gt;
First don&#039;t panic and don&#039;t start writing assembly just yet.&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible that you&#039;re just not using the right set of options.&lt;br /&gt;
&lt;br /&gt;
If you&#039;re targeting an embedded/mobile platform, chances are the fixed-point build will be faster, so make sure you&#039;re using &#039;&#039;&#039;--enable-fixed-point&#039;&#039;&#039; or defining FIXED_POINT in the build system.&lt;br /&gt;
&lt;br /&gt;
Opus also has a complexity option that can trade quality for complexity. The default is highest quality and highest complexity. You can control this using OPUS_SET_COMPLEXITY() (see doc for details). If all else fails and you need to optimize the Opus code, see the next question.&lt;br /&gt;
&lt;br /&gt;
=== I would like to optimize Opus. Where should I start? ===&lt;br /&gt;
&lt;br /&gt;
Please &#039;&#039;&#039;[http://www.opus-codec.org/contact/ contact us]&#039;&#039;&#039; before you start, or at least before you get too far.&lt;br /&gt;
&lt;br /&gt;
This will help coordinate the optimization effort and generally reduce the probability of wasting your time on duplicated effort or generally going on the wrong path. &lt;br /&gt;
&lt;br /&gt;
=== Does Opus have an echo canceller like Speex does? ===&lt;br /&gt;
&lt;br /&gt;
Echo cancellation is completely independent from codecs.&lt;br /&gt;
&lt;br /&gt;
You can use any echo canceller (including the one from libspeexdsp) along with Opus.&lt;br /&gt;
&lt;br /&gt;
That being said, among the free acoustic echo cancelers (AEC) we&#039;re aware of, the best is probably the Google AEC from the [https://code.google.com/p/webrtc/ WebRTC codebase].&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=15082</id>
		<title>OpusFAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=15082"/>
		<updated>2014-11-26T20:48:10Z</updated>

		<summary type="html">&lt;p&gt;MarkH: /* How do I use Opus? What programs support Opus? */ Opus now in webrtc&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Opus logo trans.png|right]]&lt;br /&gt;
&lt;br /&gt;
== General Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What is Opus? Who created it? ===&lt;br /&gt;
&lt;br /&gt;
Opus is a totally open, royalty-free, highly versatile audio codec. It is primarily designed for interactive speech and music transmission over the Internet, but is also applicable to storage and streaming applications. It incorporates technology from Skype&#039;s SILK codec and Xiph.Org&#039;s CELT codec. It has been standardized by the Internet Engineering Task Force (IETF) as &#039;&#039;&#039;[http://tools.ietf.org/html/rfc6716 RFC 6716]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Opus has been in development since early 2007. Programmers associated with Xiph.Org, Skype, and several other organizations have contributed to its development and to the standardization process as part of the IETF&#039;s codec working group.&lt;br /&gt;
&lt;br /&gt;
=== How does Opus compare to other codecs? ===&lt;br /&gt;
&lt;br /&gt;
Opus is distinguished from most formats for high quality audio (AAC, Vorbis, MP3) by having low delay and it is distinguished from most low delay formats (G.711, GSM, Speex) by supporting high audio quality. It meets or exceeds existing codecs&#039; quality across a wide range of bitrates, and it operates at lower delay than virtually any existing compressed format. Further, the Opus format itself and the reference implementation are available under liberal royalty-free licenses, making it easy to adopt, compatible with free software, and suitable for usage as part of the basic infrastructure of the Internet. See the Opus [http://opus-codec.org/comparison comparison page] for more details.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus make all those other lossy codecs obsolete? ===&lt;br /&gt;
&lt;br /&gt;
Theoretically, yes. From technical point of view (loss, delay, bitrates, ...) it can replace both Vorbis and Speex, and the common proprietary codecs too.&lt;br /&gt;
&lt;br /&gt;
=== Will Opus replace Vorbis in video files? ===&lt;br /&gt;
&lt;br /&gt;
For OGG Theora video files, it can, just the overall size reduction will be minimal, and it will break compatibility with existing players.&lt;br /&gt;
&lt;br /&gt;
For WebM video files, the convention is to use the VP9 video codec when using Opus as an audio codec.&lt;br /&gt;
&lt;br /&gt;
=== How do I use Opus? What programs support Opus? ===&lt;br /&gt;
&lt;br /&gt;
Opus decoding support is now included in many applications, including Firefox, foobar2000, and VLC, as well as in frameworks such as GStreamer and FFmpeg. For now, the best way to &#039;&#039;&#039;encode&#039;&#039;&#039; Opus files is to use the opusenc command-line tool from the opus-tools package. For real-time applications, Opus support is available in the Google webrtc codebase. Opus is still a new codec, expect many more applications to support it in the near future.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus support higher sampling rates, such as 96 kHz or 192 kHz? ===&lt;br /&gt;
&lt;br /&gt;
Yes and no. Opus encoding tools like opusenc will happily encode files that are sampled at 96 or 192 kHz. However, input files at these rates are internally converted to 48 kHz, and then only frequencies up to 20 kHz are encoded. The reason is simple: lossy codecs are designed to preserve audible details while discarding irrelevant information. Since the human ear can only hear up to 20 kHz at best (usually lower than that), frequency content above 20 kHz is the first thing to go. See Monty&#039;s [http://people.xiph.org/~xiphmont/demo/neil-young.html 24/192 Music Downloads ...and why they make no sense] for more details. &lt;br /&gt;
&lt;br /&gt;
=== What are the licensing requirements? ===&lt;br /&gt;
&lt;br /&gt;
The reference Opus source code is released under a three-clause BSD license, which is a very permissive Open Source license. Commercial use and distribution (including in proprietary software) is permitted, provided that some basic conditions specified in the license are met. &lt;br /&gt;
&lt;br /&gt;
Opus is also covered by some patents, for which royalty-free usage rights are granted, under conditions that the authors believe are compatible with most (all?) open source licenses, including the GPL (v2 and v3). See the [http://www.opus-codec.org/license/ licensing page] for details.&lt;br /&gt;
&lt;br /&gt;
=== Why make Opus free? ===&lt;br /&gt;
&lt;br /&gt;
On the Internet, protocol and codec standards are part of the common infrastructure everyone builds upon. Most of the value of a high quality standard is the innovation and interoperation provided by the systems built on top of it. When a few parties have monopoly rights to monetize a standard, that infrastructure stops being so common—everyone else has more reason to use their own solution instead, increasing cost and reducing efficiency. Imagine a road system where each type of car could only drive on its own manufacturer&#039;s pavement. We all benefit from living in a world where all the roads are connected. This is why Opus, unlike many codecs, is free.&lt;br /&gt;
&lt;br /&gt;
=== Is the SILK part of Opus compatible with the SILK implementation shipped in Skype? ===&lt;br /&gt;
&lt;br /&gt;
No. The SILK codec, as submitted by Skype to the IETF, was heavily modified as part of its integration within Opus. The modifications are significant enough that it is not possible to just write a &amp;quot;translator&amp;quot; and even sharing code between Opus and the &amp;quot;old SILK&amp;quot; would be highly non-trivial.&lt;br /&gt;
&lt;br /&gt;
=== Why not keep the SILK and CELT codecs separate? ===&lt;br /&gt;
&lt;br /&gt;
Opus is more than just two independent codecs with a switch. In addition to a linear prediction &amp;quot;SILK mode&amp;quot; and a MDCT &amp;quot;CELT mode&amp;quot; it has a &amp;quot;hybrid mode,&amp;quot; where speech frequencies up to 8 kHz are encoded with LP while those above 8 kHz are encoded with MDCT. This is what allows Opus to have such high speech quality around 32 kb/s. Another advantage of the integration is the ability to switch between these modes seamlessly, without any &amp;quot;glitch&amp;quot; and without any out-of-band signalling.&lt;br /&gt;
&lt;br /&gt;
=== Now that Opus is standardized, will its development stop, or can it be further improved? ===&lt;br /&gt;
&lt;br /&gt;
Unlike most ITU-T codecs, Opus is only defined in terms of its decoder. The encoder can keep evolving as long as the bitstream it produces can be decoded by the reference decoder. This is what made it possible for MP3 encoders to improve far beyond the original l3enc and the dist10 reference implementation. Although it is unlikely that Opus encoders will see such spectacular evolution, we certainly hope that future encoders will become much better than the reference encoder. In fact, the 1.1 libopus release significantly improves on the reference encoder&#039;s quality.&lt;br /&gt;
&lt;br /&gt;
=== Will all future Opus releases comply with the [http://tools.ietf.org/html/rfc6716 Opus specification]? ===&lt;br /&gt;
&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
=== In what ways is Opus optimized for the Internet? ===&lt;br /&gt;
&lt;br /&gt;
Opus being optimized for the Internet obviously means that it has good packet loss robustness and concealment, but it goes further. One of the first things we&#039;ve been asked when designing Opus was to make the rate &#039;&#039;&#039;really&#039;&#039;&#039; adaptable because we never know what kind of rates will be available. This not only meant having a wide range of bitrates, but also being able to vary in small increments. This is why Opus scales from about 6 kb/s to 512 kb/s, in increments of 0.4 kb/s (one byte with 20 ms frames). The reason Opus can have more than 1200 possible bitrates spending 11 bits signalling the bitrate is because UDP already encodes the packet size. One last aspect is that Opus is simple to transport over RTP, as can be seen from [http://tools.ietf.org/html/draft-spittka-payload-rtp-opus Opus RTP payload format]. For example, it&#039;s possible to decode RTP packets without having even seen the SDP or any out-of-band signalling. &lt;br /&gt;
&lt;br /&gt;
=== What applications for Android can play Opus? ===&lt;br /&gt;
&lt;br /&gt;
Right now, there are just a few but that list is fast growing. Please reference [http://android.stackexchange.com/q/37970/7425 this question on android.stackexchange.com]. Feel free to suggest other applications.&lt;br /&gt;
&lt;br /&gt;
=== When will the next version be released? ===&lt;br /&gt;
&lt;br /&gt;
When it&#039;s done. Seriously. We do not know. Opus is not a large project with a fixed release schedule. That being said, our pre-releases and even the git repository are generally pretty stable and given proper testing (which you should always do anyway), are safe to distribute. Just be aware that the API of new features (that have never been included in a stable release) could potentially still change.&lt;br /&gt;
&lt;br /&gt;
== Opus for Software developers ==&lt;br /&gt;
&lt;br /&gt;
=== On what platforms does Opus run? ===&lt;br /&gt;
&lt;br /&gt;
The Opus code base is written in C89 and should run on the vast majority of recent (and not so recent) CPUs. A few of the platforms on which Opus has been tested and is known to run include x86, x86-64, ARM, Itanium, Blackfin, and SPARC.&lt;br /&gt;
&lt;br /&gt;
=== Is there a fixed-point implementation? ===&lt;br /&gt;
&lt;br /&gt;
Yes; the fixed-point and floating-point decoder and encoder implementations are part of the same code base. The code defaults to float, so you need to configure with --enable-fixed-point (or defining FIXED_POINT if not using the configure script) to build the code for fixed-point.&lt;br /&gt;
&lt;br /&gt;
=== Which implementation should I use? ===&lt;br /&gt;
&lt;br /&gt;
While the implementation in RFC 6716 is what &#039;&#039;defines&#039;&#039; the standard, it is likely not the best and most up-to-date implementation. The [http://opus-codec.org/ Opus] website was set up for the purpose of continually improving the implementation— in terms of speed, encoding quality, device compatibility, etc— while still conforming to the standard. All Opus implementations are compatible by definition.&lt;br /&gt;
&lt;br /&gt;
=== How is supporting Opus different from supporting Speex/G.711/MP3? ===&lt;br /&gt;
&lt;br /&gt;
Opus has variable frame durations which can change on the fly, so an Opus decoder needs to be ready to accept packets with durations that are any multiple of 2.5ms up to a maximum of 120ms.  &lt;br /&gt;
&lt;br /&gt;
The opus encoder and decoder do not need to have matched sampling rates or channel counts.  It is recommended to always just decode at the highest rate the hardware supports (e.g. 48kHz stereo) so the user gets the full quality of whatever the far end is sending.&lt;br /&gt;
&lt;br /&gt;
=== My application doesn&#039;t work. Can anyone help me? ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to get help, but before doing so, there are a few basic things to try:&lt;br /&gt;
&lt;br /&gt;
* Implement the application with uncompressed audio instead of Opus. If it still doesn&#039;t work, then the problem isn&#039;t related to Opus.&lt;br /&gt;
* Read the [http://www.opus-codec.org/docs/ documentation].&lt;br /&gt;
* Read the opus_demo.c source code to see how to use the encoder and decoder.&lt;br /&gt;
&lt;br /&gt;
If you still can&#039;t solve the problem, the best option is to ask for help on the [http://lists.xiph.org/mailman/listinfo/opus mailing list].&lt;br /&gt;
&lt;br /&gt;
=== How do I report a bug? ===&lt;br /&gt;
&lt;br /&gt;
If you think you have found a bug in Opus (and not in your application), please [https://trac.xiph.org/newticket?component=Opus file a bug report]. Please include a way for us to reproduce the problem. The best way to do this is to provide an input file, along with the opusenc/opusdec/opus_demo command line that causes the bug to occur. If the bug cannot be triggered by the command line tools, please provide a simple patch or C file that can help reproduce it. Please also provide any other relevant information, such as OS, CPU, build options, etc. Also, don&#039;t hesitate to also contact us on the [http://lists.xiph.org/mailman/listinfo/opus mailing list] or on [irc://irc.freenode.net/opus IRC].&lt;br /&gt;
&lt;br /&gt;
=== What is Opus Custom? ===&lt;br /&gt;
&lt;br /&gt;
Opus Custom is an &#039;&#039;&#039;optional&#039;&#039;&#039; part of the Opus standard that allows for sampling rates other than 8, 12, 16, 24, or 48 kHz and frame sizes other than multiples of 2.5 ms. Opus Custom requires additional out-of-band signalling that Opus does not normally require and disables many of Opus&#039; coding modes. Also, because it is an optional part of the specification, using Opus Custom may lead to compatibility problems. For these reasons, its use is discouraged outside of very specific applications, e.g.:&lt;br /&gt;
* ultra low delay applications where synchronization with the soundcard buffer is important. &lt;br /&gt;
* low-power embedded applications where compatibility with others is not important.&lt;br /&gt;
&lt;br /&gt;
For almost all other types of applications, Opus Custom should not be used.&lt;br /&gt;
&lt;br /&gt;
=== How do I use 44.1 kHz or some other sampling rate not directly supported by Opus? ===&lt;br /&gt;
&lt;br /&gt;
Tools which read or write Opus should interoperate with other sampling rates by transparently performing sample rate conversion behind the scenes whenever necessary. In particular, software developers should not use Opus Custom for 44.1 kHz support, except in the very specific circumstances outlined above.&lt;br /&gt;
&lt;br /&gt;
Note that it&#039;s generally preferable for a decoder to output at 48kHz even when you know the original input was 44.1kHz, not only because you can skip resampling but also because many inexpensive audio interfaces have poor quality output for 44.1k.&lt;br /&gt;
&lt;br /&gt;
The opus-tools package source code contains a small, high quality, high performance, BSD licensed resampler which can be used where resampling is required.&lt;br /&gt;
&lt;br /&gt;
=== How is the bitrate setting used in VBR mode? ===&lt;br /&gt;
&lt;br /&gt;
Variable bitrate (VBR) mode allows the bitrate to automatically vary over time based on the audio being encoded, in order to achieve a consistent quality.  The bitrate setting controls the desired quality, on a scale that is calibrated to closely approximate the average bitrate that would be obtained over a large and diverse collection of audio.  The actual bitrate of any particular audio stream may be higher or lower than this average.&lt;br /&gt;
&lt;br /&gt;
=== What frame size should I use? ===&lt;br /&gt;
&lt;br /&gt;
A 20 ms frame size works well for most applications.  Smaller frame sizes may be used to achieve lower latency, but have lower quality at a given bitrate.  Sizes greater than 20 ms increase latency and are generally beneficial only at fairly low bitrates, or when used to reduce external overhead (e.g. by reducing the number of packets that are sent).&lt;br /&gt;
&lt;br /&gt;
=== Forward Error correction (FEC) doesn&#039;t appear to do anything! HELP! ===&lt;br /&gt;
&lt;br /&gt;
The inband FEC feature of Opus helps reduce the harm of packet loss by encoding some information about the prior packet.&lt;br /&gt;
&lt;br /&gt;
In order to make use of inband FEC the decoder must delay its output by at least one frame so that it can call the decoder with the decode_fec argument on the &#039;&#039;next&#039;&#039; frame in order to reconstruct the missed frame. This works best if it&#039;s integrated with a jitter buffer.&lt;br /&gt;
&lt;br /&gt;
FEC is only used by the encoder under certain conditions: the feature must be enabled via the OPUS_SET_INBAND_FEC CTL, the encoder must be told to expect loss via the OPUS_SET_PACKET_LOSS_PERC CTL, and the codec must be operated in any of the linear prediction or Hybrid modes. Frame durations of &amp;lt;10ms and very high bitrates will use the MDCT modes, where FEC is not available.&lt;br /&gt;
&lt;br /&gt;
Even when FEC is not used, telling the encoder about the expected level of loss will help it make more intelligent decisions. By default the implementation assumes there is no loss.&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t use malloc or much stack on my embedded platform. How do I make Opus work? ===&lt;br /&gt;
&lt;br /&gt;
A normal build of libopus only uses malloc/free in the _create() and _destroy() calls, so Opus is safe for realtime use so long as the codec state is pre-created.&lt;br /&gt;
&lt;br /&gt;
In order to build Opus without any reference to malloc/free at all use init() calls rather than the create() calls in your application and compile with &amp;lt;tt&amp;gt;CFLAGS=&amp;quot;-DOVERRIDE_OPUS_ALLOC -DOVERRIDE_OPUS_FREE  -D&#039;opus_alloc(x)=NULL&#039; -D&#039;opus_free(x)=NULL&#039; &amp;quot;&amp;lt;/tt&amp;gt; you will get a build which does not use malloc/free.&lt;br /&gt;
&lt;br /&gt;
If libopus is built with -DNONTHREADSAFE_PSEUDOSTACK (instead of VAR_ARRAYS, or USE_ALLOCA) it will use a user provided block of heap instead of stack for many things resulting in much lower the stack usage. However this makes the resulting library non-threadsafe and is not recommend on anything except limited embedded platforms.&lt;br /&gt;
&lt;br /&gt;
=== How can I ensure that my software interoperates with other software implementing Opus? ===&lt;br /&gt;
&lt;br /&gt;
For applications using Ogg files, there are some [http://people.xiph.org/~greg/opus_testvectors/ Ogg Opus testvectors] to test decoders and you can test encoders with opusdec. For RTP applications, the opusrtp tool can be useful. In general, here&#039;s a list of specific issues to check:&lt;br /&gt;
* Can your application handle all frame sizes, including changing the frame size from frame to frame?&lt;br /&gt;
* Does your application properly react to lost packet by calling the decoder with a NULL packet?&lt;br /&gt;
&lt;br /&gt;
=== What is the complexity of Opus? ===&lt;br /&gt;
&lt;br /&gt;
The complexity of Opus varies by a large amount based on the settings used. It depends on the mode, audio bandwidth, number of channels, and even a &amp;quot;complexity knob&amp;quot; that can trade complexity for quality. It will run easily on any recent PC or smartphone. For slower embedded CPUs/DSPs, the amount of CPU required will vary depending on the configuration and the exact CPU, so you will need to experiment. Do not expect Opus to run on really slow devices like 8-bit micro-controllers.&lt;br /&gt;
&lt;br /&gt;
=== Opus is using too much CPU for my application. What can I do? ===&lt;br /&gt;
&lt;br /&gt;
First don&#039;t panic and don&#039;t start writing assembly just yet. It&#039;s possible that you&#039;re just not using the right set of options. If you&#039;re targeting an embedded/mobile platform, chances are the fixed-point build will be faster, so make sure you&#039;re using --enable-fixed-point or defining FIXED_POINT in the build system. Opus also has a complexity option that can trade quality for complexity. The default is highest quality and highest complexity. You can control this using OPUS_SET_COMPLEXITY() (see doc for details). If all else fails and you need to optimize the Opus code, see the next question.&lt;br /&gt;
&lt;br /&gt;
=== I would like to optimize Opus. Where should I start? ===&lt;br /&gt;
&lt;br /&gt;
Please [http://www.opus-codec.org/contact/ contact us] before you start, or at least before you get too far. This will help coordinate the optimization effort and generally reduce the probability of wasting your time on duplicated effort or generally going on the wrong path. &lt;br /&gt;
&lt;br /&gt;
=== Does Opus have an echo canceller like Speex does? ===&lt;br /&gt;
&lt;br /&gt;
Echo cancellation is completely independent from codecs. You can use any echo canceller (including the one from libspeexdsp) along with Opus. That being said, among the free acoustic echo cancelers (AEC) we&#039;re aware of, the best is probably the Google AEC from the [https://code.google.com/p/webrtc/ WebRTC codebase].&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=15081</id>
		<title>OpusFAQ</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OpusFAQ&amp;diff=15081"/>
		<updated>2014-11-26T20:45:55Z</updated>

		<summary type="html">&lt;p&gt;MarkH: /* Opus for Software developers */ add a couple of common questions&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;[[Image:Opus logo trans.png|right]]&lt;br /&gt;
&lt;br /&gt;
== General Questions ==&lt;br /&gt;
&lt;br /&gt;
=== What is Opus? Who created it? ===&lt;br /&gt;
&lt;br /&gt;
Opus is a totally open, royalty-free, highly versatile audio codec. It is primarily designed for interactive speech and music transmission over the Internet, but is also applicable to storage and streaming applications. It incorporates technology from Skype&#039;s SILK codec and Xiph.Org&#039;s CELT codec. It has been standardized by the Internet Engineering Task Force (IETF) as &#039;&#039;&#039;[http://tools.ietf.org/html/rfc6716 RFC 6716]&#039;&#039;&#039;. &lt;br /&gt;
&lt;br /&gt;
Opus has been in development since early 2007. Programmers associated with Xiph.Org, Skype, and several other organizations have contributed to its development and to the standardization process as part of the IETF&#039;s codec working group.&lt;br /&gt;
&lt;br /&gt;
=== How does Opus compare to other codecs? ===&lt;br /&gt;
&lt;br /&gt;
Opus is distinguished from most formats for high quality audio (AAC, Vorbis, MP3) by having low delay and it is distinguished from most low delay formats (G.711, GSM, Speex) by supporting high audio quality. It meets or exceeds existing codecs&#039; quality across a wide range of bitrates, and it operates at lower delay than virtually any existing compressed format. Further, the Opus format itself and the reference implementation are available under liberal royalty-free licenses, making it easy to adopt, compatible with free software, and suitable for usage as part of the basic infrastructure of the Internet. See the Opus [http://opus-codec.org/comparison comparison page] for more details.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus make all those other lossy codecs obsolete? ===&lt;br /&gt;
&lt;br /&gt;
Theoretically, yes. From technical point of view (loss, delay, bitrates, ...) it can replace both Vorbis and Speex, and the common proprietary codecs too.&lt;br /&gt;
&lt;br /&gt;
=== Will Opus replace Vorbis in video files? ===&lt;br /&gt;
&lt;br /&gt;
For OGG Theora video files, it can, just the overall size reduction will be minimal, and it will break compatibility with existing players.&lt;br /&gt;
&lt;br /&gt;
For WebM video files, the convention is to use the VP9 video codec when using Opus as an audio codec.&lt;br /&gt;
&lt;br /&gt;
=== How do I use Opus? What programs support Opus? ===&lt;br /&gt;
&lt;br /&gt;
Opus decoding support is now included in many applications, including Firefox, foobar2000, and VLC, as well as in frameworks such as GStreamer and FFmpeg. For now, the best way to &#039;&#039;&#039;encode&#039;&#039;&#039; Opus files is to use the opusenc command-line tool from the opus-tools package. For real-time applications, Opus support should soon be available in the Google webrtc codebase. Opus is still a new codec, expect many more applications to support it in the near future.&lt;br /&gt;
&lt;br /&gt;
=== Does Opus support higher sampling rates, such as 96 kHz or 192 kHz? ===&lt;br /&gt;
&lt;br /&gt;
Yes and no. Opus encoding tools like opusenc will happily encode files that are sampled at 96 or 192 kHz. However, input files at these rates are internally converted to 48 kHz, and then only frequencies up to 20 kHz are encoded. The reason is simple: lossy codecs are designed to preserve audible details while discarding irrelevant information. Since the human ear can only hear up to 20 kHz at best (usually lower than that), frequency content above 20 kHz is the first thing to go. See Monty&#039;s [http://people.xiph.org/~xiphmont/demo/neil-young.html 24/192 Music Downloads ...and why they make no sense] for more details. &lt;br /&gt;
&lt;br /&gt;
=== What are the licensing requirements? ===&lt;br /&gt;
&lt;br /&gt;
The reference Opus source code is released under a three-clause BSD license, which is a very permissive Open Source license. Commercial use and distribution (including in proprietary software) is permitted, provided that some basic conditions specified in the license are met. &lt;br /&gt;
&lt;br /&gt;
Opus is also covered by some patents, for which royalty-free usage rights are granted, under conditions that the authors believe are compatible with most (all?) open source licenses, including the GPL (v2 and v3). See the [http://www.opus-codec.org/license/ licensing page] for details.&lt;br /&gt;
&lt;br /&gt;
=== Why make Opus free? ===&lt;br /&gt;
&lt;br /&gt;
On the Internet, protocol and codec standards are part of the common infrastructure everyone builds upon. Most of the value of a high quality standard is the innovation and interoperation provided by the systems built on top of it. When a few parties have monopoly rights to monetize a standard, that infrastructure stops being so common—everyone else has more reason to use their own solution instead, increasing cost and reducing efficiency. Imagine a road system where each type of car could only drive on its own manufacturer&#039;s pavement. We all benefit from living in a world where all the roads are connected. This is why Opus, unlike many codecs, is free.&lt;br /&gt;
&lt;br /&gt;
=== Is the SILK part of Opus compatible with the SILK implementation shipped in Skype? ===&lt;br /&gt;
&lt;br /&gt;
No. The SILK codec, as submitted by Skype to the IETF, was heavily modified as part of its integration within Opus. The modifications are significant enough that it is not possible to just write a &amp;quot;translator&amp;quot; and even sharing code between Opus and the &amp;quot;old SILK&amp;quot; would be highly non-trivial.&lt;br /&gt;
&lt;br /&gt;
=== Why not keep the SILK and CELT codecs separate? ===&lt;br /&gt;
&lt;br /&gt;
Opus is more than just two independent codecs with a switch. In addition to a linear prediction &amp;quot;SILK mode&amp;quot; and a MDCT &amp;quot;CELT mode&amp;quot; it has a &amp;quot;hybrid mode,&amp;quot; where speech frequencies up to 8 kHz are encoded with LP while those above 8 kHz are encoded with MDCT. This is what allows Opus to have such high speech quality around 32 kb/s. Another advantage of the integration is the ability to switch between these modes seamlessly, without any &amp;quot;glitch&amp;quot; and without any out-of-band signalling.&lt;br /&gt;
&lt;br /&gt;
=== Now that Opus is standardized, will its development stop, or can it be further improved? ===&lt;br /&gt;
&lt;br /&gt;
Unlike most ITU-T codecs, Opus is only defined in terms of its decoder. The encoder can keep evolving as long as the bitstream it produces can be decoded by the reference decoder. This is what made it possible for MP3 encoders to improve far beyond the original l3enc and the dist10 reference implementation. Although it is unlikely that Opus encoders will see such spectacular evolution, we certainly hope that future encoders will become much better than the reference encoder. In fact, the 1.1 libopus release significantly improves on the reference encoder&#039;s quality.&lt;br /&gt;
&lt;br /&gt;
=== Will all future Opus releases comply with the [http://tools.ietf.org/html/rfc6716 Opus specification]? ===&lt;br /&gt;
&lt;br /&gt;
Yes.&lt;br /&gt;
&lt;br /&gt;
=== In what ways is Opus optimized for the Internet? ===&lt;br /&gt;
&lt;br /&gt;
Opus being optimized for the Internet obviously means that it has good packet loss robustness and concealment, but it goes further. One of the first things we&#039;ve been asked when designing Opus was to make the rate &#039;&#039;&#039;really&#039;&#039;&#039; adaptable because we never know what kind of rates will be available. This not only meant having a wide range of bitrates, but also being able to vary in small increments. This is why Opus scales from about 6 kb/s to 512 kb/s, in increments of 0.4 kb/s (one byte with 20 ms frames). The reason Opus can have more than 1200 possible bitrates spending 11 bits signalling the bitrate is because UDP already encodes the packet size. One last aspect is that Opus is simple to transport over RTP, as can be seen from [http://tools.ietf.org/html/draft-spittka-payload-rtp-opus Opus RTP payload format]. For example, it&#039;s possible to decode RTP packets without having even seen the SDP or any out-of-band signalling. &lt;br /&gt;
&lt;br /&gt;
=== What applications for Android can play Opus? ===&lt;br /&gt;
&lt;br /&gt;
Right now, there are just a few but that list is fast growing. Please reference [http://android.stackexchange.com/q/37970/7425 this question on android.stackexchange.com]. Feel free to suggest other applications.&lt;br /&gt;
&lt;br /&gt;
=== When will the next version be released? ===&lt;br /&gt;
&lt;br /&gt;
When it&#039;s done. Seriously. We do not know. Opus is not a large project with a fixed release schedule. That being said, our pre-releases and even the git repository are generally pretty stable and given proper testing (which you should always do anyway), are safe to distribute. Just be aware that the API of new features (that have never been included in a stable release) could potentially still change.&lt;br /&gt;
&lt;br /&gt;
== Opus for Software developers ==&lt;br /&gt;
&lt;br /&gt;
=== On what platforms does Opus run? ===&lt;br /&gt;
&lt;br /&gt;
The Opus code base is written in C89 and should run on the vast majority of recent (and not so recent) CPUs. A few of the platforms on which Opus has been tested and is known to run include x86, x86-64, ARM, Itanium, Blackfin, and SPARC.&lt;br /&gt;
&lt;br /&gt;
=== Is there a fixed-point implementation? ===&lt;br /&gt;
&lt;br /&gt;
Yes; the fixed-point and floating-point decoder and encoder implementations are part of the same code base. The code defaults to float, so you need to configure with --enable-fixed-point (or defining FIXED_POINT if not using the configure script) to build the code for fixed-point.&lt;br /&gt;
&lt;br /&gt;
=== Which implementation should I use? ===&lt;br /&gt;
&lt;br /&gt;
While the implementation in RFC 6716 is what &#039;&#039;defines&#039;&#039; the standard, it is likely not the best and most up-to-date implementation. The [http://opus-codec.org/ Opus] website was set up for the purpose of continually improving the implementation— in terms of speed, encoding quality, device compatibility, etc— while still conforming to the standard. All Opus implementations are compatible by definition.&lt;br /&gt;
&lt;br /&gt;
=== How is supporting Opus different from supporting Speex/G.711/MP3? ===&lt;br /&gt;
&lt;br /&gt;
Opus has variable frame durations which can change on the fly, so an Opus decoder needs to be ready to accept packets with durations that are any multiple of 2.5ms up to a maximum of 120ms.  &lt;br /&gt;
&lt;br /&gt;
The opus encoder and decoder do not need to have matched sampling rates or channel counts.  It is recommended to always just decode at the highest rate the hardware supports (e.g. 48kHz stereo) so the user gets the full quality of whatever the far end is sending.&lt;br /&gt;
&lt;br /&gt;
=== My application doesn&#039;t work. Can anyone help me? ===&lt;br /&gt;
&lt;br /&gt;
It&#039;s possible to get help, but before doing so, there are a few basic things to try:&lt;br /&gt;
&lt;br /&gt;
* Implement the application with uncompressed audio instead of Opus. If it still doesn&#039;t work, then the problem isn&#039;t related to Opus.&lt;br /&gt;
* Read the [http://www.opus-codec.org/docs/ documentation].&lt;br /&gt;
* Read the opus_demo.c source code to see how to use the encoder and decoder.&lt;br /&gt;
&lt;br /&gt;
If you still can&#039;t solve the problem, the best option is to ask for help on the [http://lists.xiph.org/mailman/listinfo/opus mailing list].&lt;br /&gt;
&lt;br /&gt;
=== How do I report a bug? ===&lt;br /&gt;
&lt;br /&gt;
If you think you have found a bug in Opus (and not in your application), please [https://trac.xiph.org/newticket?component=Opus file a bug report]. Please include a way for us to reproduce the problem. The best way to do this is to provide an input file, along with the opusenc/opusdec/opus_demo command line that causes the bug to occur. If the bug cannot be triggered by the command line tools, please provide a simple patch or C file that can help reproduce it. Please also provide any other relevant information, such as OS, CPU, build options, etc. Also, don&#039;t hesitate to also contact us on the [http://lists.xiph.org/mailman/listinfo/opus mailing list] or on [irc://irc.freenode.net/opus IRC].&lt;br /&gt;
&lt;br /&gt;
=== What is Opus Custom? ===&lt;br /&gt;
&lt;br /&gt;
Opus Custom is an &#039;&#039;&#039;optional&#039;&#039;&#039; part of the Opus standard that allows for sampling rates other than 8, 12, 16, 24, or 48 kHz and frame sizes other than multiples of 2.5 ms. Opus Custom requires additional out-of-band signalling that Opus does not normally require and disables many of Opus&#039; coding modes. Also, because it is an optional part of the specification, using Opus Custom may lead to compatibility problems. For these reasons, its use is discouraged outside of very specific applications, e.g.:&lt;br /&gt;
* ultra low delay applications where synchronization with the soundcard buffer is important. &lt;br /&gt;
* low-power embedded applications where compatibility with others is not important.&lt;br /&gt;
&lt;br /&gt;
For almost all other types of applications, Opus Custom should not be used.&lt;br /&gt;
&lt;br /&gt;
=== How do I use 44.1 kHz or some other sampling rate not directly supported by Opus? ===&lt;br /&gt;
&lt;br /&gt;
Tools which read or write Opus should interoperate with other sampling rates by transparently performing sample rate conversion behind the scenes whenever necessary. In particular, software developers should not use Opus Custom for 44.1 kHz support, except in the very specific circumstances outlined above.&lt;br /&gt;
&lt;br /&gt;
Note that it&#039;s generally preferable for a decoder to output at 48kHz even when you know the original input was 44.1kHz, not only because you can skip resampling but also because many inexpensive audio interfaces have poor quality output for 44.1k.&lt;br /&gt;
&lt;br /&gt;
The opus-tools package source code contains a small, high quality, high performance, BSD licensed resampler which can be used where resampling is required.&lt;br /&gt;
&lt;br /&gt;
=== How is the bitrate setting used in VBR mode? ===&lt;br /&gt;
&lt;br /&gt;
Variable bitrate (VBR) mode allows the bitrate to automatically vary over time based on the audio being encoded, in order to achieve a consistent quality.  The bitrate setting controls the desired quality, on a scale that is calibrated to closely approximate the average bitrate that would be obtained over a large and diverse collection of audio.  The actual bitrate of any particular audio stream may be higher or lower than this average.&lt;br /&gt;
&lt;br /&gt;
=== What frame size should I use? ===&lt;br /&gt;
&lt;br /&gt;
A 20 ms frame size works well for most applications.  Smaller frame sizes may be used to achieve lower latency, but have lower quality at a given bitrate.  Sizes greater than 20 ms increase latency and are generally beneficial only at fairly low bitrates, or when used to reduce external overhead (e.g. by reducing the number of packets that are sent).&lt;br /&gt;
&lt;br /&gt;
=== Forward Error correction (FEC) doesn&#039;t appear to do anything! HELP! ===&lt;br /&gt;
&lt;br /&gt;
The inband FEC feature of Opus helps reduce the harm of packet loss by encoding some information about the prior packet.&lt;br /&gt;
&lt;br /&gt;
In order to make use of inband FEC the decoder must delay its output by at least one frame so that it can call the decoder with the decode_fec argument on the &#039;&#039;next&#039;&#039; frame in order to reconstruct the missed frame. This works best if it&#039;s integrated with a jitter buffer.&lt;br /&gt;
&lt;br /&gt;
FEC is only used by the encoder under certain conditions: the feature must be enabled via the OPUS_SET_INBAND_FEC CTL, the encoder must be told to expect loss via the OPUS_SET_PACKET_LOSS_PERC CTL, and the codec must be operated in any of the linear prediction or Hybrid modes. Frame durations of &amp;lt;10ms and very high bitrates will use the MDCT modes, where FEC is not available.&lt;br /&gt;
&lt;br /&gt;
Even when FEC is not used, telling the encoder about the expected level of loss will help it make more intelligent decisions. By default the implementation assumes there is no loss.&lt;br /&gt;
&lt;br /&gt;
=== I can&#039;t use malloc or much stack on my embedded platform. How do I make Opus work? ===&lt;br /&gt;
&lt;br /&gt;
A normal build of libopus only uses malloc/free in the _create() and _destroy() calls, so Opus is safe for realtime use so long as the codec state is pre-created.&lt;br /&gt;
&lt;br /&gt;
In order to build Opus without any reference to malloc/free at all use init() calls rather than the create() calls in your application and compile with &amp;lt;tt&amp;gt;CFLAGS=&amp;quot;-DOVERRIDE_OPUS_ALLOC -DOVERRIDE_OPUS_FREE  -D&#039;opus_alloc(x)=NULL&#039; -D&#039;opus_free(x)=NULL&#039; &amp;quot;&amp;lt;/tt&amp;gt; you will get a build which does not use malloc/free.&lt;br /&gt;
&lt;br /&gt;
If libopus is built with -DNONTHREADSAFE_PSEUDOSTACK (instead of VAR_ARRAYS, or USE_ALLOCA) it will use a user provided block of heap instead of stack for many things resulting in much lower the stack usage. However this makes the resulting library non-threadsafe and is not recommend on anything except limited embedded platforms.&lt;br /&gt;
&lt;br /&gt;
=== How can I ensure that my software interoperates with other software implementing Opus? ===&lt;br /&gt;
&lt;br /&gt;
For applications using Ogg files, there are some [http://people.xiph.org/~greg/opus_testvectors/ Ogg Opus testvectors] to test decoders and you can test encoders with opusdec. For RTP applications, the opusrtp tool can be useful. In general, here&#039;s a list of specific issues to check:&lt;br /&gt;
* Can your application handle all frame sizes, including changing the frame size from frame to frame?&lt;br /&gt;
* Does your application properly react to lost packet by calling the decoder with a NULL packet?&lt;br /&gt;
&lt;br /&gt;
=== What is the complexity of Opus? ===&lt;br /&gt;
&lt;br /&gt;
The complexity of Opus varies by a large amount based on the settings used. It depends on the mode, audio bandwidth, number of channels, and even a &amp;quot;complexity knob&amp;quot; that can trade complexity for quality. It will run easily on any recent PC or smartphone. For slower embedded CPUs/DSPs, the amount of CPU required will vary depending on the configuration and the exact CPU, so you will need to experiment. Do not expect Opus to run on really slow devices like 8-bit micro-controllers.&lt;br /&gt;
&lt;br /&gt;
=== Opus is using too much CPU for my application. What can I do? ===&lt;br /&gt;
&lt;br /&gt;
First don&#039;t panic and don&#039;t start writing assembly just yet. It&#039;s possible that you&#039;re just not using the right set of options. If you&#039;re targeting an embedded/mobile platform, chances are the fixed-point build will be faster, so make sure you&#039;re using --enable-fixed-point or defining FIXED_POINT in the build system. Opus also has a complexity option that can trade quality for complexity. The default is highest quality and highest complexity. You can control this using OPUS_SET_COMPLEXITY() (see doc for details). If all else fails and you need to optimize the Opus code, see the next question.&lt;br /&gt;
&lt;br /&gt;
=== I would like to optimize Opus. Where should I start? ===&lt;br /&gt;
&lt;br /&gt;
Please [http://www.opus-codec.org/contact/ contact us] before you start, or at least before you get too far. This will help coordinate the optimization effort and generally reduce the probability of wasting your time on duplicated effort or generally going on the wrong path. &lt;br /&gt;
&lt;br /&gt;
=== Does Opus have an echo canceller like Speex does? ===&lt;br /&gt;
&lt;br /&gt;
Echo cancellation is completely independent from codecs. You can use any echo canceller (including the one from libspeexdsp) along with Opus. That being said, among the free acoustic echo cancelers (AEC) we&#039;re aware of, the best is probably the Google AEC from the [https://code.google.com/p/webrtc/ WebRTC codebase].&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
	<entry>
		<id>https://wiki.xiph.org/index.php?title=OggOpusImplementation&amp;diff=14420</id>
		<title>OggOpusImplementation</title>
		<link rel="alternate" type="text/html" href="https://wiki.xiph.org/index.php?title=OggOpusImplementation&amp;diff=14420"/>
		<updated>2014-01-24T09:25:25Z</updated>

		<summary type="html">&lt;p&gt;MarkH: MacPorts; fix OS name; Chrome no longer uses WebKit; update FFmpeg support&lt;/p&gt;
&lt;hr /&gt;
&lt;div&gt;== Implementation Status ==&lt;br /&gt;
&lt;br /&gt;
Implementation status of the [https://tools.ietf.org/html/draft-ietf-codec-oggopus Ogg Opus draft]. This draft describes encapsulation of Opus audio in the Ogg container to make &amp;lt;tt&amp;gt;.opus&amp;lt;/tt&amp;gt; files and streams.&lt;br /&gt;
&lt;br /&gt;
What follows is a brief summary of major implementations of the draft, and their status.&lt;br /&gt;
This is intended to help understand the status of each portion of the draft, per [https://tools.ietf.org/html/rfc6982 RFC 6982].&lt;br /&gt;
&lt;br /&gt;
=== opus-tools ===&lt;br /&gt;
&lt;br /&gt;
The initial development implementation of this draft was in the opusenc, opusdec, and opusinfo command-line utilities, part of the opus-tools package and repository.&lt;br /&gt;
While still &#039;development&#039; status (pre-1.0) these utilities are in active public use, and have shipped with Linux distributions as well as homebrew and MacPorts for OS X.&lt;br /&gt;
Together they implement basic read, write and playback support of Ogg Opus files including metadata, multichannel, start and end trimming, the gain field, live streams, and chained files, but currently do not support seeking.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://git.xiph.org/?p=opus-tools.git&lt;br /&gt;
* http://www.opus-codec.org/downloads/&lt;br /&gt;
&lt;br /&gt;
=== opusfile ===&lt;br /&gt;
&lt;br /&gt;
The opusfile library is a separate implementation of this draft as a helper library for demuxing and decoding.&lt;br /&gt;
Like opus-tools, it supports metadata, multichannel, start and end trimming, the gain field, live streams, and chained files.&lt;br /&gt;
Its primary focus is efficient seeking, including over HTTP(S) and in chained streams.&lt;br /&gt;
It currently does not create Ogg Opus files.&lt;br /&gt;
This library is in early development and is not widely deployed, though several projects are currently using it, including xmms2, taglib, and cmus, and it is shipped in some Linux distributions and in homebrew.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://git.xiph.org/?p=opusfile.git&lt;br /&gt;
* http://www.opus-codec.org/downloads/&lt;br /&gt;
&lt;br /&gt;
=== Firefox ===&lt;br /&gt;
&lt;br /&gt;
The Firefox web browser is a widely deployed implementation of this draft.&lt;br /&gt;
Basic playback support with the HTML5 &amp;amp;lt;audio&amp;amp;gt; element, including start and end trimming, the gain field, live streams, multiplexing with other streams (for, e.g., the &amp;amp;lt;video&amp;amp;gt; tag), and seeking, was added in Firefox 15, in production release starting August 28, 2012.&lt;br /&gt;
Multichannel support was added in Firefox 17, in production release starting November 20, 2012.&lt;br /&gt;
Metadata support was added in Firefox 18, in production release starting January 8, 2013.&lt;br /&gt;
Chained file support (as streams only, with seeking disabled) was added in Firefox 20, in production release starting April 2, 2013.&lt;br /&gt;
Encoding support was added in Firefox 26, in production release starting December 10, 2013.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://mozilla.org/firefox/&lt;br /&gt;
* https://hacks.mozilla.org/2012/08/opus-support-for-webrtc/&lt;br /&gt;
* https://bugzilla.mozilla.org/show_bug.cgi?id=674225&lt;br /&gt;
* https://bugzilla.mozilla.org/show_bug.cgi?id=748144&lt;br /&gt;
* https://bugzilla.mozilla.org/show_bug.cgi?id=778050&lt;br /&gt;
* https://bugzilla.mozilla.org/show_bug.cgi?id=455165&lt;br /&gt;
* https://bugzilla.mozilla.org/show_bug.cgi?id=842243&lt;br /&gt;
&lt;br /&gt;
=== Chrome ===&lt;br /&gt;
&lt;br /&gt;
Google&#039;s Chrome web browser added support for this draft with the HTML5 &amp;lt;audio&amp;gt; element in M25 and enabled it by default in M33 for stable release in early 2014.&lt;br /&gt;
This implementation currently does not support end trimming, the gain tag, or chained files.&lt;br /&gt;
Prior to M33 support required passing --enable-opus-playback on the command line when invoking the executable.&lt;br /&gt;
&lt;br /&gt;
This implementation is based on open source code in Chromium, Blink, and FFmpeg.&lt;br /&gt;
&lt;br /&gt;
* https://www.google.com/intl/en/chrome/browser/&lt;br /&gt;
* https://www.google.com/intl/en/chrome/browser/canary.html&lt;br /&gt;
* https://code.google.com/p/chromium/issues/detail?id=104241&lt;br /&gt;
&lt;br /&gt;
=== GStreamer ===&lt;br /&gt;
&lt;br /&gt;
The GStreamer media framework includes an implementation of this draft.&lt;br /&gt;
It supports metadata, multichannel, start and end trimming, the gain field, live streams, chained files, multiplexing with other streams (e.g., video), and seeking.&lt;br /&gt;
Support was first added in early 2011, and is part of the 0.11 and 1.0.x releases.&lt;br /&gt;
The code implementing this draft is in the gst-plugins-bad collection, which generally indicates unsupported and/or experimental code, despite its release status.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* http://gstreamer.net/&lt;br /&gt;
* http://cgit.freedesktop.org/gstreamer/gst-plugins-bad/&lt;br /&gt;
&lt;br /&gt;
=== FFmpeg ===&lt;br /&gt;
&lt;br /&gt;
The popular media framework and conversion tool FFmpeg implements this draft.&lt;br /&gt;
It supports encoding and decoding, multiplexing and demultiplexing with other streams,&lt;br /&gt;
metadata, multichannel, start and end trimming, the gain field, live streams, and seeking.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://ffmpeg.org/&lt;br /&gt;
&lt;br /&gt;
=== libav ===&lt;br /&gt;
&lt;br /&gt;
The development repository for libav implements this draft, similar to FFmpeg.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://libav.org/&lt;br /&gt;
&lt;br /&gt;
=== VLC ===&lt;br /&gt;
&lt;br /&gt;
VLC is another widely deployed implementation of demuxing, decoding, and playback support for this draft.&lt;br /&gt;
It supports metadata, multichannel, start and end trimming, the gain field, live streams, seeking, chained files (though seeking does not work correctly with chained files), and multiplexing with other streams (e.g., video).&lt;br /&gt;
Opus support was added in version 2.0.4, released on October 18, 2012.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* https://www.videolan.org/vlc/&lt;br /&gt;
* https://git.videolan.org/?p=vlc.git&lt;br /&gt;
* https://trac.videolan.org/vlc/ticket/7185&lt;br /&gt;
&lt;br /&gt;
=== foobar2000 ===&lt;br /&gt;
&lt;br /&gt;
A popular Windows application, foobar2000 implements read, write, and playback support for this draft.&lt;br /&gt;
It supports metadata, multichannel, start and end trimming, the gain field, live streams, chained files, and seeking.&lt;br /&gt;
Opus support was added in version 1.1.14, released on August 17, 2012.&lt;br /&gt;
Encoding support is implemented using opusenc from opus-tools.&lt;br /&gt;
&lt;br /&gt;
This implementation is closed source.&lt;br /&gt;
&lt;br /&gt;
* http://www.foobar2000.org/&lt;br /&gt;
&lt;br /&gt;
=== Rockbox ===&lt;br /&gt;
&lt;br /&gt;
Rockbox is an established alternative firmware for portable music players (typically small, embedded devices) that implements demuxing, decoding, and playback support for this draft starting with version 3.13 released March 5, 2013.&lt;br /&gt;
It supports metadata, start and end trimming, the gain field, and seeking.&lt;br /&gt;
It does not currently support multichannel or chained files.&lt;br /&gt;
&lt;br /&gt;
This implementation is open source.&lt;br /&gt;
&lt;br /&gt;
* http://www.rockbox.org/&lt;br /&gt;
* http://git.rockbox.org/?p=rockbox.git&lt;br /&gt;
* http://gerrit.rockbox.org/r/#/c/300/&lt;/div&gt;</summary>
		<author><name>MarkH</name></author>
	</entry>
</feed>