mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-11-05 18:52:48 +01:00
parent
35faefee5d
commit
e0ab98541c
@ -873,7 +873,9 @@ ## Post-Processing Options:
|
||||
(requires ffmpeg and ffprobe)
|
||||
--audio-format FORMAT Format to convert the audio to when -x is
|
||||
used. (currently supported: best (default),
|
||||
mp3, aac, m4a, opus, vorbis, flac, alac, wav)
|
||||
mp3, aac, m4a, opus, vorbis, flac, alac,
|
||||
wav). You can specify multiple rules using
|
||||
similar syntax as --remux-video
|
||||
--audio-quality QUALITY Specify ffmpeg audio quality to use when
|
||||
converting the audio with -x. Insert a value
|
||||
between 0 (best) and 10 (worst) for VBR or a
|
||||
|
@ -213,7 +213,7 @@ def validate_minmax(min_val, max_val, min_name, max_name=None):
|
||||
validate_regex('format sorting', f, InfoExtractor.FormatSort.regex)
|
||||
|
||||
# Postprocessor formats
|
||||
validate_in('audio format', opts.audioformat, ['best'] + list(FFmpegExtractAudioPP.SUPPORTED_EXTS))
|
||||
validate_regex('audio format', opts.audioformat, FFmpegExtractAudioPP.FORMAT_RE)
|
||||
validate_in('subtitle format', opts.convertsubtitles, FFmpegSubtitlesConvertorPP.SUPPORTED_EXTS)
|
||||
validate_regex('thumbnail format', opts.convertthumbnails, FFmpegThumbnailsConvertorPP.FORMAT_RE)
|
||||
validate_regex('recode video format', opts.recodevideo, FFmpegVideoConvertorPP.FORMAT_RE)
|
||||
|
@ -1424,7 +1424,8 @@ def _alias_callback(option, opt_str, value, parser, opts, nargs):
|
||||
'--audio-format', metavar='FORMAT', dest='audioformat', default='best',
|
||||
help=(
|
||||
'Format to convert the audio to when -x is used. '
|
||||
f'(currently supported: best (default), {", ".join(FFmpegExtractAudioPP.SUPPORTED_EXTS)})'))
|
||||
f'(currently supported: best (default), {", ".join(FFmpegExtractAudioPP.SUPPORTED_EXTS)}). '
|
||||
'You can specify multiple rules using similar syntax as --remux-video'))
|
||||
postproc.add_option(
|
||||
'--audio-quality', metavar='QUALITY',
|
||||
dest='audioquality', default='5',
|
||||
|
@ -426,10 +426,11 @@ def _concat_spec(cls, in_files, concat_opts=None):
|
||||
class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
COMMON_AUDIO_EXTS = ('wav', 'flac', 'm4a', 'aiff', 'mp3', 'ogg', 'mka', 'opus', 'wma')
|
||||
SUPPORTED_EXTS = tuple(ACODECS.keys())
|
||||
FORMAT_RE = create_mapping_re(('best', *SUPPORTED_EXTS))
|
||||
|
||||
def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False):
|
||||
FFmpegPostProcessor.__init__(self, downloader)
|
||||
self._preferredcodec = preferredcodec or 'best'
|
||||
self.mapping = preferredcodec or 'best'
|
||||
self._preferredquality = float_or_none(preferredquality)
|
||||
self._nopostoverwrites = nopostoverwrites
|
||||
|
||||
@ -469,9 +470,11 @@ def run_ffmpeg(self, path, out_path, codec, more_opts):
|
||||
@PostProcessor._restrict_to(images=False)
|
||||
def run(self, information):
|
||||
orig_path = path = information['filepath']
|
||||
target_format = self._preferredcodec
|
||||
target_format, _skip_msg = resolve_mapping(information['ext'], self.mapping)
|
||||
if target_format == 'best' and information['ext'] in self.COMMON_AUDIO_EXTS:
|
||||
self.to_screen(f'Not converting audio {orig_path}; the file is already in a common audio format')
|
||||
target_format, _skip_msg = None, 'the file is already in a common audio format'
|
||||
if not target_format:
|
||||
self.to_screen(f'Not converting audio {orig_path}; {_skip_msg}')
|
||||
return [], information
|
||||
|
||||
filecodec = self.get_audio_codec(path)
|
||||
|
Loading…
Reference in New Issue
Block a user