From b827321093819f00d9184364da905a41f4e0afea Mon Sep 17 00:00:00 2001 From: "cliff.wang" Date: Thu, 20 Mar 2014 13:02:37 -0400 Subject: [PATCH] cc-5747 Replaygain: doesnt work for aac tracks --- python_apps/pypo/media/update/replaygain.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/python_apps/pypo/media/update/replaygain.py b/python_apps/pypo/media/update/replaygain.py index 329a1e6a0..431933bda 100644 --- a/python_apps/pypo/media/update/replaygain.py +++ b/python_apps/pypo/media/update/replaygain.py @@ -56,6 +56,8 @@ def get_file_type(file_path): file_type = 'mp3' elif re.search(r'og(g|a)$', file_path, re.IGNORECASE): file_type = 'vorbis' + elif re.search(r'm4a$', file_path, re.IGNORECASE): + file_type = 'mp4' elif re.search(r'flac$', file_path, re.IGNORECASE): file_type = 'flac' else: @@ -64,6 +66,8 @@ def get_file_type(file_path): file_type = 'mp3' elif 'ogg' in mime_type: file_type = 'vorbis' + elif 'mp4' in mime_type: + file_type = 'mp4' elif 'flac' in mime_type: file_type = 'flac' @@ -111,6 +115,14 @@ def calculate_replay_gain(file_path): search = re.search(r'REPLAYGAIN_TRACK_GAIN=(.*) dB', out) else: logger.warn("vorbisgain/ogginfo not found") + elif file_type == 'mp4': + if run_process(['which', 'aacgain']) == 0: + command = ['nice', '-n', nice_level, 'aacgain', '-q', temp_file_path] + out = get_process_output(command) + search = re.search(r'Recommended "Track" dB change: (.*)', \ + out) + else: + logger.warn("aacgain not found") elif file_type == 'flac': if run_process(['which', 'metaflac']) == 0: