我想用 Node.js 读取一个 audi 文件,将其解码为 PCM 并将其编码为 MP3。我正在使用 node-lame 进行编码/解码,但不幸的是我收到以下错误:
/Users/Jon/streaming test/node_modules/lame/lib/encoder.js:191
write(output);
^
TypeError: string is not a function
at cb (/Users/Jon/streaming test/node_modules/lame/lib/encoder.js:191:7)
我的编码和解码代码:
var filename = './beautifullie.mp3';
var decoder = lame.Decoder();
var encoder = lame.Encoder({channels: 2, bitDepth: 16, sampleRate: 44100});
fs.createReadStream(filename).pipe(decoder);
decoder.on('format', function(format) {
console.log('Decoding .. '+JSON.stringify(format));
decoder.pipe(encoder);
});
encoder.on("data", function(data) {
console.log('Sending..');
//sendData(data);
});
您可以在此处找到引发错误的文件:https ://github.com/TooTallNate/node-lame/blob/master/lib/encoder.js