From 5fd95ee242722b3bcf5d78b7755cb10aa9dca512 Mon Sep 17 00:00:00 2001 From: Martin Kaistra Date: Sat, 10 Sep 2016 15:09:58 +0200 Subject: [PATCH] use aac if libfdk_aac not installed --- video_thread.py | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/video_thread.py b/video_thread.py index 25b3b46..9f4ce7b 100644 --- a/video_thread.py +++ b/video_thread.py @@ -31,7 +31,14 @@ class Worker(QtCore.QObject): completeAudioArray = self.core.readAudioFile(inputFile) - out_pipe = sp.Popen([ self.core.FFMPEG_BIN, + # test if user has libfdk_aac + encoders = sp.check_output(self.core.FFMPEG_BIN + " -encoders -hide_banner", shell=True) + if b'libfdk_aac' in encoders: + acodec = 'libfdk_aac' + else: + acodec = 'aac' + + ffmpegCommand = [ self.core.FFMPEG_BIN, '-y', # (optional) means overwrite the output file if it already exists. '-f', 'rawvideo', '-vcodec', 'rawvideo', @@ -41,13 +48,20 @@ class Worker(QtCore.QObject): '-i', '-', # The input comes from a pipe '-an', '-i', inputFile, - '-acodec', "libfdk_aac", # output audio codec + '-acodec', acodec, # output audio codec '-b:a', "192k", '-vcodec', "libx264", '-pix_fmt', "yuv420p", '-preset', "medium", - '-f', "mp4", - outputFile], + '-f', "mp4"] + + if acodec == 'aac': + ffmpegCommand.append('-strict') + ffmpegCommand.append('-2') + + ffmpegCommand.append(outputFile) + + out_pipe = sp.Popen(ffmpegCommand, stdin=sp.PIPE,stdout=sys.stdout, stderr=sys.stdout) smoothConstantDown = 0.08