[英]How to record audio in format of mp3/m4a JavaScript- recorder.js
In recorderjs rec.exportWAV([callback][, type])
is used to generate a Blob object containing the recorded audio in WAV format.在 recorderjs
rec.exportWAV([callback][, type])
用于生成包含 WAV 格式录制音频的 Blob 对象。
But the WAV file is taking large space, for 30sec it is approximately 1mb.但是WAV文件占用了很大的空间,30秒大约是1mb。 So I want to record the audio in format of mp3/m4a which takes less space.
所以我想以占用更少空间的mp3/m4a格式录制音频。
Is there any way to record audio in format of mp3/m4a.有没有办法以mp3/m4a的格式录制音频。
Recorder.js does NOT support encoding captured audio as mp3. Recorder.js 不支持将捕获的音频编码为 mp3。
It can only record 16 bit mono or stereo uncompressed pcm as wav.它只能将 16 位单声道或立体声未压缩 pcm 录制为 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:要将大小减半,您可以在 Recorder.js 构造函数中使用
numChannels:1
录制单声道而不是 2 声道/立体声,如下所示:
var rec = new Recorder(source,{numChannels:1})
numChannels
is an undocumented feature of Recorder.js (the library is not maintained anymore). numChannels
是 Recorder.js 的一个未记录功能(该库不再维护)。
Source: https://addpipe.com/blog/using-recorder-js-to-capture-wav-audio-in-your-html5-web-site/来源: https : //addpipe.com/blog/using-recorder-js-to-capture-wav-audio-in-your-html5-web-site/
To record to mp3 you can use:要录制到 mp3,您可以使用:
i think you should check this link : HTML5 record audio to file我想你应该检查这个链接: HTML5 record audio to file
here u can change the audio type like this : type = type ||在这里您可以像这样更改音频类型:type = type || config.type ||
配置类型 || 'audio/wav';
'音频/音频';
You can change the format of the recording by mentioning the format in exportWAV function, as follows:可以通过exportWAV函数中提到格式来改变录音的格式,如下:
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 .我来到了以下链接的上述解决方案。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.