From 8d548f4f0b285912afe03aa4c5f6ac11dccdc17a Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Fri, 29 Dec 2017 03:27:06 -0800 Subject: [PATCH 1/2] [postprocessor/ffmpeg] Avoid outdated avconv When the user hasn't expressed a preference between avconv and ffmpeg, and avconv is outdated, default to ffmpeg. Default to avconv in all other cases. --- AUTHORS | 1 + youtube_dl/postprocessor/ffmpeg.py | 21 +++++++++++++++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/AUTHORS b/AUTHORS index 7e012247c..03f5880b5 100644 --- a/AUTHORS +++ b/AUTHORS @@ -231,3 +231,4 @@ John Dong Tatsuyuki Ishi Daniel Weber Kay Bouché +Larry Hastings diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index 3ea1afcf3..c3ade10fb 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -55,6 +55,9 @@ class FFmpegPostProcessorError(PostProcessingError): class FFmpegPostProcessor(PostProcessor): + _avconv_required_version = '10-0' + _ffmpeg_required_version = '1.0' + def __init__(self, downloader=None): PostProcessor.__init__(self, downloader) self._determine_executables() @@ -63,7 +66,11 @@ class FFmpegPostProcessor(PostProcessor): if not self.available: raise FFmpegPostProcessorError('ffmpeg or avconv not found. Please install one.') - required_version = '10-0' if self.basename == 'avconv' else '1.0' + if self.basename == 'avconv': + required_version = self._avconv_required_version + else: + required_version = self._ffmpeg_required_version + if is_outdated_version( self._versions[self.basename], required_version): warning = 'Your copy of %s is outdated, update %s to version %s or newer if you encounter any errors.' % ( @@ -85,7 +92,7 @@ class FFmpegPostProcessor(PostProcessor): self._paths = None self._versions = None if self._downloader: - prefer_ffmpeg = self._downloader.params.get('prefer_ffmpeg', False) + prefer_ffmpeg = self._downloader.params.get('prefer_ffmpeg', None) location = self._downloader.params.get('ffmpeg_location') if location is not None: if not os.path.exists(location): @@ -117,6 +124,16 @@ class FFmpegPostProcessor(PostProcessor): (p, get_exe_version(p, args=['-version'])) for p in programs) self._paths = dict((p, p) for p in programs) + if prefer_ffmpeg is None: + if not is_outdated_version(self._versions['avconv'], + self._avconv_required_version): + prefer_ffmpeg = False + print("preferring avconv") + elif not is_outdated_version(self._versions['ffmpeg'], + self._ffmpeg_required_version): + prefer_ffmpeg = True + print("preferring ffmpeg") + if prefer_ffmpeg: prefs = ('ffmpeg', 'avconv') else: From adc326e850201598121f8e3ab5b731b7c691cf74 Mon Sep 17 00:00:00 2001 From: Larry Hastings Date: Fri, 29 Dec 2017 03:42:25 -0800 Subject: [PATCH 2/2] Fix flake8 complaints. --- youtube_dl/postprocessor/ffmpeg.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index c3ade10fb..20e602277 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -126,11 +126,11 @@ class FFmpegPostProcessor(PostProcessor): if prefer_ffmpeg is None: if not is_outdated_version(self._versions['avconv'], - self._avconv_required_version): + self._avconv_required_version): prefer_ffmpeg = False print("preferring avconv") elif not is_outdated_version(self._versions['ffmpeg'], - self._ffmpeg_required_version): + self._ffmpeg_required_version): prefer_ffmpeg = True print("preferring ffmpeg")