javascript - reducing recorded audio .wav file size -
i using recorder.js , recorderworker.js record audio. know file type .wav , and file size big. tried 1 solution got previous similar questions asked on stackoverflow still 1 min audio, file size >= 6.5 mb. instead of both channels using single channel. these following changes have mad in javascript.
in recorder.js-->
this.node.onaudioprocess = function(e){ if (!recording) return; var buffer = []; (var channel = 0; channel <1; channel++){ buffer.push(e.inputbuffer.getchanneldata(channel)); } worker.postmessage({ command: 'record', buffer: buffer }); }
in recorderworker.js-->
function record(inputbuffer){ (var channel = 0; channel < 1; channel++){ recbuffers[channel].push(inputbuffer[channel]); } reclength += inputbuffer[0].length; } function exportwav(type){ var bufferl = mergebuffers(recbuffers[0], reclength); var dataview = encodewav(bufferl); var audioblob = new blob([dataview], { type: type }); this.postmessage(audioblob); } function getbuffer(){ var buffers = []; (var channel = 0; channel < 1; channel++){ buffers.push(mergebuffers(recbuffers[channel], reclength)); } this.postmessage(buffers); } function interleave(inputl, inputr){ var length = inputl.length; var result = new float32array(length); var index = 0, inputindex = 0; while (index < length){ result[index++] = inputl[inputindex]; //result[index++] = inputr[inputindex]; inputindex++; } return result; } /* channel count */ view.setuint16(22, 1, true); /* block align (channel count * bytes per sample) */ view.setuint16(32, 2, true);
i tried convert mp3 file type using libmp3lame.js slow plus can't record >2 min audio using this.
what asking first, there doing wrong because of size not getting reduced? second, there anyother way reduce size?
Comments
Post a Comment