Rapptz / discord.py

An API wrapper for Discord written in Python.
http://discordpy.rtfd.org/en/latest
MIT License
14.73k stars 3.74k forks source link

FFmpegPCMAudio has stopped working recently #1974

Closed Yureien closed 3 years ago

Yureien commented 5 years ago

Summary

Recently, the music feature stopped working by itself without any change in the code of my discord bot. I tried updating all the libraries but could not fix it. Before this, it worked fine.

Reproduction Steps

Here is the actual code for the bot: https://github.com/FadedCoder/PinocchioBot/blob/master/music/functions.py#L41

And this is the major snippet:

    ...
    source = discord.PCMVolumeTransformer(
        discord.FFmpegPCMAudio(
            music.stream_url,
            before_options="-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5"),
        volume=guild_state.volume)

    def after_finished(err):
        asyncio.run_coroutine_threadsafe(
            _play_music(message, voice_client, guild_state),
            voice_client.loop)

    await message.channel.send("Now Playing", embed=embed)
    if voice_client.is_playing():
        voice_client.stop()
        voice_client.play(source, after=after_finished)

This is the part of the code that pulls the audio from Youtube-DL and sends it to the client. I can confirm that youtube-dl is working properly as I can get the streaming URL for the music.

Expected Results

Music to play, instead it remains quiet.

Actual Results

INFO:discord.voice_client:Voice handshake complete. Endpoint found singapore291.discord.gg (IP: 161.202.204.222)
INFO:discord.gateway:selected the voice protocol for use (xsalsa20_poly1305_suffix)
INFO:discord.gateway:received secret key for voice connection
INFO:discord.player:Preparing to terminate ffmpeg process 31618.
INFO:discord.player:ffmpeg process 31618 has not terminated. Waiting to terminate...
INFO:discord.player:ffmpeg process 31618 should have terminated with a return code of -9.

This is the output. For some reason, ffmpeg is terminating before playing anything.

Checklist

System Information

Rapptz commented 5 years ago

I don't believe this is a bug that I can deal with.

FFmpegPCMAudio.cleanup is called whenever we're done reading from the process or it errors out. How it got to that state is outside of the library's scope.

kytpbs commented 1 year ago

I don't think this helps but i have gotten the same issue

the numbers changing everytime

discord.player:ffmpeg process 21112 has not terminated. Waiting to terminate...
discord.player: ffmpeg process 21112 should have terminated with a return code of 1.