How to record audio in format of mp3/m4a JavaScript- recorder.js

可紊 提交于 2019-12-08 10:03:29
rampravesh

i think you should check this link : HTML5 record audio to file

here u can change the audio type like this : type = type || config.type || 'audio/wav';

Recorder.js does NOT support encoding captured audio as mp3.

It can only record 16 bit mono or stereo uncompressed pcm as wav.

To halve the size you could record mono sound instead of 2 channel/stereo using numChannels:1 in the Recorder.js constructor like this:

var rec = new Recorder(source,{numChannels:1})

numChannels is an undocumented feature of Recorder.js (the library is not maintained anymore).

Source: https://addpipe.com/blog/using-recorder-js-to-capture-wav-audio-in-your-html5-web-site/

To record to mp3 you can use:

  1. WebAudioRecorder.js which includes an asm.js version of the LAME mp3 encoder
  2. vmsg which includes a WebAssembly version of the LAME mp3 encoder

You can change the format of the recording by mentioning the format in exportWAV function, as follows:

recorder.exportWAV(function (blob) {
                callback(blob);

                // create WAV download link using audio data blob
                // createDownloadLink();

                // Clear the Recorder to start again !
                recorder.clear();
            }, "audio/mp3");

I have came to the above solution for the following link.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!