【发布时间】:2013-07-06 01:38:46
【问题描述】:
我正在尝试从浏览器捕获用户的音频输入。我已经用 WAV 完成了,但是文件真的很大。我的一个朋友告诉我,OGG 文件要小得多。 有谁知道如何将WAV转换为OGG? 我也有原始数据缓冲区,我真的不需要转换。但我只需要OGG编码器。
这是来自Matt Diamond's RecorderJS 的 WAV 编码器:
function encodeWAV(samples){
var buffer = new ArrayBuffer(44 + samples.length * 2);
var view = new DataView(buffer);
/* RIFF identifier */
writeString(view, 0, 'RIFF');
/* file length */
view.setUint32(4, 32 + samples.length * 2, true);
/* RIFF type */
writeString(view, 8, 'WAVE');
/* format chunk identifier */
writeString(view, 12, 'fmt ');
/* format chunk length */
view.setUint32(16, 16, true);
/* sample format (raw) */
view.setUint16(20, 1, true);
/* channel count */
view.setUint16(22, 2, true);
/* sample rate */
view.setUint32(24, sampleRate, true);
/* byte rate (sample rate * block align) */
view.setUint32(28, sampleRate * 4, true);
/* block align (channel count * bytes per sample) */
view.setUint16(32, 4, true);
/* bits per sample */
view.setUint16(34, 16, true);
/* data chunk identifier */
writeString(view, 36, 'data');
/* data chunk length */
view.setUint32(40, samples.length * 2, true);
floatTo16BitPCM(view, 44, samples);
return view;
}
OGG 有吗?
【问题讨论】:
-
我从 vorbis 找到了 .ogg 编码器源代码。但是在 JS 中什么都没有,我不能在 JS 中使用相同的算法来做到这一点
-
+1 因为没有必要对此投反对票。
-
+1 同意。这对谁有帮助?
-
谢谢你们。对 stackoverflow.com 的信任已恢复!
-
i got off the internet是work by Matt Diamond