Wav file is too large
ShyamSMoorthy opened this issue · comments
Hello , Am using the exact "CaptureCfg" configuration mentioned in the document , and everything working fine , But there is major issue we are facing is the wav file is way too large that we are not able to pass is to server or perform any other operations.
(Eg:If we record for 10 min , the blob size is around 165 MB)
Is there any possibility of reducing the wav file size , that would be very helpful .Thanks in advance.
audioinput.DEFAULT = {
SAMPLERATE: audioinput.SAMPLERATE.CD_AUDIO_44100Hz,
BUFFER_SIZE: 16384,
CHANNELS: audioinput.CHANNELS.MONO,
FORMAT: audioinput.FORMAT.PCM_16BIT,
NORMALIZE: true,
NORMALIZATION_FACTOR: 32767.0,
STREAM_TO_WEBAUDIO: false,
CONCATENATE_MAX_CHUNKS: 10,
AUDIOSOURCE_TYPE: audioinput.AUDIOSOURCE_TYPE.DEFAULT,
DEBUG: false
};
I understand, WAV is an uncompressed audio format, which is the reason for why it is so large.
There are some things you could do to make the resulting file at bit smaller:
- SAMPLERATE can be lowered from 44100Hz to 16000Hz (audioinput.SAMPLERATE.VOIP_16000Hz) which probably is enough for most applications. That more than halves the number of samples, which directly cuts the size of the resulting WAV file (which should go from 165MB to around 60MB).
- Create several smaller recording chunks instead of a single big one and then concatenate them on the server.
- Compress the WAV before sending it to the server. There are a number of ways of doing this:
3.1 Quick and dirty: Before sending the WAV, zip it using a client side library, for example https://github.com/Stuk/jszip: zip.file("audio.wav", blob); On the server, you then need to unzip the file before processing it.
3.2 Convert the audio to a compressed audio format: Like for example here: https://github.com/Audior/Recordmp3js or using https://github.com/zhuker/lamejs or something similar.
3.3 Using a Cordova plugin like for example: https://github.com/Tushar-Kanvinde/cordova-phonegap-audio-encode (for iOS) to convert the WAV to M4A.
I hope this helps!
@ShyamSMoorthy since this issue hasn't been active for some time now, I will close it. Just let us know if there is any new information.