-
Notifications
You must be signed in to change notification settings - Fork 40
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
use ffmpeg for opus encoding #11
Comments
It's a great idea, but I think it should just be another example repo. This repo specifically needs to almost be removed and re-wrote if anything. But I'd hate to make such an API change to it since I know folks are using it. Make a nice repo and tag it with discordgo :) I can add it to the discordgo wiki too. I think one downfall of the ffmpeg route is you loose some of the config options possible for opus, right? Like VBA vs Constant and maybe some other things? But, it is a nice way of doing it. Less complicated. I think the best thing about .dca is really that you can pre-encode the files in advance for things you play often and save them in .dca files that are ready to play. |
@nhooyr, hey did you ever end up making a repo with using ffmpeg to encode with gopus directly? thanks 👍 |
Unfortunately I gave up on this. |
ah okie that's a shame, but thanks anyways! 👍 |
Going to close as it has been a long time and I'm not sure if this is relevant anymore. |
@nhooyr I am working something similar, did you find something ? |
Nope, never ended up continuing with my project. |
I've been writing a discord bot in elixir using this library https://github.com/cronokirby/alchemy
Unlike this library where an opus library is used, the author uses ffmpeg for opus encoding directly from the file stream. In order to do this, ffmpeg has to be compiled with libopus support. On macOS, its as simple as
brew install ffmpeg --with-opus
.I've ported it over to Go. It's very crude and only for demonstration purposes but it works really well and eliminates the need for a executable like dca-rs or a go opus library.
https://github.com/nhooyr/botatouille/blob/7e1cd9d5a8d517fd43fd11599b2a62bf832a5c96/cmd/botatouille/music/music.go#L62-L104
Only issue is that if the goroutine reading from ffmpeg's stdout ever falls behind ffmpeg, it may read more than a single frame. Then it will try and send more than a single frame to discord which will cause the audio to get completely screwed up. I wanted to know if you think there is any way to fix this.
I think its highly unlikely because the goroutine has its own thread and is only reading from ffmpeg and not doing anything else but I'm not 100% sure. What do you think?
If you like this method, I can incorporate it into this library.
The text was updated successfully, but these errors were encountered: