about summary refs log tree commit diff
path: root/youtube_dl/postprocessor
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2017-03-16 12:50:45 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2017-03-16 12:50:45 +0100
commit21bfcd3d6e41aed6113c874533fcfe41eb250d96 (patch)
tree9587cb533eb37bebfa5f2c37167b9c06074b1260 /youtube_dl/postprocessor
parentb51dc9db0e6ffc6a7725d92fa2c5de45a5b1be20 (diff)
downloadyoutube-dl-21bfcd3d6e41aed6113c874533fcfe41eb250d96.tar.gz
youtube-dl-21bfcd3d6e41aed6113c874533fcfe41eb250d96.tar.xz
youtube-dl-21bfcd3d6e41aed6113c874533fcfe41eb250d96.zip
[postprocessor/ffmpeg] Add support for flac
Requested at http://stackoverflow.com/q/42828041/35070
Diffstat (limited to 'youtube_dl/postprocessor')
-rw-r--r--youtube_dl/postprocessor/ffmpeg.py34
1 files changed, 22 insertions, 12 deletions
diff --git a/youtube_dl/postprocessor/ffmpeg.py b/youtube_dl/postprocessor/ffmpeg.py
index 96ddb3b36..7c162d92a 100644
--- a/youtube_dl/postprocessor/ffmpeg.py
+++ b/youtube_dl/postprocessor/ffmpeg.py
@@ -26,15 +26,25 @@ from ..utils import (
 
 
 EXT_TO_OUT_FORMATS = {
-    "aac": "adts",
-    "m4a": "ipod",
-    "mka": "matroska",
-    "mkv": "matroska",
-    "mpg": "mpeg",
-    "ogv": "ogg",
-    "ts": "mpegts",
-    "wma": "asf",
-    "wmv": "asf",
+    'aac': 'adts',
+    'flac': 'flac',
+    'm4a': 'ipod',
+    'mka': 'matroska',
+    'mkv': 'matroska',
+    'mpg': 'mpeg',
+    'ogv': 'ogg',
+    'ts': 'mpegts',
+    'wma': 'asf',
+    'wmv': 'asf',
+}
+ACODECS = {
+    'mp3': 'libmp3lame',
+    'aac': 'aac',
+    'flac': 'flac',
+    'm4a': 'aac',
+    'opus': 'opus',
+    'vorbis': 'libvorbis',
+    'wav': None,
 }
 
 
@@ -237,7 +247,7 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
                 acodec = 'copy'
                 extension = 'm4a'
                 more_opts = ['-bsf:a', 'aac_adtstoasc']
-            elif filecodec in ['aac', 'mp3', 'vorbis', 'opus']:
+            elif filecodec in ['aac', 'flac', 'mp3', 'vorbis', 'opus']:
                 # Lossless if possible
                 acodec = 'copy'
                 extension = filecodec
@@ -256,8 +266,8 @@ class FFmpegExtractAudioPP(FFmpegPostProcessor):
                     else:
                         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]
+            # We convert the audio (lossy if codec is lossy)
+            acodec = ACODECS[self._preferredcodec]
             extension = self._preferredcodec
             more_opts = []
             if self._preferredquality is not None: