From 70484b9f8ae629ccb87e8c0569f8f4bf2dfdb0ac Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Mon, 11 May 2015 00:26:39 +0600 Subject: [PATCH 1/4] [postprocessor/ffmpeg] Extract `check_outdated` method --- youtube_dl/postprocessor/ffmpeg.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index 214de39f9..211faf69a 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -36,7 +36,9 @@ class FFmpegPostProcessor(PostProcessor): def check_version(self): if not self.available: raise FFmpegPostProcessorError('ffmpeg or avconv not found. Please install one.') + self.check_outdated() + def check_outdated(self): required_version = '10-0' if self.basename == 'avconv' else '1.0' if is_outdated_version( self._versions[self.basename], required_version): @@ -44,6 +46,8 @@ class FFmpegPostProcessor(PostProcessor): self.basename, self.basename, required_version) if self._downloader: self._downloader.report_warning(warning) + return True + return False @staticmethod def get_versions(downloader=None): From 7fcb605b82796e79a5f559624808ca9404df1154 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Mon, 11 May 2015 00:27:29 +0600 Subject: [PATCH 2/4] [YoutubeDL] Fallback to `-f best` when merger is outdated --- youtube_dl/YoutubeDL.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 4cf83c510..7c3bdb964 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -1086,9 +1086,10 @@ class YoutubeDL(object): if req_format is None: req_format_list = [] if (self.params.get('outtmpl', DEFAULT_OUTTMPL) != '-' - and info_dict['extractor'] in ['youtube', 'ted'] - and FFmpegMergerPP(self).available): - req_format_list.append('bestvideo+bestaudio') + and info_dict['extractor'] in ['youtube', 'ted']): + merger = FFmpegMergerPP(self) + if merger.available and not merger.check_outdated(): + req_format_list.append('bestvideo+bestaudio') req_format_list.append('best') req_format = '/'.join(req_format_list) formats_to_download = [] From 13763ce599c8fbba43e57d2d79a9b007cfbd4ced Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Mon, 11 May 2015 02:00:31 +0600 Subject: [PATCH 3/4] [postprocessor/ffmpeg] Add `can_merge` method --- youtube_dl/postprocessor/ffmpeg.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index 211faf69a..cc65b34e7 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -36,9 +36,7 @@ class FFmpegPostProcessor(PostProcessor): def check_version(self): if not self.available: raise FFmpegPostProcessorError('ffmpeg or avconv not found. Please install one.') - self.check_outdated() - def check_outdated(self): required_version = '10-0' if self.basename == 'avconv' else '1.0' if is_outdated_version( self._versions[self.basename], required_version): @@ -46,8 +44,6 @@ class FFmpegPostProcessor(PostProcessor): self.basename, self.basename, required_version) if self._downloader: self._downloader.report_warning(warning) - return True - return False @staticmethod def get_versions(downloader=None): @@ -595,6 +591,23 @@ class FFmpegMergerPP(FFmpegPostProcessor): os.rename(encodeFilename(temp_filename), encodeFilename(filename)) return info['__files_to_merge'], info + def can_merge(self): + # TODO: figure out merge-capable ffmpeg version + if self.basename != 'avconv': + return True + + required_version = '10-0' + if is_outdated_version( + self._versions[self.basename], required_version): + warning = ('Your copy of %s is outdated and unable to properly mux separate video and audio files, ' + 'youtube-dl will download single file media. ' + 'Update %s to version %s or newer to fix this.') % ( + self.basename, self.basename, required_version) + if self._downloader: + self._downloader.report_warning(warning) + return False + return True + class FFmpegFixupStretchedPP(FFmpegPostProcessor): def run(self, info): From 97fcf1bbd07ae0c5b6e530dcf2623d199452a76c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sergey=20M=E2=80=A4?= Date: Mon, 11 May 2015 02:01:16 +0600 Subject: [PATCH 4/4] [YoutubeDL] Check if merger can actually merge --- youtube_dl/YoutubeDL.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index 7c3bdb964..00f86b342 100755 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -1088,7 +1088,7 @@ class YoutubeDL(object): if (self.params.get('outtmpl', DEFAULT_OUTTMPL) != '-' and info_dict['extractor'] in ['youtube', 'ted']): merger = FFmpegMergerPP(self) - if merger.available and not merger.check_outdated(): + if merger.available and merger.can_merge(): req_format_list.append('bestvideo+bestaudio') req_format_list.append('best') req_format = '/'.join(req_format_list)