From ce599d5a7edf2161d0881ccd263131d51c656093 Mon Sep 17 00:00:00 2001 From: remitamine Date: Thu, 14 Apr 2016 18:48:00 +0100 Subject: [PATCH 1/3] [downloader/external] enable piping for FFmpegFD(closes #2124) --- youtube_dl/downloader/external.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index 30277dc20..cda39fe97 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -225,7 +225,7 @@ def _call_downloader(self, tmpfilename, info_dict): args += ['-i', url, '-c', 'copy'] if protocol == 'm3u8': - if self.params.get('hls_use_mpegts', False): + if self.params.get('hls_use_mpegts', False) or tmpfilename == '-': args += ['-f', 'mpegts'] else: args += ['-f', 'mp4', '-bsf:a', 'aac_adtstoasc'] @@ -235,7 +235,10 @@ def _call_downloader(self, tmpfilename, info_dict): args += ['-f', EXT_TO_OUT_FORMATS.get(info_dict['ext'], info_dict['ext'])] args = [encodeArgument(opt) for opt in args] - args.append(encodeFilename(ffpp._ffmpeg_filename_argument(tmpfilename), True)) + if tmpfilename == '-': + args.append('pipe:1') + else: + args.append(encodeFilename(ffpp._ffmpeg_filename_argument(tmpfilename), True)) self._debug_cmd(args) From d868f43c588b9929208823e86c12669d69e4e2cd Mon Sep 17 00:00:00 2001 From: remitamine Date: Sat, 16 Apr 2016 19:45:56 +0100 Subject: [PATCH 2/3] [ffmpeg] check for - file name in _ffmpeg_filename_argument --- youtube_dl/downloader/external.py | 5 +---- youtube_dl/postprocessor/ffmpeg.py | 2 +- 2 files changed, 2 insertions(+), 5 deletions(-) diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index cda39fe97..8d642fc3e 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -235,10 +235,7 @@ def _call_downloader(self, tmpfilename, info_dict): args += ['-f', EXT_TO_OUT_FORMATS.get(info_dict['ext'], info_dict['ext'])] args = [encodeArgument(opt) for opt in args] - if tmpfilename == '-': - args.append('pipe:1') - else: - args.append(encodeFilename(ffpp._ffmpeg_filename_argument(tmpfilename), True)) + args.append(encodeFilename(ffpp._ffmpeg_filename_argument(tmpfilename), True)) self._debug_cmd(args) diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index b64cd396b..30af6eb5a 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -175,7 +175,7 @@ def _ffmpeg_filename_argument(self, fn): # Always use 'file:' because the filename may contain ':' (ffmpeg # interprets that as a protocol) or can start with '-' (-- is broken in # ffmpeg, see https://ffmpeg.org/trac/ffmpeg/ticket/2127 for details) - return 'file:' + fn + return 'file:' + fn if fn != '-' else fn class FFmpegExtractAudioPP(FFmpegPostProcessor): From b9f2fdd37fe2085deb09710a2084c940e9920304 Mon Sep 17 00:00:00 2001 From: remitamine Date: Sat, 16 Apr 2016 21:49:13 +0100 Subject: [PATCH 3/3] [ffmpeg] Clarify rationale for pipe(-) exclusion in _ffmpeg_filename_argument --- youtube_dl/postprocessor/ffmpeg.py | 1 + 1 file changed, 1 insertion(+) diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index 30af6eb5a..1793a878c 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -175,6 +175,7 @@ def _ffmpeg_filename_argument(self, fn): # Always use 'file:' because the filename may contain ':' (ffmpeg # interprets that as a protocol) or can start with '-' (-- is broken in # ffmpeg, see https://ffmpeg.org/trac/ffmpeg/ticket/2127 for details) + # Also leave '-' intact in order not to break streaming to stdout. return 'file:' + fn if fn != '-' else fn