From f9b5cead31d56afb4a876397e09fec1f1d0c9f0d Mon Sep 17 00:00:00 2001 From: Rapptz Date: Sat, 21 Nov 2020 23:12:15 -0500 Subject: [PATCH] Suppress the creation of a command window from ffmpeg on Windows Fix #6038 --- discord/player.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/discord/player.py b/discord/player.py index cbfd000af..d5540a567 100644 --- a/discord/player.py +++ b/discord/player.py @@ -51,6 +51,11 @@ __all__ = ( 'PCMVolumeTransformer', ) +if sys.platform != 'win32': + CREATE_NO_WINDOW = 0 +else: + CREATE_NO_WINDOW = 0x08000000 + class AudioSource: """Represents an audio stream. @@ -136,7 +141,7 @@ class FFmpegAudio(AudioSource): def _spawn_process(self, args, **subprocess_kwargs): process = None try: - process = subprocess.Popen(args, **subprocess_kwargs) + process = subprocess.Popen(args, creationflags=CREATE_NO_WINDOW, **subprocess_kwargs) except FileNotFoundError: executable = args.partition(' ')[0] if isinstance(args, str) else args[0] raise ClientException(executable + ' was not found.') from None @@ -469,7 +474,7 @@ class FFmpegOpusAudio(FFmpegAudio): @staticmethod def _probe_codec_fallback(source, executable='ffmpeg'): args = [executable, '-hide_banner', '-i', source] - proc = subprocess.Popen(args, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) + proc = subprocess.Popen(args, creationflags=CREATE_NO_WINDOW, stdout=subprocess.PIPE, stderr=subprocess.STDOUT) out, _ = proc.communicate(timeout=20) output = out.decode('utf8') codec = bitrate = None