WebCodecs

122 views
Skip to first unread message

Artur Grigoryan

unread,
Sep 21, 2021, 2:40:10 AM9/21/21
to medi...@chromium.org
Hello,
I hope you are doing well.

I'm trying to use WebCodecs for decoding audio (need to get
audioBuffer from arrayBuffer), currently I'm using decodeAudioData,
but it's not working for big files. I need to understand is there a
way to decode with WebCodecs

Thanks
Artur Grigoryan

guest271314

unread,
Sep 21, 2021, 9:41:53 AM9/21/21
to media-dev, Artur Grigoryan
No, WebCodecs does not provide a specified means to decode audio.

> I'm using decodeAudioData, but it's not working for big files

One option is to utilize Web Audio API AudioWorklet or Media Capture Transform MediaStreamTrackProcessor.

Chris Cunningham

unread,
Sep 21, 2021, 2:22:19 PM9/21/21
to Artur Grigoryan, media-dev
Hi Artur,

Yes, WebCodecs supports audio decoding via the AudioDecoder interface. You'll want to use the encoded samples in your array buffer to construct EncodedAudioChunks, which you'll then feed to the AudioDecoder via decode(). We don't have a good demo for AudioDecoder yet (in development), but you can get a sense for how this works by checking out the video decoder demo here.

Best,
Chris

--
You received this message because you are subscribed to the Google Groups "media-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to media-dev+...@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/media-dev/CABB34sbO%3DMQZOD72xuZrApR_OTR4eMfqg-ULFGjpYtaf63pKQA%40mail.gmail.com.

guest271314

unread,
Sep 21, 2021, 7:39:20 PM9/21/21
to media-dev, Chris Cunningham, media-dev, Artur Grigoryan
It makes no sense to encode again just to decode. 

Also, WebCodecs AudioDecoder suffers from the restriction of fixed sampleRate set to 48000 which requires substantial effort to re-sample to a rate other than 48000, see https://github.com/WebAudio/web-audio-api-v2/issues/133



Reply all
Reply to author
Forward
0 new messages