Playing a specific YouTube video from a Bot

Hi, I’m trying to create a command that plays audio from a specific YouTube video for 4 seconds and then leaves. I have the timing commands right, but the audio just doesn’t want to play, and I can’t discern why. After hours of research, I came up with some code, but it returns the error:

"<YouTube Link>: Invalid data found when processing input"

I can’t tell what’s wrong, or how to get audio playing in the first place. I also tried installing ffmpeg both through pip and through direct download, but I can’t get that to work. If someone could help, that would be great, thanks in advance.

async def join(ctx):
user =
channel =
await channel.connect()

guild = ctx.guild
voice_client: discord.VoiceClient = discord.utils.get(client.voice_clients, guild=guild)
audio_source = discord.FFmpegPCMAudio('insert video here')
if not voice_client.is_playing():, after=None)

await asyncio.sleep(4)
await ctx.voice_client.disconnect()


do you still need help? i found a solution

I have same issue Could you tell me the solution?

I found the solution.

replace the url link of the video that you want to play with this code

audio_source = discord.FFmpegPCMAudioexecutable="C:/ffmpeg/bin/ffmpeg.exe", source="C:<path_to_file>"

make sure you install ffmpeg correctly and pathing etc. etc.

i hope it helps someone