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
AudioOutStream hangs when being written to #1008
Comments
I have been using ffmpeg for my conversion too. It has to do with having to both read and write iirc. Basically when you copy to ffmpeg it immediately tries to write to stdout (which has been redirected by your process I'm assuming). However this is blocked since a copy operation to stdin of ffmpeg is occurring. The solution I found is to |
@LDSpits It's odd because even when I write other data (not from ffmpeg) it still seems to hang. Also, it hangs on writing to the Discord stream (which seems independent of ffmpeg's process). Also, can you provide me with some code? I'm not sure what you mean by copying async with both streams. |
Hi There, Can we see how you've rigged up your ffmpeg process please? Also, if you're planning on using a buffer for read/write operations, you're buffer count is way too high. Should be 48000 = Sample Frequency. Should be the same on your FFMPEG options. FFMPEG should be encoding to PCM (s16le) too. |
Here's the code for
Also, thanks for the information about the buffer size, though I was using that simply to try and figure out what was causing the issue. |
Hi There, That Other than that, I'm starting to run out of possible ideas. :( |
@ComputerMaster1st Awaiting the |
Check the file path. If the mp3 is in your project's root directory (same directory where your code is for dotnet core), then just use |
@ComputerMaster1st Putting the file in the root directory as well as eliminating spaces from the file path does nothing no matter the quotations or not. |
Ok, I have one more possible solution... Do you have libsodium.dll & opus.dll downloaded & placed within your project's root directory? |
Native builds (be sure to rename |
Hmm... redownloading the libraries actually did help. I am now able to play a short (5 second long) MP3 file over Discord. However, when I attempt to play larger files, nothing is outputted to the Discord channel, seemingly bringing me back to the previous situation. I'm going to try and play some other audio files. Perhaps ffmpeg doesn't like these..? |
Wonderful! This issue seems to be resolved by getting the correct audio libraries. If it's possible, though, I would appreciate if the documentation was updated with that flow chart and link because I wan't sure where to get the libraries. Sometimes there's still silence, but re-opening the program solves that, so it's probably an unrelated issue. Thanks for the help, everyone. |
I've been playing around with Discord.NET's audio functionalities, and I'm trying to play an MP3 file on an audio channel. The bot connects to the channel successfully, however, no sound occurs. After further investigation (and a couple hours of headache) it seems that writing to the AudioOutStream hangs when a certain amount has been written to it. Here's some code:
The problem is, according to the debugger when using the
CopyStream
method, seems to be thatoutput.Write()
simply hangs and doesn't return.CopyToAsync()
doesn't work either, probably for the same underlying reasons. I can stream data from the ffmpeg process just fine, it's simply that writing it doesn't work and no sound comes through to the Discord channel. I have no idea how to solve this.The text was updated successfully, but these errors were encountered: