gpac / mp4box.js

JavaScript version of GPAC's MP4Box tool
https://gpac.github.io/mp4box.js/
BSD 3-Clause "New" or "Revised" License
1.94k stars 326 forks source link

Getting audio track extradata #287

Closed bengfarrell closed 2 years ago

bengfarrell commented 2 years ago

Hi, thanks for the great library! This isn't a bug, but I'm hoping someone will know the answer to this. I've been using your examples for extracting video samples and decoding with the VideoDecoder from the Web Codecs API as shown in the demo where your sample code from mp4_demuxer.js does the heavy lifting.

I'm trying to do similar for audio, and I'm having a hard time figuring out how I'd adapt the getExtradata function to pull from the audio track instead, which I assume would NOT point to the avcc box, and even then if I did find the correct box would need to know how to construct the byte array based on a handful of mystery (to me) properties.

Do you all have any examples? thanks!

bengfarrell commented 2 years ago

Yikes! I see on https://github.com/gpac/mp4box.js/issues/243 that AAC isn't supported! And even then Chrome doesn't seem to recognize Opus in MP4 containers yet! That explains why I can't find great examples!

All the same though, I'd still love to know if anyone has a replacement function for extradata assuming the audio is Opus. I'm just pulling in the file through MP4Box's createFile function, so it's not like Chrome is reading the MP4 itself in my example

bengfarrell commented 2 years ago

I'm closing this! Thanks for reading. I'm finding that the extradata is really optional. I've just been getting burned on unhelpful errors with setting up AudioDecoders. And this is all due to lack of examples in the Web Codec API space right now for working with audio.