From 6dc24999bfb04cc1a8e189d512d732a9168fe104 Mon Sep 17 00:00:00 2001 From: pabloalcantara Date: Thu, 18 Aug 2011 10:41:59 -0300 Subject: [PATCH] Encode code optimizations --- headphones/encode.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/headphones/encode.py b/headphones/encode.py index 6e258392..4b7052ff 100644 --- a/headphones/encode.py +++ b/headphones/encode.py @@ -49,27 +49,27 @@ def encode(albumPath): if (music.endswith('.mp3') and (MP3(music).info.bitrate/1000<=headphones.BITRATE)): logger.warn('Music "%s" has bitrate<="%skbit" will not be reencoded' % (music,headphones.BITRATE)) else: - cmd=encoder+' -h --resample ' + str(headphones.SAMPLINGFREQUENCY) + ' -b ' + str(headphones.BITRATE) - cmd=cmd+' '+headphones.ADVANCEDENCODER - cmd=cmd+' "'+os.path.join(music)+'"' - cmd=cmd+' "'+os.path.join(musicTempFiles[i])+'"' + cmd=encoder + ' -h --resample ' + str(headphones.SAMPLINGFREQUENCY) + ' -b ' + str(headphones.BITRATE) + cmd=cmd+ ' ' + headphones.ADVANCEDENCODER + cmd=cmd+ ' "' + music + '"' + cmd=cmd+ ' "' + musicTempFiles[i] +'"' return_code = call(cmd, shell=True) if return_code==0: os.remove(music) - shutil.move(musicTempFiles[i],os.path.join(albumPath)) + shutil.move(musicTempFiles[i],albumPath) else: if (music.endswith('.mp3') and (MP3(music).info.bitrate/1000<=headphones.BITRATE)): logger.warn('Music "%s" has bitrate<="%skbit" will not be reencoded' % (music,headphones.BITRATE)) else: - cmd=encoder+' -i' - cmd=cmd+' "'+os.path.join(music)+'"' - cmd=cmd+' -ac 2 -vn -ar ' + str(headphones.SAMPLINGFREQUENCY) + ' -ab ' + str(headphones.BITRATE) +'k' - cmd=cmd+' '+headphones.ADVANCEDENCODER - cmd=cmd+' "'+os.path.join(musicTempFiles[i])+'"' + cmd=encoder+ ' -i' + cmd=cmd+ ' "' + music + '"' + cmd=cmd+ ' -ac 2 -vn -ar ' + str(headphones.SAMPLINGFREQUENCY) + ' -ab ' + str(headphones.BITRATE) + 'k' + cmd=cmd+ ' ' + headphones.ADVANCEDENCODER + cmd=cmd+ ' "' + musicTempFiles[i] + '"' return_code = call(cmd, shell=True) if return_code==0: os.remove(music) - shutil.move(musicTempFiles[i],os.path.join(albumPath)) + shutil.move(musicTempFiles[i],albumPath) i=i+1