]> jfr.im git - yt-dlp.git/commitdiff
[ExtractAudio] Don't re-encode when file is already in a common audio format (Closes...
authorpukkandan <redacted>
Mon, 15 Feb 2021 17:46:11 +0000 (23:16 +0530)
committerpukkandan <redacted>
Mon, 15 Feb 2021 17:52:11 +0000 (23:22 +0530)
Fixes: https://github.com/blackjack4494/youtube-dlc/issues/214
Fixes: https://github.com/ytdl-org/youtube-dl/issues/28006
youtube_dlc/postprocessor/ffmpeg.py

index 0982bea81370317703910f404ff06f54c6362a53..292af9aa8ed32b922b8287bdc85023c02a4900cc 100644 (file)
@@ -280,6 +280,8 @@ def _ffmpeg_filename_argument(self, fn):
 
 
 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 @@ def run_ffmpeg(self, path, out_path, codec, more_opts):
 
     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: