Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Converting WAV to any compressed audio format in client-side JavaScript

I am recording audio from getUserMedia({audio:true}); in the browser using Recorder.js and then exporting it as a WAV file because that's the only option the library provides.

A 1 minute 20 seconds file is 14.1 MB large. I need to upload the audio to a server and I need to do it fast. How do I convert the WAV audio in any other compressed format to lower the file size?

I don't mind converting to:

  • MP3
  • Opus
  • WebM
  • Ogg
  • FLAC
  • any other format you know of

If there is no way as of now to convert to any of these formats, how can I compress the WAV file on the client?

PS: I did a lot of searches to find anything that converts WAV in JS, but found nothing. libmp3lame.js isn't working in Chrome.

Thanks!

like image 289
Arjun Bajaj Avatar asked Jul 03 '13 19:07

Arjun Bajaj


People also ask

Is WAV audio compressed?

Though a WAV file can contain compressed audio, the most common WAV audio format is uncompressed audio in the linear pulse-code modulation (LPCM) format. LPCM is also the standard audio coding format for audio CDs, which store two-channel LPCM audio sampled at 44,100 Hz with 16 bits per sample.

How do I compress a WAV file to a zip file?

Click "Compressed (zipped) Folder." Windows creates a new zip folder whose name matches your WAV file's name. The folder also has a ZIP file extension. You'll see this folder in the same folder that contains your WAV file. Right-click that folder and select “Properties” to view the folder's size.

Can you compress WAV files without losing quality?

The only way to reduce the size of a wav file is to resample it to a lower bit rate or use less bits per sample. Wav files don't have compression capabilities like mp3 or ogg.

Does HTML audio support WAV?

The browser will choose the first source it supports. The text between the <audio> and </audio> tags will only be displayed in browsers that do not support the <audio> element. There are three supported audio formats in HTML: MP3, WAV, and OGG.


1 Answers

I've made an audio recorder that records to mp3 directly from the browser combining RecorderJS and libmp3lame.js

You can find the gitHub project here: https://github.com/nusofthq/Recordmp3js

and a more detailed explanation of the implementation: http://nusofthq.com/blog/recording-mp3-using-only-html5-and-javascript-recordmp3-js/

like image 191
Remus Negrota Avatar answered Oct 06 '22 18:10

Remus Negrota