chrisguttandin/extendable-media-recorder

Any way to get audioBitsPerSecond

Opened this issue · 4 comments

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?

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

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

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);

Yes that's exactly what I did!