Decrease Bitrate on Wav File Created with Recorderjs

Decrease bitrate on WAV file created with recorderjs

You could try a couple of things. First off, I think you're on to something about "dropping every other element of the interleaved buffer" (converting the sound to mono).

For that you could choose to keep the left or the right channel. You could change the "interleave" function to be:

function interleave(inputL, inputR){
return inputL; // or inputR
}

If you wanted to keep both channels, but "pan" them both center (to the single mono channel), you could do something like:

function interleave(inputL, inputR){
var result = new Float32Array(inputL.length);
for (var i = 0; i < inputL.length; ++i)
result[i] = 0.5 * (inputL[i] + inputR[i]);
return result;
}

That being said, there are potentially a lot of other placed you would have to change the encoded audio from being denoted as stereo to mono. However, my guess is (and I haven't used recorder.js, so I don't know it's inner workings), line 113/114 in the recorderWorker could probably changed to 1.

My guess is that you could get away with just changing the two places mentioned here (the interleave function, and the place where channel-count is set [line 114]) because: interleave and encodeWAV are only called through the exportWAV function, so not touching how the original worker has been recorder audio (and it's been recording stereo) hopefully won't break it. We would in that case only be making changes to the audio that was stored.

How to Reduce wav File-size created by Recorder.js

The problem with wav is that the files are non-compressed, therefore they take up a lot of space on the disk, just 1 minute of recording can take as much as 10 Megabytes.

The solution to this? Well let’s convert the wav file to mp3. Simply saving the wav file and then converting it will not do. We will need to convert the recording, to mp3, in real time, in the browser.

https://nusofthq.com/blog/recording-mp3-using-only-html5-and-javascript-recordmp3-js/

Recorder.js calculate and offset recording for latency

I'm a bit confused by your concern for the latency. Yes, it's true that the minimum possible latency is going to be the related to the length of the buffer but there are many other latencies involved. In any case, the latency has nothing to do with the recording duration, which seems to me to be what your question is about.

If you want to record an exactly 3 second long buffer at 44100 that is 44100*3=132,300 samples. The buffer size is 4096 samples and the system is only going to record an even multiple of that number. Given that the closest you are going to get is to record either 32 or 33 complete buffers. This gives either 131072 (2.97 seconds) or 135168 (3.065 seconds) samples.

You have a couple options here.

  • Choose a buffer length that evenly divides the sample rate. e.g. 11025. You can then record exactly 12 buffers.
  • Record slightly longer than the 3.0 seconds you need and then throw the extra 2868 samples away.


Related Topics



Leave a reply



Submit