Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How can I use ogv just for decoding? #533

Open
jfrancos opened this issue Oct 8, 2019 · 8 comments
Open

How can I use ogv just for decoding? #533

jfrancos opened this issue Oct 8, 2019 · 8 comments

Comments

@jfrancos
Copy link

jfrancos commented Oct 8, 2019

For Brave/Firefox I use WebAudio's decodeAudioData, which returns an AudioBuffer of the decoded PCM audio data. This doesn't work in Safari.

Is there a way I can use ogv just for decoding, in place of decodeAudioData?

Thanks for your hard work.

@bvibber
Copy link
Owner

bvibber commented Dec 12, 2019

This would be possible to rig up using the codec modules directly, though not yet a convenient interface for it.

Roughly, you need to pass data into a demuxer module's receiveInput method, then loop over it with process, dequeuing any packets along the way and passing them into the decoder module. Take the output data, concatenate it all into a single ArrayBuffer and resolve the promise.

Devil's always in the details though. :)

@guest271314
Copy link

What is input and expected output?

@guest271314
Copy link

Do not have access to Safari. Testing decodeAudioData at Epiphany 3.28.5 an AudioBuffer is logged when the audio codec is Ogg or A_PCM/FLOAT/IEEE in a WebM container or MP2/MP3 in a MP3. OPUS in a WebM container outputs null. Conversion to WAV can be achieved using this version https://cdn.jsdelivr.net/npm/[email protected]/index.js of https://github.com/mattdiamond/Recorderjs at https://plnkr.co/edit/HMqf5CrAXhOHtlzOadI8?p=info.

@jfrancos
Copy link
Author

Actually I figured out how to use emscripten to be able to use vorbis-tools' oggdec directly:

https://github.com/jfrancos/oggdec-wasm

@guest271314
Copy link

@jfrancos Are you able to verify which file types and codecs Safari is able to decode with decodeAudioData() re #533 (comment) and mdn/webaudio-examples#5?

@rgov
Copy link

rgov commented Apr 12, 2021

I would love to be able to do this as well. My use case is that I have a stream of "raw" Theora packets coming from a camera, without an OGV container. I want to be able to feed in the header packets, an intra frame, and a sequence of inter frames and get out the final image buffer. Is this possible at all? The codec-bench.html file looks like it might be close.

@bvibber
Copy link
Owner

bvibber commented Apr 12, 2021

Yes, you can call the decoder directly if you like. No stable api or documentation or support.

@rgov
Copy link

rgov commented Apr 12, 2021

Ok thanks. I put together an example of using ogv.js to decode raw Theora packets into video frames: https://github.com/rgov/js-theora-decoder (Demo)

@Brion One thing I'm curious about is why I need to call processHeader() for intra frames, instead of processFrame().

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants