From a79580dc9a1d422894374ead6823f9bc283b5981 Mon Sep 17 00:00:00 2001 From: Anand Tamariya Date: Thu, 20 Dec 2018 14:47:07 +0530 Subject: [PATCH 1/3] Allow format to be specified by -f flag --- youtube_dl/downloader/external.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index 958d00aac..1ba839716 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -294,7 +294,7 @@ class FFmpegFD(ExternalFD): if live: args += ['-rtmp_live', 'live'] - args += ['-i', url, '-c', 'copy'] + args += ['-i', url] if self.params.get('test', False): args += ['-fs', compat_str(self._TEST_FILE_SIZE)] From f0cbbcf089f0f1119c44240f440c023f5bc4fee1 Mon Sep 17 00:00:00 2001 From: Anand Tamariya Date: Mon, 24 Dec 2018 16:37:38 +0530 Subject: [PATCH 2/3] For MP4 format and stdout, use -movflags option. --- youtube_dl/downloader/external.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index 1ba839716..b6601d7ba 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -300,10 +300,12 @@ class FFmpegFD(ExternalFD): args += ['-fs', compat_str(self._TEST_FILE_SIZE)] if protocol in ('m3u8', 'm3u8_native'): - if self.params.get('hls_use_mpegts', False) or tmpfilename == '-': + if self.params.get('hls_use_mpegts', False): args += ['-f', 'mpegts'] else: args += ['-f', 'mp4'] + if tmpfilename == '-': + args += ["-movflags", "frag_keyframe+empty_moov"] if (ffpp.basename == 'ffmpeg' and is_outdated_version(ffpp._versions['ffmpeg'], '3.2', False)) and (not info_dict.get('acodec') or info_dict['acodec'].split('.')[0] in ('aac', 'mp4a')): args += ['-bsf:a', 'aac_adtstoasc'] elif protocol == 'rtmp': From 7e9f0baefaec0a8050fa4d12b3977f9052643638 Mon Sep 17 00:00:00 2001 From: Anand Tamariya Date: Thu, 27 Dec 2018 20:08:02 +0530 Subject: [PATCH 3/3] Use optimized ffmpeg params for pipe operation --- youtube_dl/downloader/external.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/youtube_dl/downloader/external.py b/youtube_dl/downloader/external.py index b6601d7ba..b6e7bea07 100644 --- a/youtube_dl/downloader/external.py +++ b/youtube_dl/downloader/external.py @@ -305,7 +305,8 @@ class FFmpegFD(ExternalFD): else: args += ['-f', 'mp4'] if tmpfilename == '-': - args += ["-movflags", "frag_keyframe+empty_moov"] + args += ['-movflags', 'frag_keyframe+empty_moov', '-c:v', 'libx264', '-c:a', 'aac', '-ac', '2', '-ab', '128000'] + args += ['-bsf:a', 'aac_adtstoasc', '-tune', 'zerolatency', '-preset', 'ultrafast', '-level', '31', '-pix_fmt', 'yuv420p'] if (ffpp.basename == 'ffmpeg' and is_outdated_version(ffpp._versions['ffmpeg'], '3.2', False)) and (not info_dict.get('acodec') or info_dict['acodec'].split('.')[0] in ('aac', 'mp4a')): args += ['-bsf:a', 'aac_adtstoasc'] elif protocol == 'rtmp':