I am asking because I couldn't find the answer anywhere. I have successfully implemented RecorderJS in order to record microphone input in JS. However, the recorded file is WAV which results in large files. I am looking for a way to record with JS directly to MP3, or encode the bits somehow to MP3 instead of WAV.
How can it be done? Is there a Web Audio API function that can do that or JS MP3 encoder of some sort?
One of the best ways to record audio on a website is to use a Chrome Extension like Audio Capture. This tool can be easily installed on the browser, ready to use whenever you need to record audio on any tab. It also allows you to mute all other tabs to avoid accidently recording them as well.
At the moment the MediaStream Recorder API is only supported by Chrome, Firefox, Opera and Edge 79 (Chromium). Please comment on this Safari/WebKit feature request to request Safari support.
Chrome Audio Capture is a Chrome extension that allows users to record any audio playing on the current tab. Multiple tabs can be recorded simultaneously. Recordings can be saved as either .
The only Javascript MP3 encoder I've seen is https://github.com/akrennmair/libmp3lame-js, which is a port using emscripten. It's supposed to be slow, and I've never used it.
I don't know of any natively-written Javascript MP3 encoders, and encoding is not covered by the Web Audio API.
There's a library written in pure javascript, called lamejs. To encode mp3s from raw audio. It is much faster than emscripten compile of libmp3lame. https://github.com/zhuker/lamejs
Example usage:
lib = new lamejs();
mp3encoder = new lib.Mp3Encoder(1, 44100, 128); //mono 44.1khz encode to 128kbps
samples = new Int16Array(44100); //one second of silence
var mp3 = mp3encoder.encodeBuffer(samples); //encode mp3
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With