gpt4 book ai didi

ffmpeg - 属性错误 : 'FFmpegPCMAudio' object has no attribute '_process'

转载 作者:行者123 更新时间:2023-12-04 23:10:42 25 4
gpt4 key购买 nike

我正在尝试制作一个不和谐的音乐机器人,这是我的播放功能:

async def play(self, ctx, url):
ctx.voice_client.stop()
FFMPEG_OPTIONS = {'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'option': '-vn'}
YDL_OPTIONS = {'format': 'bestaudio'}

voice = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
url2 = info['formats'][0]['url']

voice.play(discord.FFmpegPCMAudio(url2, **FFMPEG_OPTIONS))
但是当我运行代码时,出现以下错误:
[youtube] MbhXIddT2YY: Downloading webpage
Exception ignored in: <function AudioSource.__del__ at 0x7f1fca7373a0>
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 103, in __del__
self.cleanup()
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/player.py", line 154, in cleanup
proc = self._process
AttributeError: 'FFmpegPCMAudio' object has no attribute '_process'
Ignoring exception in command play:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 85, in wrapped
ret = await coro(*args, **kwargs)
File "/home/runner/Myoojic-Baat/music.py", line 42, in play
voice.play(discord.FFmpegPCMAudio(url2, **FFMPEG_OPTIONS))
TypeError: __init__() got an unexpected keyword argument 'option'

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/bot.py", line 939, in invoke
await ctx.command.invoke(ctx)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 863, in invoke
await injected(*ctx.args, **ctx.kwargs)
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/commands/core.py", line 94, in wrapped
raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: __init__() got an unexpected keyword argument 'option'
我发现了一个有类似错误的相关帖子: AttributeError: 'FFmpegPCMAudio' object has no attribute 'start'
但是那里的解决方案并没有解决我的问题。

最佳答案

FFMPEG_OPTIONS对象应该是 'options': '-vn'不是 'option':'-vn' .

关于ffmpeg - 属性错误 : 'FFmpegPCMAudio' object has no attribute '_process' ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/69211936/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com