问题
I am trying to convert a WAV file to Opus, using Node's fs.readFile
and passing that buffer to @Discord/opus
converter. I get neither the result or a error thrown with a explanation of what is wrong. This is basically the example you have in the docs... right?
Bug? By design? or me missing something?
I would expect the try/catch
to be called but somehow the error is "absorbed" and the script just exits silently.
Online example: 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;
Further details:
- @discordjs/opus version:
^0.3.2
- Node.js version:
v14.2.0
- Operating system:
Mac Mojave (10.14.6)
Related issue in repo: https://github.com/discordjs/opus/issues/26
来源:https://stackoverflow.com/questions/62681986/wav-to-opus-convertion-with-discord-js-opus-fails-silently