From 88df85e8320b0d7055895a2923fd1108b214744b Mon Sep 17 00:00:00 2001 From: Nick Siakas Date: Sat, 13 Jun 2020 12:23:22 +0300 Subject: [PATCH] Added option to not show ffmpeg window for GUI applications --- youtube_dl/postprocessor/ffmpeg.py | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index 5f7298345..a560e02d5 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -52,9 +52,10 @@ class FFmpegPostProcessorError(PostProcessingError): class FFmpegPostProcessor(PostProcessor): - def __init__(self, downloader=None): + def __init__(self, downloader=None, noconsole=False): PostProcessor.__init__(self, downloader) self._determine_executables() + self._noconsole = noconsole def check_version(self): if not self.available: @@ -227,7 +228,12 @@ class FFmpegPostProcessor(PostProcessor): if self._downloader.params.get('verbose', False): self._downloader.to_screen('[debug] ffmpeg command line: %s' % shell_quote(cmd)) - p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE) + + startupinfo = subprocess.STARTUPINFO() + if self._noconsole: + startupinfo.dwFlags |= subprocess.STARTF_USESHOWWINDOW + + p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE, stdin=subprocess.PIPE, startupinfo=startupinfo) stdout, stderr = p.communicate() if p.returncode != 0: stderr = stderr.decode('utf-8', 'replace') @@ -247,8 +253,8 @@ class FFmpegPostProcessor(PostProcessor): class FFmpegExtractAudioPP(FFmpegPostProcessor): - def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False): - FFmpegPostProcessor.__init__(self, downloader) + def __init__(self, downloader=None, noconsole=False, preferredcodec=None, preferredquality=None, nopostoverwrites=False): + FFmpegPostProcessor.__init__(self, downloader, noconsole) if preferredcodec is None: preferredcodec = 'best' self._preferredcodec = preferredcodec @@ -350,8 +356,8 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor): class FFmpegVideoConvertorPP(FFmpegPostProcessor): - def __init__(self, downloader=None, preferedformat=None): - super(FFmpegVideoConvertorPP, self).__init__(downloader) + def __init__(self, downloader=None, noconsole=False, preferedformat=None): + super(FFmpegVideoConvertorPP, self).__init__(downloader, noconsole) self._preferedformat = preferedformat def run(self, information):