From 5f6d948da32bd35422cb2e4364514cecbd2fd0a1 Mon Sep 17 00:00:00 2001 From: Elysia <71698422+aiko-chan-ai@users.noreply.github.com> Date: Mon, 29 Jul 2024 20:56:50 +0700 Subject: [PATCH] fix connection --- src/client/voice/player/MediaPlayer.js | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/src/client/voice/player/MediaPlayer.js b/src/client/voice/player/MediaPlayer.js index 4a1b36e..b3de1e6 100644 --- a/src/client/voice/player/MediaPlayer.js +++ b/src/client/voice/player/MediaPlayer.js @@ -74,6 +74,17 @@ class MediaPlayer extends EventEmitter { const args = isStream ? FFMPEG_ARGUMENTS.slice() : ['-i', input, ...FFMPEG_ARGUMENTS]; if (options.seek) args.unshift('-ss', String(options.seek)); + args.unshift( + '-reconnect', + '1', + '-reconnect_at_eof', + '1', + '-reconnect_streamed', + '1', + '-reconnect_delay_max', + '4294', + ); + const ffmpeg = new prism.FFmpeg({ args }); streams.ffmpeg = ffmpeg; if (isStream) { @@ -135,6 +146,18 @@ class MediaPlayer extends EventEmitter { if (options.seek) args.unshift('-ss', String(options.seek)); + // Fix connection + args.unshift( + '-reconnect', + '1', + '-reconnect_at_eof', + '1', + '-reconnect_streamed', + '1', + '-reconnect_delay_max', + '4294', + ); + // Get stream type if (this.voiceConnection.videoCodec == 'VP8') { args.push('-f', 'ivf', '-deadline', 'realtime', '-c:v', 'libvpx');