0

I am using recorder.js to upload user's audio files on our server. This is working in chrome and firefox both..But our audio file will be around 1 minute and for 1 minute audio file its generating approx 8 MB file which is too large to upload on server..

I have tried to update recorderWorker.js file:

Updated interleave method as

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

and set channel-count as

/* channel count */
view.setUint16(22, 1, true);

By this above code my file was created in just half size ie of 4 MB. when I play this file in chrome it is working but when I try this file in firefox and windows media player..This is not working..In firefox its giving failed to load and in windows media player giving "Windows Media Player encountered a problem while playing the file." message.

I have created 2 samples:

http://216.245.194.124/recorduploadsample.com/
http://216.245.194.124/recorduploadsample2.com/

First sample will work in both chrome and firefox and after record anything we can play the recorded sound..(This is original code with large file size)

Second sample is working only in chrome not in firefox (Updated above code to reduce the file size)

I need to reduce the file size by changing resolution of the audio file and that should work in chrome, firefox both...Can anyone suggest the solution for this?

Thanks in Advance

aagrawal
  • 45
  • 7
  • You might find this relevant: http://stackoverflow.com/questions/16296645/decrease-bitrate-on-wav-file-created-with-recorderjs I needed to change the bitrate, but that of course also reduces the filesize. – icedwater Apr 01 '14 at 06:44
  • @icedwater Yes I found that post and on basis of that I changed channel count and updated interleave method but that was only working in chrome not in firefox...I also want to record the audio in low resolution to reduce the file size..What needs to change for this? – aagrawal Apr 01 '14 at 06:51
  • My guess? Either recorder.js or firefox. But it's a wild guess. – icedwater Apr 01 '14 at 06:54
  • @icedwater When I did not make these changes to reduce file size that time that audio file is playing well in chrome, firefox and windows media player also....But when I added this code to reduce the file size it only works in chrome...It is not working in firefox as well as windows media player too...I want to reduce file size but it should work in all...For this what should be changed in code? – aagrawal Apr 01 '14 at 07:01

1 Answers1

1

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/

Dr.jacky
  • 3,341
  • 6
  • 53
  • 91