Discord Bot Music (discord.py) - ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one. How to fix on Pycharm
Discord Bot Music (discord.py) - ERROR: ffprobe/avprobe and ffmpeg/avconv not found. Please install one. How to fix on Pycharm
致敬。我正在尝试在 discord 上创建一个音乐机器人,当我尝试下载时它会警告我错误。由于我使用 pycharm 许多解决方案不适合我或不起作用,我不知道该怎么做。
这里的代码:
@client.command()
async def play(ctx, url : str):
song_there = os.path.isfile("song.mp3")
try:
if song_there:
os.remove("song.mp3")
except PermissionError:
await ctx.send("Wait for the current playing music to end or use the 'stop' command")
return
voiceChannel = discord.utils.get(ctx.guild.voice_channels, id=638017907791626250)
await voiceChannel.connect()
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
for file in os.listdir("./"):
if file.endswith(".mp3"):
os.rename(file, "song.mp3")
voice.play(discord.FFmpegPCMAudio("song.mp3"))
我解决了:只需下载构建 (windows link: https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z) 并提取 ffmpeg.exe
, ffplay.exe
和 ffprobe.exe
并将它们放在我们项目文件夹
中的 scripts
文件夹中
致敬。我正在尝试在 discord 上创建一个音乐机器人,当我尝试下载时它会警告我错误。由于我使用 pycharm 许多解决方案不适合我或不起作用,我不知道该怎么做。 这里的代码:
@client.command()
async def play(ctx, url : str):
song_there = os.path.isfile("song.mp3")
try:
if song_there:
os.remove("song.mp3")
except PermissionError:
await ctx.send("Wait for the current playing music to end or use the 'stop' command")
return
voiceChannel = discord.utils.get(ctx.guild.voice_channels, id=638017907791626250)
await voiceChannel.connect()
voice = discord.utils.get(client.voice_clients, guild=ctx.guild)
ydl_opts = {
'format': 'bestaudio/best',
'postprocessors': [{
'key': 'FFmpegExtractAudio',
'preferredcodec': 'mp3',
'preferredquality': '192',
}],
}
with youtube_dl.YoutubeDL(ydl_opts) as ydl:
ydl.download([url])
for file in os.listdir("./"):
if file.endswith(".mp3"):
os.rename(file, "song.mp3")
voice.play(discord.FFmpegPCMAudio("song.mp3"))
我解决了:只需下载构建 (windows link: https://www.gyan.dev/ffmpeg/builds/ffmpeg-git-full.7z) 并提取 ffmpeg.exe
, ffplay.exe
和 ffprobe.exe
并将它们放在我们项目文件夹
scripts
文件夹中