简体   繁体   English

如何以 mp3/m4a 格式录制音频 JavaScript-recorder.js

[英]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,您可以使用:

  1. WebAudioRecorder.js which includes an asm.js version of the LAME mp3 encoder WebAudioRecorder.js ,其中包含LAME mp3 编码器asm.js版本
  2. vmsg which includes a WebAssembly version of the LAME mp3 encoder vmsg包含LAME mp3 编码器的 WebAssembly 版本

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.

相关问题 使用Recorder.js的音频记录中的“获取音频时出错” - “Error getting audio” in audio record using Recorder.js 使用 Recorder.js 和 Flask 录音 - 使用 JavaScript 发布数据 - Audio recording with Recorder.js and Flask - post data using JavaScript 如何在网页上播放.mp3或.m4a音频并同时显示嵌入式专辑封面? (使用Javascript,HTML5或Flash) - How to play a .mp3 or .m4a audio on a webpage and show the embedded album art at the same time? (using Javascript, HTML5, or Flash) JavaScript:如何将音频Blob分成1秒的块并使用recorder.js导出到WAV文件? - JavaScript : How to split an audio blob into 1 second chunks and export to wav files using recorder.js? 如何在服务器上的recorder.js中保存音频文件 - how to save audio file in recorder.js on server 如何使用 recorder.js object 调用此 function “.record()”? - How do I call this function “.record()” with a recorder.js object? Javascript - 从 mp3 文件录制音频 - Javascript - Record audio from mp3 file 如何使用recorder.js将音频文件质量更改为16位,立体声8000 Hz? - How can i change audio file quality to be 16 bit, stereo 8000 Hz using recorder.js? 使用recorder.js以低kbps录制音频 - Recording audio with low kbps using recorder.js Web2py中使用recorder.js的音频录制实现 - Audio recording implementation in web2py using recorder.js
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM