1
0
mirror of https://github.com/l1ving/youtube-dl synced 2025-01-24 03:52:51 +08:00

[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.
This commit is contained in:
Larry Hastings 2017-12-29 03:27:06 -08:00
parent 84f085d4bd
commit 8d548f4f0b
2 changed files with 20 additions and 2 deletions

View File

@ -231,3 +231,4 @@ John Dong
Tatsuyuki Ishi
Daniel Weber
Kay Bouché
Larry Hastings

View File

@ -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: