mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2024-12-22 18:17:17 -05:00
parent
35faefee5d
commit
e0ab98541c
@ -873,7 +873,9 @@ You can also fork the project on github and run your fork's [build workflow](.gi
|
||||
(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_options(opts):
|
||||
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 create_parser():
|
||||
'--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 @@ class FFmpegPostProcessor(PostProcessor):
|
||||
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 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
|
||||
@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