Skip to content Skip to sidebar Skip to footer

Encode Audiobuffer With Opus (or Other Codec) In Browser

I am trying to stream Audio via Websocket. I can get an AudioBuffer from the Microphone (or other Source) via Web-Audio-Api and stream the RAW-Audio-Buffer, but i think this would

Solution 1:

The Web Audio API has a MediaStreamDestination node that will expose a .stream MediaStream that you can then pass through the WebRTC API.

But if you are only dealing with a microphone input, then pass directly that MediaStream to WebRTC, no need for the Web Audio step.


Ps: for the ones that only want to encode to opus, then MediaRecorder is currently the only native way. It will incur a delay, will generate a webm file, not only the raw data, and will process the data no faster than real-time.

Only other options now are to write your own encoders and run it in WabAssembly.

Hopefully in a near future, we'll have access to the WebCodecs API which should solve this use case among others.

Post a Comment for "Encode Audiobuffer With Opus (or Other Codec) In Browser"