Reputation: 111
Trying to find a suitable technique/container for streaming live low-latency Opus over HTTP/TCP?
The Ogg container is of course the obvious choice. However, for low-bitrate Opus (<50 bytes/frame) the overhead becomes huge if low-latency streaming is desired. For example, for Opus @ 8 kbps in 20 ms chunks the overhead becomes 58% if only one frame is placed in each Ogg page.
Upvotes: 2
Views: 4365
Reputation: 9090
With WebAssembly, we can play freshly-download audio in < 300ms on a 2mbps connection: https://fetch-stream-audio.anthum.com/
Upvotes: 0
Reputation: 305
OggOpus is absolutely unsuitable for low-latency streaming because of the way Ogg is designed. I assume you already know a bit about this since you mentioned pages but for the benefit of StackOverflow: Opus packets are arranged into Ogg pages, each page typically containing 255 Opus packets. Each Opus packet is typically 20ms of audio. Each Ogg page includes a checksum to validate its contents, and the page can't be sent on the wire until the checksum is calculated, and therefore until the entire page is filled. 20ms * 255 packets = about 5 seconds of audio that has to be buffered before the audio can be sent over the wire, and that is significant delay from a user perspective.
It's true that you can send fewer packets per page, but this results in higher data overhead as you need to create more ogg pages, and at low levels (just a few packets per page) the overhead becomes so large that it nearly cancels out the audio compression in the first place.
WebRTC is the typical solution for realtime Opus audio over the network; however, it also assumes that you are using a transport layer that operates on datagrams (e.g. UDP, WebSocket) rather than as a continuous stream (e.g. TCP). This question came up for me when I wanted to implement an Opus interface to Microsoft Speech services - since I wanted low latency as well as low overhead speech over a TCP stream. The Opus developers recommended just using a simple length-prefix protocol following Opus' own frame length coding. With such a protocol you would just send the raw Opus packets, each one prefixes by one or two bytes indicating packet length.
Upvotes: 3
Reputation: 19664
Here are some Opus streams over HTTP using Icecast.
Icecast is a streaming media server which currently supports Ogg (Vorbis and Theora), Opus, WebM and MP3 audio streams. It can be used to create an Internet radio station or a privately running jukebox and many things in between. It is very versatile in that new formats can be added relatively easily and supports open standards for commuincation and interaction.
Icecast is distributed under the GNU GPL, version 2.
Upvotes: 0
Reputation: 163468
The only way I know of to get low latency is to use WebRTC. It's built for that, where nothing else web-based really is.
You won't necessarily be able to pick your codec (at least not with the higher level APIs available), and codec and bitrate negotiation is part of the standard. But, you will get the lowest latency available to you for anything web-based, short of a browser plugin.
Upvotes: 1