Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement a performant alternative to node-opus #3678

Closed
Rantanen opened this issue Jan 12, 2020 · 8 comments
Closed

Implement a performant alternative to node-opus #3678

Rantanen opened this issue Jan 12, 2020 · 8 comments

Comments

@Rantanen
Copy link

Is your feature request related to a problem? Please describe.
node-opus keeps breaking on every other Node.js release due to V8 API changes

Describe the ideal solution
Provide a native alternative for node-opus on top of N-API. I don't expect this to be a difficult task - the (raw) API node-opus provides follows the libopus API closely and the native bits are a very thin wrapper around that API to make it available to JS.

Describe alternatives you've considered
None

Additional context
I'm getting a bit tired of keeping node-opus up to date with the ever changing V8 APIs. Currently I have no intention in making node-opus compatible with the latest Node version (12.x?). It feels like 90%+ of its users are discord bots, so I felt like giving this project a heads up.

@kyranet
Copy link
Member

kyranet commented Jan 13, 2020

It was brought to our attention that opusscript provides an option to run WebAssembly instead of JavaScript to boost all operations, however, we have not benchmarked this.

Are you able to uninstall node-opus and try opusscript (wasm mode is enabled by default), then check if it works and compare it to node-opus in a supported version? Having some metrics about how Wasm performs versus C++ Addons would be interesting.

@Rantanen
Copy link
Author

Are you able to uninstall node-opus and try opusscript (wasm mode is enabled by default),

No, sorry. I wouldn't know where to start. I'm not really a user of discord.js.

Just wanted to notify you that node-opus might not be that great of a long term solution anymore.

@amishshah
Copy link
Member

amishshah commented Jan 13, 2020

Thanks for the heads up @Rantanen. Also a thanks from us and our community for node-opus, it's been massively useful to our users over the years :)

Regarding the benchmarks, I ran a rough one and found that to process a 3 minute 20 seconds audio file:

  • node-opus takes about 2 seconds
  • opusscript (wasm) takes about 4 seconds
  • opusscript (no wasm) takes about 24 seconds

I think for most users, using opusscript instead of node-opus will be perfectly fine for the time being! You can get the wasm version of opusscript by just making sure you are using at least Node 8 and have the latest opusscript installed 👍

@Rantanen
Copy link
Author

Good to hear! I'm sure the wasm version is easier to maintain and breaks less often too!

@devsnek
Copy link
Member

devsnek commented Jan 13, 2020

@Rantanen if V8 breakage is the problem, you might want to look at n-api. it's ABI stable across all versions of node that have it. There is also a C++ wrapper available.

@Rantanen
Copy link
Author

@devsnek Yeah, that would be a solution, like mentioned in the original issue. Unfortunately I don't really have interest in putting that effort into node-opus anymore. :(

I feel like the NodeJS community would be better served by an Opus implementation that has an author who actually wants to provide a good NodeJS Opus implementation instead of one that just wants open GitHub issues to go away. :)

@iCrawl
Copy link
Member

iCrawl commented Jan 15, 2020

Thank you for your efforts @Rantanen!

I took the task and rewrote it here: https://github.com/discordjs/opus

Since I based this off your code (not that there was a lot, like you said its a very thin wrapper to begin with) I made sure to put you into the copyright notice.

@Rantanen
Copy link
Author

Took me this long to finally do it but it's official now. The Rantanen/node-opus repository has been archived, the npm package has been deprecated and it's directing people to use @discordjs/opus instead.

Thanks @iCrawl for implementing the N-API alternative! ❤️

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Apr 16, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants