8
与使用AudioContext的JavaScript音频混合已达到和导出音频混合我使用OfflineAudioContext和n,跛脚js编码解码音频,现在的expoort工作正常,但它是非常慢,我期待一个有效的方式来做到这一点比现在更快。上述如何将arrayBuffer转换为mp3音频?
与使用AudioContext的JavaScript音频混合已达到和导出音频混合我使用OfflineAudioContext和n,跛脚js编码解码音频,现在的expoort工作正常,但它是非常慢,我期待一个有效的方式来做到这一点比现在更快。上述如何将arrayBuffer转换为mp3音频?
https://github.com/TooTallNate/node-lame
是跛编码器,其确实的PCM数据的编码处理。
检查此[线程] [1]
document.querySelector('input').onchange = function(){
var fileReader = new FileReader;
fileReader.onload = function(){
var arrayBuffer = this.result;
snippet.log(arrayBuffer);
snippet.log(arrayBuffer.byteLength);
}
fileReader.readAsArrayBuffer(this.files[0]);
var url = URL.createObjectURL(this.files[0]);
audio_player.src = url;
audio_player.play();
};
<!-- Provides the `snippet` object, see http://meta.stackexchange.com/a/242144/134069 -->
<script src="http://tjcrowder.github.io/simple-snippets-console/snippet.js"></script>
<input id="audio_file" type="file" accept="audio/*" />
<audio id="audio_player" />
目前没有更好的跨浏览器方式来做到这一点。您可以考虑使用OGG([Firefox可以本地录制到OGG](https://www.webrtc-experiment.com/RecordRTC/AudioVideo-on-Firefox.html)),Chrome将需要[JS OGG编码器]( https://github.com/astroza/chrome_ogg_encoder))。编码MP3的最快方法是使用[PNACL](http://www.chromium.org/nativeclient/pnacl/introduction-to-portable-native-client)和[NACLPorts Lame](https://github.com) /anvio/naclports/tree/master/libraries/lame-3.99-5),但它仅限于Chrome和非平凡! – CodingIntrigue
没有自己测试,但根据LameJS项目,它应该运行“比实时快20倍”。查看代码,它似乎利用JavaScript的“Float32Array”。我会检查您的浏览器是否支持该技术,以及它是否支持基于GPU的基于矩阵乘法的WebGL(它可能会)。如果没有,我会尝试使用浏览器,然后检查速度。 –
你可以看看使用emscripten并编译跛脚编码器源。不知道如何解决你的问题,这可能比它对你更有价值。 – Goblinlord