mirror of
https://github.com/ytdl-org/youtube-dl.git
synced 2024-12-19 11:34:04 +00:00
[YoutubeDL] Output avconv/ffmpeg versions if -v is given
This commit is contained in:
parent
a7e97f6db1
commit
d28b517154
@ -62,7 +62,7 @@ from .utils import (
|
|||||||
from .cache import Cache
|
from .cache import Cache
|
||||||
from .extractor import get_info_extractor, gen_extractors
|
from .extractor import get_info_extractor, gen_extractors
|
||||||
from .downloader import get_suitable_downloader
|
from .downloader import get_suitable_downloader
|
||||||
from .postprocessor import FFmpegMergerPP
|
from .postprocessor import FFmpegMergerPP, FFmpegPostProcessor
|
||||||
from .version import __version__
|
from .version import __version__
|
||||||
|
|
||||||
|
|
||||||
@ -1311,8 +1311,18 @@ class YoutubeDL(object):
|
|||||||
sys.exc_clear()
|
sys.exc_clear()
|
||||||
except:
|
except:
|
||||||
pass
|
pass
|
||||||
self._write_string('[debug] Python version %s - %s' %
|
self._write_string('[debug] Python version %s - %s\n' % (
|
||||||
(platform.python_version(), platform_name()) + '\n')
|
platform.python_version(), platform_name()))
|
||||||
|
|
||||||
|
exe_versions = FFmpegPostProcessor.get_versions()
|
||||||
|
exe_str = ', '.join(
|
||||||
|
'%s %s' % (exe, v)
|
||||||
|
for exe, v in sorted(exe_versions.items())
|
||||||
|
if v
|
||||||
|
)
|
||||||
|
if not exe_str:
|
||||||
|
exe_str = 'none'
|
||||||
|
self._write_string('[debug] exe versions: %s\n' % exe_str)
|
||||||
|
|
||||||
proxy_map = {}
|
proxy_map = {}
|
||||||
for handler in self._opener.handlers:
|
for handler in self._opener.handlers:
|
||||||
|
@ -1,24 +1,26 @@
|
|||||||
|
|
||||||
from .atomicparsley import AtomicParsleyPP
|
from .atomicparsley import AtomicParsleyPP
|
||||||
from .ffmpeg import (
|
from .ffmpeg import (
|
||||||
|
FFmpegPostProcessor,
|
||||||
FFmpegAudioFixPP,
|
FFmpegAudioFixPP,
|
||||||
|
FFmpegEmbedSubtitlePP,
|
||||||
|
FFmpegExtractAudioPP,
|
||||||
FFmpegMergerPP,
|
FFmpegMergerPP,
|
||||||
FFmpegMetadataPP,
|
FFmpegMetadataPP,
|
||||||
FFmpegVideoConvertor,
|
FFmpegVideoConvertor,
|
||||||
FFmpegExtractAudioPP,
|
|
||||||
FFmpegEmbedSubtitlePP,
|
|
||||||
)
|
)
|
||||||
from .xattrpp import XAttrMetadataPP
|
from .xattrpp import XAttrMetadataPP
|
||||||
from .execafterdownload import ExecAfterDownloadPP
|
from .execafterdownload import ExecAfterDownloadPP
|
||||||
|
|
||||||
__all__ = [
|
__all__ = [
|
||||||
'AtomicParsleyPP',
|
'AtomicParsleyPP',
|
||||||
|
'ExecAfterDownloadPP',
|
||||||
'FFmpegAudioFixPP',
|
'FFmpegAudioFixPP',
|
||||||
|
'FFmpegEmbedSubtitlePP',
|
||||||
|
'FFmpegExtractAudioPP',
|
||||||
'FFmpegMergerPP',
|
'FFmpegMergerPP',
|
||||||
'FFmpegMetadataPP',
|
'FFmpegMetadataPP',
|
||||||
|
'FFmpegPostProcessor',
|
||||||
'FFmpegVideoConvertor',
|
'FFmpegVideoConvertor',
|
||||||
'FFmpegExtractAudioPP',
|
|
||||||
'FFmpegEmbedSubtitlePP',
|
|
||||||
'XAttrMetadataPP',
|
'XAttrMetadataPP',
|
||||||
'ExecAfterDownloadPP',
|
|
||||||
]
|
]
|
||||||
|
@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import re
|
||||||
import subprocess
|
import subprocess
|
||||||
import sys
|
import sys
|
||||||
import time
|
import time
|
||||||
@ -18,6 +19,23 @@ from ..utils import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
|
def get_version(executable):
|
||||||
|
""" Returns the version of the specified executable,
|
||||||
|
or False if the executable is not present """
|
||||||
|
try:
|
||||||
|
out, err = subprocess.Popen(
|
||||||
|
[executable, '-version'],
|
||||||
|
stdout=subprocess.PIPE, stderr=subprocess.PIPE).communicate()
|
||||||
|
except OSError:
|
||||||
|
return False
|
||||||
|
firstline = out.partition(b'\n')[0].decode('ascii', 'ignore')
|
||||||
|
m = re.search(r'version\s+([0-9._-a-zA-Z]+)', firstline)
|
||||||
|
if not m:
|
||||||
|
return u'present'
|
||||||
|
else:
|
||||||
|
return m.group(1)
|
||||||
|
|
||||||
|
|
||||||
class FFmpegPostProcessorError(PostProcessingError):
|
class FFmpegPostProcessorError(PostProcessingError):
|
||||||
pass
|
pass
|
||||||
|
|
||||||
@ -25,22 +43,26 @@ class FFmpegPostProcessorError(PostProcessingError):
|
|||||||
class FFmpegPostProcessor(PostProcessor):
|
class FFmpegPostProcessor(PostProcessor):
|
||||||
def __init__(self, downloader=None, deletetempfiles=False):
|
def __init__(self, downloader=None, deletetempfiles=False):
|
||||||
PostProcessor.__init__(self, downloader)
|
PostProcessor.__init__(self, downloader)
|
||||||
self._exes = self.detect_executables()
|
self._versions = self.get_versions()
|
||||||
self._deletetempfiles = deletetempfiles
|
self._deletetempfiles = deletetempfiles
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def detect_executables():
|
def get_versions():
|
||||||
programs = ['avprobe', 'avconv', 'ffmpeg', 'ffprobe']
|
programs = ['avprobe', 'avconv', 'ffmpeg', 'ffprobe']
|
||||||
return dict((program, check_executable(program, ['-version'])) for program in programs)
|
return dict((program, get_version(program)) for program in programs)
|
||||||
|
|
||||||
def _get_executable(self):
|
def _get_executable(self):
|
||||||
if self._downloader.params.get('prefer_ffmpeg', False):
|
if self._downloader.params.get('prefer_ffmpeg', False):
|
||||||
return self._exes['ffmpeg'] or self._exes['avconv']
|
prefs = ('ffmpeg', 'avconv')
|
||||||
else:
|
else:
|
||||||
return self._exes['avconv'] or self._exes['ffmpeg']
|
prefs = ('avconv', 'ffmpeg')
|
||||||
|
for p in prefs:
|
||||||
|
if self._versions[p]:
|
||||||
|
return p
|
||||||
|
return None
|
||||||
|
|
||||||
def _uses_avconv(self):
|
def _uses_avconv(self):
|
||||||
return self._get_executable() == self._exes['avconv']
|
return self._get_executable() == 'avconv'
|
||||||
|
|
||||||
def run_ffmpeg_multiple_files(self, input_paths, out_path, opts):
|
def run_ffmpeg_multiple_files(self, input_paths, out_path, opts):
|
||||||
if not self._get_executable():
|
if not self._get_executable():
|
||||||
|
Loading…
Reference in New Issue
Block a user