mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2025-09-03 16:45:17 +00:00
[docs,cleanup] Some minor refactoring and improve docs
This commit is contained in:
@ -478,7 +478,7 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
||||
SUPPORTED_EXTS = ('mp4', 'mkv', 'flv', 'webm', 'mov', 'avi', 'mp3', 'mka', 'm4a', 'ogg', 'opus')
|
||||
FORMAT_RE = re.compile(r'{0}(?:/{0})*$'.format(r'(?:\w+>)?(?:%s)' % '|'.join(SUPPORTED_EXTS)))
|
||||
_action = 'converting'
|
||||
_ACTION = 'converting'
|
||||
|
||||
def __init__(self, downloader=None, preferedformat=None):
|
||||
super(FFmpegVideoConvertorPP, self).__init__(downloader)
|
||||
@ -497,29 +497,28 @@ class FFmpegVideoConvertorPP(FFmpegPostProcessor):
|
||||
return []
|
||||
|
||||
@PostProcessor._restrict_to(images=False)
|
||||
def run(self, information):
|
||||
path, source_ext = information['filepath'], information['ext'].lower()
|
||||
def run(self, info):
|
||||
filename, source_ext = info['filepath'], info['ext'].lower()
|
||||
target_ext = self._target_ext(source_ext)
|
||||
_skip_msg = (
|
||||
'could not find a mapping for %s' if not target_ext
|
||||
else 'already is in target format %s' if source_ext == target_ext
|
||||
f'could not find a mapping for {source_ext}' if not target_ext
|
||||
else f'already is in target format {source_ext}' if source_ext == target_ext
|
||||
else None)
|
||||
if _skip_msg:
|
||||
self.to_screen('Not %s media file "%s"; %s' % (self._action, path, _skip_msg % source_ext))
|
||||
return [], information
|
||||
self.to_screen(f'Not {self._ACTION} media file {filename!r}; {_skip_msg}')
|
||||
return [], info
|
||||
|
||||
prefix, sep, oldext = path.rpartition('.')
|
||||
outpath = prefix + sep + target_ext
|
||||
self.to_screen('%s video from %s to %s; Destination: %s' % (self._action.title(), source_ext, target_ext, outpath))
|
||||
self.run_ffmpeg(path, outpath, self._options(target_ext))
|
||||
outpath = replace_extension(filename, target_ext, source_ext)
|
||||
self.to_screen(f'{self._ACTION.title()} video from {source_ext} to {target_ext}; Destination: {outpath}')
|
||||
self.run_ffmpeg(filename, outpath, self._options(target_ext))
|
||||
|
||||
information['filepath'] = outpath
|
||||
information['format'] = information['ext'] = target_ext
|
||||
return [path], information
|
||||
info['filepath'] = outpath
|
||||
info['format'] = info['ext'] = target_ext
|
||||
return [filename], info
|
||||
|
||||
|
||||
class FFmpegVideoRemuxerPP(FFmpegVideoConvertorPP):
|
||||
_action = 'remuxing'
|
||||
_ACTION = 'remuxing'
|
||||
|
||||
@staticmethod
|
||||
def _options(target_ext):
|
||||
|
Reference in New Issue
Block a user