mirror of
https://github.com/l1ving/youtube-dl
synced 2025-01-24 07:12: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:
parent
84f085d4bd
commit
8d548f4f0b
1
AUTHORS
1
AUTHORS
@ -231,3 +231,4 @@ John Dong
|
|||||||
Tatsuyuki Ishi
|
Tatsuyuki Ishi
|
||||||
Daniel Weber
|
Daniel Weber
|
||||||
Kay Bouché
|
Kay Bouché
|
||||||
|
Larry Hastings
|
||||||
|
@ -55,6 +55,9 @@ class FFmpegPostProcessorError(PostProcessingError):
|
|||||||
|
|
||||||
|
|
||||||
class FFmpegPostProcessor(PostProcessor):
|
class FFmpegPostProcessor(PostProcessor):
|
||||||
|
_avconv_required_version = '10-0'
|
||||||
|
_ffmpeg_required_version = '1.0'
|
||||||
|
|
||||||
def __init__(self, downloader=None):
|
def __init__(self, downloader=None):
|
||||||
PostProcessor.__init__(self, downloader)
|
PostProcessor.__init__(self, downloader)
|
||||||
self._determine_executables()
|
self._determine_executables()
|
||||||
@ -63,7 +66,11 @@ class FFmpegPostProcessor(PostProcessor):
|
|||||||
if not self.available:
|
if not self.available:
|
||||||
raise FFmpegPostProcessorError('ffmpeg or avconv not found. Please install one.')
|
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(
|
if is_outdated_version(
|
||||||
self._versions[self.basename], required_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.' % (
|
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._paths = None
|
||||||
self._versions = None
|
self._versions = None
|
||||||
if self._downloader:
|
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')
|
location = self._downloader.params.get('ffmpeg_location')
|
||||||
if location is not None:
|
if location is not None:
|
||||||
if not os.path.exists(location):
|
if not os.path.exists(location):
|
||||||
@ -117,6 +124,16 @@ class FFmpegPostProcessor(PostProcessor):
|
|||||||
(p, get_exe_version(p, args=['-version'])) for p in programs)
|
(p, get_exe_version(p, args=['-version'])) for p in programs)
|
||||||
self._paths = dict((p, p) 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:
|
if prefer_ffmpeg:
|
||||||
prefs = ('ffmpeg', 'avconv')
|
prefs = ('ffmpeg', 'avconv')
|
||||||
else:
|
else:
|
||||||
|
Loading…
Reference in New Issue
Block a user