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

Any way to get audioBitsPerSecond #643

Open
bryanmcgrane opened this issue May 9, 2021 · 4 comments
Open

Any way to get audioBitsPerSecond #643

bryanmcgrane opened this issue May 9, 2021 · 4 comments

Comments

@bryanmcgrane
Copy link

Hello! I would like to obtain the audioBitsPerSecond via: https://developer.mozilla.org/en-US/docs/Web/API/MediaRecorder/audioBitsPerSecond

Is there any way I can get this from the MediaRecorder object?

@chrisguttandin
Copy link
Owner

Unfortunately that's not yet implemented. I'm also not really sure how it's supposed to work. It doesn't work the same in Chrome and Firefox. On top of that the number returned in Chrome isn't always correct.

In case you just want to know the audioBitsPerSecond value of the wav encoder it can be computed with the following formula.

16 /* bitsPerSample */ * sampleRate * numberOfChannels

@bryanmcgrane
Copy link
Author

I ended up parsing the wav file header and grabbing the info from that :)

@chrisguttandin
Copy link
Owner

Okay, great. I think we should leave the issue open until it get's finally implemented.

Just in case someone else needs this before I guess you used something like this to read the value from the first Blob, right?

const arrayBuffer = await blob.arrayBuffer();
const dataView = new DataView(arrayBuffer);
const audioBitsPerSecond = dataView.getUint32(28, true);

@bryanmcgrane
Copy link
Author

Yes that's exactly what I did!

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

No branches or pull requests

2 participants