FFMPEG(?)错误:[out#0/s16le @ 000002452f906a00] 输出文件不包含任何流

问题描述 投票:0回答:1
FFMPEG_OPTIONS = {
    'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
    'options': '-vn'}
YDL_OPTIONS = {
    'format': 'bestaudio/best',
    'extractaudio': True,
    'noplaylist': True,
    'simulate': 'True',
    'preferredquality': '192',
    'preferredcodec': 'mp3',
    'key': 'FFmpegExtractAudio'}
@bot.command(aliases=['Ping', 'PING', 'Пинг', 'ПИНГ', 'зштп', 'ЗШТП', 'Зштп',
                      'пинг'])
async def ping(ctx):
    await ctx.message.reply(f'Ping: {round(bot.latency * 1000)}ms')
#########################[PLAY MUSIC BLOCK]#########################
@bot.command()
async def add(ctx, *url):
    url = ' '.join(url)
    with yt_dlp.YoutubeDL(YDL_OPTIONS) as ydl:
        try:
            info = ydl.extract_info(url, download=False)
        except:
            info = ydl.extract_info(f"ytsearch:{url}",
                                    download=False)['entries'][0]

    URL = info['formats'][0]['url']
    name = info['title']
    time = str(datetime.timedelta(seconds=info['duration']))
    songs_queue.q_add([name, time, URL])
    embed = nextcord.Embed(description=f'Записываю [{name}]({url}) в очередь 📝',
                           colour=nextcord.Colour.red())
    await ctx.message.reply(embed=embed)
def step_and_remove(voice_client):
    if loop_flag:
        songs_queue.q_add(songs_queue.get_value()[0])
    songs_queue.q_remove()
    audio_player_task(voice_client)
def audio_player_task(voice_client):
    if not voice_client.is_playing() and songs_queue.get_value():
        voice_client.play(nextcord.FFmpegPCMAudio(
            executable="ffmpeg\\bin\\ffmpeg.exe",
            source=songs_queue.get_value()[0][2],
            **FFMPEG_OPTIONS),
            after=lambda e: step_and_remove(voice_client))
@bot.command(aliases=['Play', 'PLAY', 'играй', 'ИГРАЙ', 'Играй', 'сыграй',
                      'Сыграй', 'СЫГРАЙ', 'здфн', 'Здфн', 'ЗДФН', 'p', 'P',
                      'pl', 'PL', 'Pl', 'Плей',
                      'ПЛЕЙ', 'плей'])
async def play(ctx, *url):
    await join(ctx)
    await add(ctx, ' '.join(url))
    await ctx.message.add_reaction(emoji='🎸')
    voice_client = ctx.guild.voice_client
    audio_player_task(voice_client)
@bot.command(aliases=['Queue', 'QUEUE', 'йгугу', 'Йгугу', 'ЙГУГУ', 'очередь',
                      'Очередь', 'ОЧЕРЕДЬ', 'список', 'Список', 'СПИСОК',
                      'list', 'List', 'LIST', 'дшые', 'Дшые', 'ДШЫЕ', 'Лист',
                      'лист', 'ЛИСТ', 'песни', 'Песни', 'ПЕСНИ', 'songs',
                      'Songs', 'SONGS', 'ыщтпы', 'ЫЩТПЫ', 'Ыщтпы', 'q'])
async def queue(ctx):
    if len(songs_queue.get_value()) > 0:
        only_names_and_time_queue = []
        for i in songs_queue.get_value():
            name = i[0]
            if len(i[0]) > 30:
                name = i[0][:30] + '...'
            only_names_and_time_queue.append(f'📀 `{name:<33}   {i[1]:>20}`\n')
        c = 0
        queue_of_queues = []
        while c < len(only_names_and_time_queue):
            queue_of_queues.append(only_names_and_time_queue[c:c + 10])
            c += 10

        embed = nextcord.Embed(title=f'ОЧЕРЕДЬ [LOOP: {loop_flag}]',
                               description=''.join(queue_of_queues[0]),
                               colour=nextcord.Colour.red())
        await ctx.send(embed=embed)

        for i in range(1, len(queue_of_queues)):
            embed = nextcord.Embed(description=''.join(queue_of_queues[i]),
                                   colour=nextcord.Colour.red())
            await ctx.send(embed=embed)
    else:
        await ctx.send('Очередь пуста')

Discord 中有我的音乐机器人的一部分,我真的不知道为什么它不起作用。实际上,我尝试使用某人的旧代码,因此需要修复它。我已经删除了代码中最重要的部分,这些部分很可能有错误。 我发现了其他问题,但还有另一个错误。 尝试启动视频后,出现以下错误: [out#0/s16le @ 000002452f906a00] 输出文件不包含任何流 打开输出文件管道时出错:1。 打开输出文件时出错:参数无效

python ffmpeg discord video-streaming
1个回答
0
投票

我的朋友帮助我找到了解决方案。 我需要将“info['formats'][0]['url']”更改为info['url']并更改YDL_OPTIONS

YDL_OPTIONS = {
    'format': 'bestaudio/best',
    'extractaudio': True,
    'noplaylist': True,
    'keepvideo': False,
    'postprocessors': [{
        'key': 'FFmpegExtractAudio',
        'preferredcodec': 'mp3',
        'preferredquality': '320'
    }]
}
© www.soinside.com 2019 - 2024. All rights reserved.