我有一个关于 ffmpeg 的问题。我用 discord.py lib 编写了一个不和谐的机器人,当有人加入频道时它会播放音频。我希望程序在后台在我的计算机上运行,因此不会出现控制台日志。因此,我使用 .bat 和 .vbs 文件启动 python 脚本,因此该进程在后台运行。到目前为止,这工作正常。问题是ffmpeg lib(我假设它是ffmpeg lib ...)在播放音频时在命令提示符中打印出一行(“[mp3 @ 0000020168869040] Estimating duration from bitrate, this may be inaccurate”),所以每次有人加入一个频道时,我的桌面上都会出现一个命令提示符 1 秒,只是为了显示这一行,然后它会关闭,但每次都出现它真的很烦人。我想知道是否有办法阻止 ffmpeg lib 打印出这一行,但我不知道到目前为止。有人可以帮我吗?谢谢饼干
我的代码:
def getAudioSource(source):
audio_source = discord.FFmpegPCMAudio(executable="E:/PythonPrograms/DiscordBotHallo/Dateien/ffmpeg-win64-v4.2.2.exe", source=source)
return audio_source
def getRandomGreeting():
list = os.listdir("E:/PythonPrograms/DiscordBotHallo/Begrüßungen")
Greeting = list[random.randrange(len(list))]
Greeting = "Begrüßungen/" + Greeting
return Greeting
@client.event
async def on_voice_state_update(member, before, after):
if before.channel == None and member.id != 801800464756768768:
greetingPath = getRandomGreeting()
audio_source = getAudioSource(greetingPath)
vc = await after.channel.connect()
vc.play(audio_source)
while vc.is_playing():
await asyncio.sleep(1)
vc.stop()
await vc.disconnect()