diff options
author | pukkandan <pukkandan@gmail.com> | 2021-02-15 23:16:11 +0530 |
---|---|---|
committer | pukkandan <pukkandan@gmail.com> | 2021-02-15 23:22:11 +0530 |
commit | 1de75fa129775b6d1ea57686299e0aeadb9a8ab8 (patch) | |
tree | a7bfc906f7cf63cad0714b6f3ed24573544b4e6d | |
parent | 62852977953ff6d2492f87260ba60a44c3a9924a (diff) | |
download | hypervideo-pre-1de75fa129775b6d1ea57686299e0aeadb9a8ab8.tar.lz hypervideo-pre-1de75fa129775b6d1ea57686299e0aeadb9a8ab8.tar.xz hypervideo-pre-1de75fa129775b6d1ea57686299e0aeadb9a8ab8.zip |
[ExtractAudio] Don't re-encode when file is already in a common audio format (Closes #58)
Fixes: https://github.com/blackjack4494/youtube-dlc/issues/214
Fixes: https://github.com/ytdl-org/youtube-dl/issues/28006
-rw-r--r-- | youtube_dlc/postprocessor/ffmpeg.py | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/youtube_dlc/postprocessor/ffmpeg.py b/youtube_dlc/postprocessor/ffmpeg.py index 0982bea81..292af9aa8 100644 --- a/youtube_dlc/postprocessor/ffmpeg.py +++ b/youtube_dlc/postprocessor/ffmpeg.py @@ -280,6 +280,8 @@ class FFmpegPostProcessor(PostProcessor): class FFmpegExtractAudioPP(FFmpegPostProcessor): + COMMON_AUDIO_EXTENSIONS = ('wav', 'flac', 'm4a', 'aiff', 'mp3', 'ogg', 'mka', 'opus', 'wma') + def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False): FFmpegPostProcessor.__init__(self, downloader) if preferredcodec is None: @@ -301,6 +303,10 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor): def run(self, information): path = information['filepath'] + orig_ext = information['ext'] + + if self._preferredcodec == 'best' and orig_ext in self.COMMON_AUDIO_EXTENSIONS: + self.to_screen('Skipping audio extraction since the file is already in a common audio format') filecodec = self.get_audio_codec(path) if filecodec is None: |