在Chrome中使用MediaRecorder记录为Ogg [英] Record as Ogg using MediaRecorder in Chrome

查看:463
本文介绍了在Chrome中使用MediaRecorder记录为Ogg的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有一种方法可以在使用MediaRecorder时在Chrome中记录ogg格式?我相信,Chrome默认情况下支持WebM.以下是我的工作

Is there a way we could record ogg format in Chrome while working with MediaRecorder ? I believe, Chrome by default supports WebM. Following is what I do

    navigator.mediaDevices.getUserMedia({ audio: true })
    .then(stream => {
        rec = new MediaRecorder(stream);

        rec.ondataavailable = e => {
            audioChunks.push(e.data);
            if (rec.state == "inactive")
            {
                let blob = new Blob(audioChunks, { 'type': 'audio/ogg; codecs=opus' });
            }
        };

    })
    .catch(e => console.log(e));

推荐答案

此处的受支持格式列表中,似乎没有.

From the list of supported formats here, it appears it does not.

但是,这里有一些库可以帮助您记录为其他格式:

However, here are some libraries that help you record to alternative formats:

格式(Container.Codec):Ogg.Opus,WebM.Opus,WAV.PCM
浏览器:Chrome,Firefox,Safari,Edge

Formats (Container.Codec): Ogg.Opus, WebM.Opus, WAV.PCM
Browsers: Chrome, Firefox, Safari, Edge

注意:不允许您将Opus录制的采样率从默认的48000hz更改. (例如,这意味着它的输出不能直接提交给 DialogFlow ,因为它的输出

Note: Does not let you change the sampling rate for Opus recording from the default of 48000hz. (For example, this means its output can't directly be submitted to DialogFlow, since it requires Opus audio to have a sample rate of 16000hz.)

格式:Ogg.Opus,WAV.PCM
浏览器:Chrome,Firefox,Safari,Opera,Edge

Formats: Ogg.Opus, WAV.PCM
Browsers: Chrome, Firefox, Safari, Opera, Edge

3)LibFlac: https://github.com/mmig/libflac.js

格式:FLAC.FLAC
浏览器:(未知,但可能与上面相同)

Formats: FLAC.FLAC
Browsers: (unknown, but probably same as the above)

有关如何与麦克风输入配合使用的信息,请参见语音转换示例

See the speech-to-flac example for how to use with microphone input.

格式:Ogg.Vorbis,MP3.MP3,WAV.PCM
浏览器:(未知,但可能与上面相同)

Formats: Ogg.Vorbis, MP3.MP3, WAV.PCM
Browsers: (unknown, but probably same as the above)

5)带WAV/PCM支持的增强MediaRecorder的库

A: https://github.com/muaz-khan/RecordRTC (recorderType :RecordRTC.StereoAudioRecorder)
B: https://github.com/streamproc/MediaStreamRecorder (mimeType:"audio/wav"或音频/pcm")

5) Libraries augmenting MediaRecorder with WAV/PCM support

A: https://github.com/muaz-khan/RecordRTC (recorderType: RecordRTC.StereoAudioRecorder)
B: https://github.com/streamproc/MediaStreamRecorder (mimeType: "audio/wav" or "audio/pcm")

对于WAV.PCM,格式足够简单,您不需要库.如果您喜欢较低级别"的方法,则可以在此处查看示例: https://stackoverflow.com/a/54213814/2441655

For WAV.PCM, the format is simple enough you don't necessarily need a library. If you prefer a "lower level" approach, you can look through the examples here: https://stackoverflow.com/a/54213814/2441655

这篇关于在Chrome中使用MediaRecorder记录为Ogg的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆