Open lightmar opened 10 years ago
I have this problem too. The error message is caused by trying to create a new ArrayBuffer of size -1 just before the end of the code:
var nread = Module.ccall('lame_encode_buffer_ieee_float', ...]);
var arraybuf = new ArrayBuffer(nread);
I get the "Invalid array buffer length" because nread is -1. The transcompiled code is hard to follow, but so far I have learned the following:
Here's a paste of the function giving that -1.. Will comment again if I get it working for me.
@lightmar: I have a solution which works for me. I could not get the copy of libmp3lame.js in this repo working for recordings longer than 8 seconds, I suspect this is because of something bad in my input, am sending mono and the number of samples seems to be wrong.
Anyway, this copy works for me, found at: http://audior.ec/recordmp3js/, via this tutorial.
Swapping it in, I no longer experience the issue you describe.
Thank you, however I still can't make it work. I just came back to try again after I left it for few months. I have discovered that the error occurs only when a user records microphone with an high sample rate of 192000. When I try it on my mac with 44000 input, it works.
How can I make it work? or Maybe reduce the sample rate somehow?
I'm having problems also on windows computers, which, as @lightmar has stated, have sample rates of 192000 instead of 44000.
Any approach with this?
I have tried changing the Lame config like this:
Lame.set_in_samplerate(mp3codec, 44100); Lame.set_out_samplerate(mp3codec, 44100); Lame.set_bitrate(mp3codec, 128);
And it did worked, but the problem is that the sound recording was really bad, it sounds something like roaring lions....
Can anyone point me to how I can increase the length of time I can record..? I suspect it deals with increasing the bufferlength, etc..
Any help is greatly appreciated. Thanks!
@lightmar , Is this solution helpful?
"Lame.set_in_samplerate(mp3codec, 44100); Lame.set_out_samplerate(mp3codec, 44100); Lame.set_bitrate(mp3codec, 128);"
I am not trying this yet as it works beautifully on linux but has suddenly stopped working on Windows, I'll take your word on it.
@lightmar I should have taken you seriously on the roaring lions thing, Any idea how to fix it??
We run into the same issue. Since it has been a while, may be someone already found the solution ? really appreciate you help.
@lightmar i also get the "roaring lions", did you manage to solve this problem?
@michelboudali, we did not find solution per say, but figured what causing that. On Windows: Try to go Control Panel -> Sound ->Payback-> Advanced and try to change sample rate. We get "Invalid array buffer length" with certain settings and don't get with others.
We do catch that issue by adding onerror handler to worker:
encoderWorker.onerror = function (err) {
var errorText = 'Sorry, We are having some technical <br/>difficulties to convert your recorder <br/>sound to mp3 format and save.';
console.log('worker is suffering!', err)
document.getElementById('recorder_error').innerHTML = errorText;
}
I can share files with you if you are interested.
Hi,
Thank you for this great plugin. Unfortunately I have a problem which I can't figure out. When I encode to mp3 from microphone, on some computers it works great, however on others when I try to encode to I get the following error: Uncaught RangeError: Invalid array buffer length
Does anyone knows whats the reason and how solve it?
Thanks