serenity-rs / songbird

An async Rust library for the Discord voice API
ISC License
384 stars 110 forks source link

Bot not playing any audio, silent-failure (no error) #155

Closed interacsion closed 1 year ago

interacsion commented 1 year ago

I am running the https://github.com/serenity-rs/songbird/tree/a85a1f08e15541eed9ea026423d9ed6697f390ec/examples/serenity/voice example. The bot doesn't play anything when I run ~join then ~play <url>

Before Edit: I am trying to use songbird with a poise bot I am working on, but it doesn't play any audio when I call the following: ```rs let source = songbird::ytdl(url).await.unwrap(); let (call, _) = songbird::get(context) .await .unwrap() .join(guild_id, channel_id) .await; call.lock().await.play_source(source); ``` songbird is registered using the following: ```rs poise::Framework::builder() ... .client_settings(|client| client.register_songbird()) ... ``` serenity is using the following features: `rustls_backend`, `client`, `gateway`, `model`, `builder`, `voice`, `cache`
Environment Rust version: 1.65.0 Serenity version: 0.11.5 Songbird version: 0.3.0 FFMPEG version: 2022-11-28 youtube-dl version: 2021.12.17
interacsion commented 1 year ago

Updated issue description ^

FelixMcFelix commented 1 year ago

I think your issue must lie somewhere on your system; going back to songbird v0.3 and using the builtin example works without issues for me (same youtube-dl version, only difference is I have an older ffmpeg). Do you see anything indicative if you set up a log subscriber and configure RUST_LOG=error?

interacsion commented 1 year ago
Dec 10 12:40:04.590  INFO runner: songbird::driver::tasks::events: Event state for track 1 added
Dec 10 12:40:06.772  INFO runner: songbird::events::store: Firing End for [0]
Dec 10 12:40:06.772  INFO runner: songbird::driver::tasks::events: Event state for track 0 of 1 removed.

Note the timestamps. these follow each other almost instantly. and no audio plays.

FelixMcFelix commented 1 year ago

What's basically happening here, from what I can see, is that: 1) The process chain to download/convert a track is happening without issue (or you'd fail before the .play_source). Main takeaway is that ffmpeg, youtube-dl are on the path. 2) The track is set to play, then the mixer reads 0 audio bytes (indicating that ffmpeg or youtube-dl have sent an end-of-file). The track is then discarded because it has either finished or hit an error.

If you could try out the process chain manually, that might be more helpful? E.g., unpacking this code a bit:

youtube-dl --print-json -f webm[abr>0]/bestaudio/best -R infinite --no-playlist --ignore-config --no-warnings "YOUR_URL_HERE" -o test.1

ffmpeg -i test.1 -f s16le -ac 2 -ar 48000 -acodec pcm_f32le - > test.2

I've updated my local ffmpeg and I'm getting no issues, so that's not it. Can you tell me if you get any errors from the above?

interacsion commented 1 year ago

Not getting any errors. (youtube-dl prints a very long json string, but I don't think there are any errors in it.) I took a look at both the files. test.1 plays without any problems using VLC, while test.2 is 0 bytes, is my ffmpeg broken?

interacsion commented 1 year ago

It seems it was broken. after reinstalling the latest version of ffmpeg it now works.