From 8544f1a915ff689453105eacfd44c6f6e9b8ca75 Mon Sep 17 00:00:00 2001 From: Istvan Nagy Date: Sun, 15 Mar 2015 18:13:58 +0100 Subject: [PATCH] libfdkaac transcode support added. --- youtube_dl/__init__.py | 2 +- youtube_dl/postprocessor/ffmpeg.py | 17 ++++++++++++++++- 2 files changed, 17 insertions(+), 2 deletions(-) diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 852b2fc3d..41969e980 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -162,7 +162,7 @@ def _real_main(argv=None): if opts.playlistend not in (-1, None) and opts.playlistend < opts.playliststart: raise ValueError('Playlist end must be greater than playlist start') if opts.extractaudio: - if opts.audioformat not in ['best', 'aac', 'mp3', 'm4a', 'opus', 'vorbis', 'wav']: + if opts.audioformat not in ['best', 'aac', 'libfdkaac', 'libfdkaac-he', 'libfdkaac-hev2', 'mp3', 'm4a', 'opus', 'vorbis', 'wav']: parser.error('invalid audio format specified') if opts.audioquality: opts.audioquality = opts.audioquality.strip('k').strip('K') diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py index b6f51cfd5..e264ecb11 100644 --- a/youtube_dl/postprocessor/ffmpeg.py +++ b/youtube_dl/postprocessor/ffmpeg.py @@ -237,7 +237,7 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor): more_opts += ['-b:a', self._preferredquality + 'k'] else: # We convert the audio (lossy) - acodec = {'mp3': 'libmp3lame', 'aac': 'aac', 'm4a': 'aac', 'opus': 'opus', 'vorbis': 'libvorbis', 'wav': None}[self._preferredcodec] + acodec = {'mp3': 'libmp3lame', 'aac': 'aac', 'm4a': 'aac', 'opus': 'opus', 'vorbis': 'libvorbis', 'wav': None, 'libfdkaac': None, 'libfdkaac-he': None, 'libfdkaac-hev2': None}[self._preferredcodec] extension = self._preferredcodec more_opts = [] if self._preferredquality is not None: @@ -255,6 +255,21 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor): if self._preferredcodec == 'wav': extension = 'wav' more_opts += ['-f', 'wav'] + if self._preferredcodec == 'libfdkaac' or self._preferredcodec == 'libfdkaac-he' or self._preferredcodec == 'libfdkaac-hev2': + more_opts = [] + acodec = 'libfdk_aac' + prefix, sep, ext = path.rpartition('.') + if (ext == 'm4a'): + extension = 'libfdkaac.m4a' + if self._preferredquality is not None: + if int(self._preferredquality) < 6: + more_opts += ['-vbr', self._preferredquality] + else: + more_opts += ['-b:a', self._preferredquality + 'k'] + if self._preferredcodec == 'libfdkaac-he': + more_opts += ['-profile:a', 'aac_he'] + elif self._preferredcodec == 'libfdkaac-hev2': + more_opts += ['-profile:a', 'aac_he_v2'] prefix, sep, ext = path.rpartition('.') # not os.path.splitext, since the latter does not work on unicode in all setups new_path = prefix + sep + extension