badaix / snapweb

Web interface for Snapcast

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing opus support

badaix opened this issue · 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.

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

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.

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

Yes, someone just needs to do it.

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 ?

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?

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.