import re
from .common import FileDownloader
-from ..postprocessor.ffmpeg import FFmpegPostProcessor
+from ..postprocessor.ffmpeg import FFmpegPostProcessor, EXT_TO_OUT_FORMATS
from ..compat import compat_str
from ..utils import (
cli_option,
@classmethod
def available(cls):
- return check_executable(cls.get_basename(), cls.available_opt)
+ return check_executable(cls.get_basename(), [cls.AVAILABLE_OPT])
@classmethod
def supports(cls, info_dict):
class CurlFD(ExternalFD):
- available_opt = ['-V']
+ AVAILABLE_OPT = '-V'
def _make_cmd(self, tmpfilename, info_dict):
cmd = [self.exe, '--location', '-o', tmpfilename]
class AxelFD(ExternalFD):
- available_opt = ['-V']
+ AVAILABLE_OPT = '-V'
def _make_cmd(self, tmpfilename, info_dict):
cmd = [self.exe, '-o', tmpfilename]
class WgetFD(ExternalFD):
- available_opt = ['--version']
+ AVAILABLE_OPT = '--version'
def _make_cmd(self, tmpfilename, info_dict):
cmd = [self.exe, '-O', tmpfilename, '-nv', '--no-cookies']
class Aria2cFD(ExternalFD):
- available_opt = ['-v']
+ AVAILABLE_OPT = '-v'
def _make_cmd(self, tmpfilename, info_dict):
cmd = [self.exe, '-c']
class FFmpegFD(ExternalFD):
@classmethod
def supports(cls, info_dict):
- return info_dict['protocol'] in ('http', 'https', 'ftp', 'ftps', 'm3u8', 'rtsp', 'rtmp', 'mms')
+ return info_dict['protocol'] in ('http', 'https', 'ftp', 'ftps', 'm3u8', 'rtsp', 'rtmp', 'mms') and not info_dict.get('requested_formats')
@classmethod
def available(cls):
args = [ffpp.executable, '-y']
- start_time = info_dict.get('start_time', 0)
+ start_time = info_dict.get('start_time') or 0
if start_time:
args += ['-ss', compat_str(start_time)]
end_time = info_dict.get('end_time')
else:
args += ['-f', 'mp4', '-bsf:a', 'aac_adtstoasc']
else:
- args += ['-f', info_dict['ext']]
+ args += ['-f', EXT_TO_OUT_FORMATS.get(info_dict['ext'], info_dict['ext'])]
args = [encodeArgument(opt) for opt in args]
args.append(encodeFilename(ffpp._ffmpeg_filename_argument(tmpfilename), True))