[ExtractAudio] Use libfdk_aac if available

Closes #1502
Authored by: CrypticSignal
This commit is contained in:
CrypticSignal 2021-11-04 02:23:40 +05:30 committed by pukkandan
parent 9af98e17bd
commit 673c0057e8
No known key found for this signature in database
GPG key ID: 0F00D95A001F4698

View file

@ -99,7 +99,7 @@ class FFmpegPostProcessor(PostProcessor):
if prog != 'ffmpeg' or not out: if prog != 'ffmpeg' or not out:
return return
# TODO: Feature detection self._features['fdk'] = '--enable-libfdk-aac' in out
self.basename = None self.basename = None
self.probe_basename = None self.probe_basename = None
@ -391,6 +391,7 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
# Experimentally, with values over 4, bitrate changes were minimal or non-existent # Experimentally, with values over 4, bitrate changes were minimal or non-existent
'aac': (0.1, 4), 'aac': (0.1, 4),
'vorbis': (0, 10), 'vorbis': (0, 10),
'libfdk_aac': (1, 5),
'opus': None, # doesn't support -q:a 'opus': None, # doesn't support -q:a
'wav': None, 'wav': None,
'flac': None, 'flac': None,
@ -399,6 +400,8 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
return [] return []
q = limits[1] + (limits[0] - limits[1]) * (self._preferredquality / 10) q = limits[1] + (limits[0] - limits[1]) * (self._preferredquality / 10)
if codec == 'libfdk_aac':
return ['-vbr', f'{int(q)}']
return ['-q:a', f'{q}'] return ['-q:a', f'{q}']
def run_ffmpeg(self, path, out_path, codec, more_opts): def run_ffmpeg(self, path, out_path, codec, more_opts):
@ -448,6 +451,8 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
else: else:
# We convert the audio (lossy if codec is lossy) # We convert the audio (lossy if codec is lossy)
acodec = ACODECS[self._preferredcodec] acodec = ACODECS[self._preferredcodec]
if acodec == 'aac' and self._features.get('fdk'):
acodec = 'libfdk_aac'
extension = self._preferredcodec extension = self._preferredcodec
more_opts = self._quality_args(acodec) more_opts = self._quality_args(acodec)
if self._preferredcodec == 'aac': if self._preferredcodec == 'aac':