badaix / snapweb

Web interface for Snapcast
GNU General Public License v3.0
102 stars 33 forks source link

Missing opus support #8

Open badaix opened 4 years ago

badaix commented 4 years ago

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.

tilllt commented 3 years ago

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

kingosticks commented 3 years ago

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.

tilllt commented 3 years ago

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

kingosticks commented 3 years ago

Yes, someone just needs to do it.

m040601 commented 1 year ago

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 ?

blacklight commented 8 months ago

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 commented 8 months ago

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.

kingosticks commented 1 week ago

https://github.com/eshaz/wasm-audio-decoders might be useful in solving this and https://github.com/badaix/snapweb/issues/14