From 42dfaf9536e79f436d4f570bc761f238219727bd Mon Sep 17 00:00:00 2001 From: Guillaume Pellerin Date: Wed, 21 Oct 2015 12:15:40 +0200 Subject: [PATCH] goto avconv instead of ffmpeg, mp3 intead of aac, 8 threads for x264 --- tools/scripts/transcode/remux_fix_media.py | 8 ++++---- tools/scripts/transcode/transcode.py | 18 ++++++++++++++---- 2 files changed, 18 insertions(+), 8 deletions(-) diff --git a/tools/scripts/transcode/remux_fix_media.py b/tools/scripts/transcode/remux_fix_media.py index a95a3bae..2a988869 100755 --- a/tools/scripts/transcode/remux_fix_media.py +++ b/tools/scripts/transcode/remux_fix_media.py @@ -57,7 +57,7 @@ class FixCheckMedia(object): def hard_fix_webm(self, path): try: tmp_file = self.tmp_dir + 'out.webm ' - command = 'ffmpeg -loglevel 0 -i "'+ path + '" -vcodec libvpx -vb 500k -acodec libvorbis -aq 7 -f webm -y "' + tmp_file + '" > /dev/null' + command = 'avconv -loglevel 0 -i "'+ path + '" -vcodec libvpx -vb 500k -acodec libvorbis -aq 7 -f webm -y "' + tmp_file + '" > /dev/null' print command os.system(command) command = 'mv ' + tmp_file + path @@ -69,12 +69,12 @@ class FixCheckMedia(object): def fix_webm(self, path): try: tmp_file = self.tmp_dir + 'out.webm' - command = '/usr/local/bin/ffmpeg -loglevel 0 -i "' + path + '" -vcodec copy -acodec copy -f webm -y "' + tmp_file + '" > /dev/null' + command = 'avconv -loglevel 0 -i "' + path + '" -vcodec copy -acodec copy -f webm -y "' + tmp_file + '" > /dev/null' print command os.system(command) ebml_obj = EBMLData(tmp_file) offset = ebml_obj.get_first_cluster_seconds() - command = '/usr/local/bin/ffmpeg -loglevel 0 -ss ' + str(offset) + ' -i "' + tmp_file + '" -vcodec copy -acodec copy -f webm -y "' + path + '" > /dev/null' + command = 'avconv -loglevel 0 -ss ' + str(offset) + ' -i "' + tmp_file + '" -vcodec copy -acodec copy -f webm -y "' + path + '" > /dev/null' print command os.system(command) except: @@ -82,7 +82,7 @@ class FixCheckMedia(object): def fix_mp3(self, source, path): try: - command = '/usr/local/bin/ffmpeg -loglevel 0 -i "'+ source + '" -vn -aq 6 -y "' + path + '" > /dev/null' + command = 'avconv -loglevel 0 -i "'+ source + '" -vn -aq 6 -y "' + path + '" > /dev/null' print command os.system(command) except: diff --git a/tools/scripts/transcode/transcode.py b/tools/scripts/transcode/transcode.py index 4a083350..6cee6308 100755 --- a/tools/scripts/transcode/transcode.py +++ b/tools/scripts/transcode/transcode.py @@ -18,13 +18,13 @@ class Logger: source_format = 'webm' preview_tc = '00:00:05' -threads = 4 +threads = 8 ffmpeg_args = { 'mp3' : '-i "%s" -vn -acodec libmp3lame -aq 6 -ac 2', 'ogg' : '-i "%s" -vn -acodec copy', 'mp4' : '-i "%s" -vcodec libx264 -threads ' + str(threads) + \ - ' -c:v libx264 -crf 17 -maxrate 1100k -bufsize 1835k -acodec libfaac -ab 96k -ac 2', + ' -c:v libx264 -crf 17 -maxrate 1100k -bufsize 1835k -acodec libmp3lame -aq 6 -ac 2', 'png' : '-ss ' + preview_tc + ' -i "%s"', } @@ -33,6 +33,8 @@ log_file = args[-1] root_dir = args[-2] logger = Logger(log_file) + + for root, dirs, files in os.walk(root_dir): for file in files: path = os.path.abspath(root + os.sep + file) @@ -42,8 +44,16 @@ for root, dirs, files in os.walk(root_dir): local_file = name + '.' + format dest = os.path.abspath(root + os.sep + local_file) local_files = os.listdir(root) - if not local_file in local_files or '--force' in args: - command = 'ffmpeg -loglevel 0 ' + ffmpeg_args[format] % path + ' -y "' + dest + '"' + trig = True + for filename in local_files: + if '.' + format in filename: + trig = False + break + if (not local_file in local_files and trig == True) or '--force' in args: + command = 'avconv -loglevel 0 ' + ffmpeg_args[format] % path + ' -y "' + dest + '"' logger.logger.info(command) if not '--dry-run' in args: os.system(command) + + + -- 2.39.5