访问浏览器音频编解码器进行编码
accessing browser audio codecs for encoding
来自文档 (here):
The decodeAudioData() method of the BaseAudioContext Interface is used to asynchronously decode audio file data contained in an ArrayBuffer.
ctx.decodeAudioData(audioData).then(function(decodedData) {
// use the decoded data here
});
我的问题是我们能否访问浏览器的音频编解码器以执行编码而不是解码(即转换原始 pcm -> flac/opus/mp3 等)?
不幸的是,这还不可能。目前有一个新的 API 或一组名为 WebCodecs 的 API 的提案,它可能会在未来支持该用例。
在那之前,我能想到的编码音频的唯一本地方法是使用 MediaRecorder
。但它不能用于准确编码 AudioBuffer
,因为它是 start()
和 stop()
方法不精确。
来自文档 (here):
The decodeAudioData() method of the BaseAudioContext Interface is used to asynchronously decode audio file data contained in an ArrayBuffer.
ctx.decodeAudioData(audioData).then(function(decodedData) {
// use the decoded data here
});
我的问题是我们能否访问浏览器的音频编解码器以执行编码而不是解码(即转换原始 pcm -> flac/opus/mp3 等)?
不幸的是,这还不可能。目前有一个新的 API 或一组名为 WebCodecs 的 API 的提案,它可能会在未来支持该用例。
在那之前,我能想到的编码音频的唯一本地方法是使用 MediaRecorder
。但它不能用于准确编码 AudioBuffer
,因为它是 start()
和 stop()
方法不精确。