Rik*_*ard 9 javascript node.js opus discord.js
我正在尝试将 WAV 文件转换为 Opus,使用 Nodefs.readFile并将该缓冲区传递给@Discord/opus转换器。我既没有得到结果,也没有得到错误的解释以及错误的解释。这基本上是你在文档中的例子......对吗?
漏洞?按设计?还是我错过了什么?我希望会try/catch被调用,但不知何故错误被“吸收”,脚本只是默默退出。
在线示例:https : //codesandbox.io/s/funny-jones-d7sls?file=/src/index.js
const audioBuffer = await fs
.readFile(file)
.catch(err => console.log("Error reading input file:", err));
console.log("LENGTH:", audioBuffer.length); // all good so far...
const encoder = new OpusEncoder(41000, 2);
let encoded = null;
try {
console.log("Trying to encode..."); // log runs
encoded = encoder.encode(audioBuffer);
console.log("Encoded!"); // log doesn't run :(
} catch (err) {
console.log("Encoding failed:", err); // no error thrown... :'(
}
return encoded;
Run Code Online (Sandbox Code Playgroud)
更多细节:
^0.3.2v14.2.0Mac Mojave (10.14.6)repo 中的相关问题:https : //github.com/discordjs/opus/issues/26