snapweb icon indicating copy to clipboard operation
snapweb copied to clipboard

Missing opus support

Open badaix opened this issue 5 years ago • 9 comments

Snapweb should support opus. There is a opus branch with a emscripten cross compiled opus library, but it's getting out of sync during playback, maybe the decoding must be done in a thread.

badaix avatar Sep 26 '20 19:09 badaix

Naive question, but can't snapweb use the built-in browsers codecs (like OPUS) and achieve sync by using browser internal mechanisms like this?

https://developer.mozilla.org/en-US/docs/Web/API/AudioBufferSourceNode/playbackRate

tilllt avatar Apr 05 '21 08:04 tilllt

No. We need to be able to decode raw Opus, browsers handle Ogg Opus. I don't think playbackrate helps us with this but maybe I'm misunderstanding you. Something like https://github.com/samirkumardas/opus-to-pcm goes some way to explain the issue (I'm not an expert on Ogg but I'm not convinced about the framing implementation and the flushing config setting). More interesting is the upcoming https://w3c.github.io/webcodecs/ API which would be perfect. Looks like it's in Chrome 86 (behind a feature flag) and Firefox are working on supporting it. I guess it won't be available for a long while yet. Best off finding a libopus wasm library in the meantime, we probably don't care about a huge file size.

kingosticks avatar Apr 11 '21 19:04 kingosticks

I understand that snapcast needs the raw opus stream, not the ogg encapsuled opus, so that's a problem if the built-in codec cannot decode raw opus.

In any case, it seems that other programs successfully integrated emscripten versions of opus, specifically the aurora.js project...

https://github.com/audiocogs/opus.js

tilllt avatar Apr 11 '21 19:04 tilllt

Yes, someone just needs to do it.

kingosticks avatar Apr 11 '21 20:04 kingosticks

Can anyone give an update on this situation for non technical users ? Was there any progress regarding this issue ?

After some years of using snapcast already, I ended up here today because I was testing the builtin Snapweb client on Firefox (http://myserver:1780/).

I rarely use a web browser as a client, so I hadnt noticed this before.

After many years of using Firefox I was quite surprised to find this messages:

Codec not supported: ogg

and

Codec not supported: opus

I am 99.99 % sure that I have already listened to other radio streams in ogg or opus in Firefox, so this "not supported" message has nothing to do with Firefox itself. Am I correct ?

It's some "opus support" or "ogg support" missing from Snapcast . Am I correct ?

m040601 avatar Dec 13 '22 18:12 m040601

Any progress on this issue? From what I understand the possible solutions would include:

  1. Piggyback on opus.js
  2. Make a custom WASM wrapper
  3. Wait for the webcodecs API to be released

Is my understanding correct that the opus.js way may be the favourite one?

Btw if the problem is only with raw opus and not with ogg opus then why do I get Codec not supported: ogg as well?

blacklight avatar Feb 16 '24 20:02 blacklight

It's some "opus support" or "ogg support" missing from Snapcast . Am I correct ?

It's not on Snapcast, technically speaking. If you configure codec=opus on Snapserver and then you play from the Snapclient service or from the Android app, everything goes well.

That's because those applications use the native Opus decoders.

The problem is only with the Web side, as raw Opus (apparently) isn't natively supported, thus support can be added either through an external library, or by sideloading the codec through a WASM wrapper.

blacklight avatar Feb 16 '24 20:02 blacklight