Процесс ffmpeg 20564 успешно завершен с кодом возврата 3436169992Python

Программы на Python
Ответить Пред. темаСлед. тема
Anonymous
 Процесс ffmpeg 20564 успешно завершен с кодом возврата 3436169992

Сообщение Anonymous »

Пытаюсь воспроизвести видео с YouTube в виде аудио через бот Discord. Я столкнулся с запрещенной ошибкой 403 и добавил YDL_OPTIONS, чтобы обойти ее. Теперь выдает код ошибки 3436169992. Бот пишет на сервер «сейчас играет: xxxx», но звук не воспроизводится. Есть какие-нибудь подсказки?
FFMPEG_OPTIONS = {
"before_options": "-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5",
"options": "-vn -filter:a \"volume=0.25\""
}

# yt-dlp options
YDL_OPTIONS = {
"format": "bestaudio[ext=webm][acodec=opus]/bestaudio",
"noplaylist": True,
"quiet": True,
"extract_flat": False,
"no_warnings": True,
"source_address": "0.0.0.0" # Prevents YouTube throttling
}

voice_clients = {}

@bot.event
async def on_message(message):
if message.content.startswith("-play"):
try:
# Ensure the user is in a voice channel
if not message.author.voice:
await message.channel.send("You need to be in a voice channel to use this command.")
return

# Connect to the user's voice channel if not already connected
if message.guild.id not in voice_clients or not voice_clients[message.guild.id].is_connected():
voice_client = await message.author.voice.channel.connect()
voice_clients[message.guild.id] = voice_client
else:
voice_client = voice_clients[message.guild.id]

# Extract the YouTube URL from the command
url = message.content.split()[1]

# Download and extract audio using yt-dlp
with YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
audio_url = info["url"]
title = info.get("title", "Unknown Title")

# Debug: Print the extracted audio URL
print(f"Audio URL: {audio_url}")

# Play the audio using FFmpeg
source = FFmpegPCMAudio(audio_url, **FFMPEG_OPTIONS)
voice_client.play(source, after=lambda e: print("Playback finished."))

# Notify the user
await message.channel.send(f"Now playing: {title}")

except Exception as e:
print(f"Error: {e}")
await message.channel.send("An error occurred while trying to play the audio.")


Подробнее здесь: https://stackoverflow.com/questions/793 ... 3436169992
Реклама
Ответить Пред. темаСлед. тема

Быстрый ответ

Изменение регистра текста: 
Смайлики
:) :( :oops: :roll: :wink: :muza: :clever: :sorry: :angel: :read: *x)
Ещё смайлики…
   
К этому ответу прикреплено по крайней мере одно вложение.

Если вы не хотите добавлять вложения, оставьте поля пустыми.

Максимально разрешённый размер вложения: 15 МБ.

  • Похожие темы
    Ответы
    Просмотры
    Последнее сообщение

Вернуться в «Python»