If anyone is integrating Opus audio into a web or JavaScript application, I wrote a WebAssembly Opus decoder that uses libopusfile to decode Opus files in chunks using the JavaScript Streams API. This decoder can begin decoding after receiving the Opus headers and first audio data page: https://github.com/AnthumChris/opus-stream-decoder All thoughts and contributions are welcome, and I'm planning to add a seeking feature using HTTP range requests: https://github.com/AnthumChris/opus-stream-decoder/issues/1 Browsers and the Web Audio API don't currently offer direct ways to decode partial Opus files until the complete file is downloaded and available. If anyone has connections with browser vendor engineers, it would be worth considering a direct way for JavaScript to access browsers' baked-in Opus decoding library, which would avoid the ~140-220K Wasm binaries currently needed to do this. Only complete files can be downloaded with BaseAudioContext.decodeAudioData(): https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/decodeAudioData -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/opus/attachments/20181102/33bd013f/attachment.html>
Chris McGowan wrote:> All thoughts and contributions are welcome, and I'm planning to add a > seeking feature using HTTP range requests: > https://github.com/AnthumChris/opus-stream-decoder/issues/1You may also be interested in <https://github.com/brion/ogv.js/> (if you're not already aware of it). There might be some useful collaboration possible.> ~140-220K Wasm binaries currently needed to do this. Only complete > files can be downloaded with BaseAudioContext.decodeAudioData(): > https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/decodeAudioDataMaybe I'm confused, but I thought this was the purpose of the Media Source Extensions? If you can parse page boundaries with JS/WebAssembly, it is pretty simple to assemble a "complete" file from partial file contents by prepending the headers in the right place, but to get seamless playback between different chunks, you also need to maintain decoder state between them. decodeAudioData can't do that, but MSE should be able to?
Thanks Timothy. Media Source Extensions were much easier and high-level than using WebAssembly with the Web Audio API. Unfortunately, MSE does not support MIME "audio/ogg" and I had to put my OpusFiles into a WebM container file. What could we do to get MSE support for Ogg Opus files? I created this issue if it helps: https://github.com/w3c/media-source/issues/245. Would be happy to initiate the process with the web platform folks. On Fri, Nov 2, 2018 at 1:10 PM Timothy B. Terriberry <tterribe at xiph.org> wrote:> Chris McGowan wrote: > > All thoughts and contributions are welcome, and I'm planning to add a > > seeking feature using HTTP range requests: > > https://github.com/AnthumChris/opus-stream-decoder/issues/1 > > You may also be interested in <https://github.com/brion/ogv.js/> (if > you're not already aware of it). There might be some useful > collaboration possible. > > > ~140-220K Wasm binaries currently needed to do this. Only complete > > files can be downloaded with BaseAudioContext.decodeAudioData(): > > > https://developer.mozilla.org/en-US/docs/Web/API/BaseAudioContext/decodeAudioData > > Maybe I'm confused, but I thought this was the purpose of the Media > Source Extensions? > > If you can parse page boundaries with JS/WebAssembly, it is pretty > simple to assemble a "complete" file from partial file contents by > prepending the headers in the right place, but to get seamless playback > between different chunks, you also need to maintain decoder state > between them. decodeAudioData can't do that, but MSE should be able to? > _______________________________________________ > opus mailing list > opus at xiph.org > http://lists.xiph.org/mailman/listinfo/opus >-------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/opus/attachments/20191206/20d08a36/attachment.html>
Timothy B. Terriberry <tterribe at xiph.org> wrote:> If you can parse page boundaries with JS/WebAssembly, it is pretty > simple to assemble a "complete" file from partial file contents by > prepending the headers in the right place >Hey, Timothy, I ended up writing a JavaScript Opus file splitter, thanks for letting me know that it was possible. https://github.com/AnthumChris/fetch-stream-audio/tree/master/utils/opus-file-splitter -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://lists.xiph.org/pipermail/opus/attachments/20191213/9db11378/attachment.html>