Wav to Opus convertion with Discord.js/opus fails silently

安稳与你 提交于 2020-07-08 10:23:07

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!