+ def run_ffmpeg(self, path, out_path, opts):
+ if not self._exes['ffmpeg'] and not self._exes['avconv']:
+ raise FFmpegPostProcessorError(u'ffmpeg or avconv not found. Please install one.')
+ cmd = ([self._exes['avconv'] or self._exes['ffmpeg'], '-y', '-i', encodeFilename(path)]
+ + opts +
+ [encodeFilename(self._ffmpeg_filename_argument(out_path))])
+ p = subprocess.Popen(cmd, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
+ stdout,stderr = p.communicate()
+ if p.returncode != 0:
+ stderr = stderr.decode('utf-8', 'replace')
+ msg = stderr.strip().split('\n')[-1]
+ raise FFmpegPostProcessorError(msg)
+
+ def _ffmpeg_filename_argument(self, fn):
+ # ffmpeg broke --, see https://ffmpeg.org/trac/ffmpeg/ticket/2127 for details
+ if fn.startswith(u'-'):
+ return u'./' + fn
+ return fn
+
+class FFmpegExtractAudioPP(FFmpegPostProcessor):
+ def __init__(self, downloader=None, preferredcodec=None, preferredquality=None, nopostoverwrites=False):
+ FFmpegPostProcessor.__init__(self, downloader)
+ if preferredcodec is None:
+ preferredcodec = 'best'
+ self._preferredcodec = preferredcodec
+ self._preferredquality = preferredquality
+ self._nopostoverwrites = nopostoverwrites
+