Opened 14 years ago
#20 new defect
Volume normalization
Reported by: | mats_a | Owned by: | |
---|---|---|---|
Priority: | major | Component: | client |
Keywords: | Cc: |
Description
Below is some volume-normalization code I wrote, since mplayer's -volnorm can cause distortion. The idea is to ask mplayer to return the average dB volume of the song and subtract that off from a base. Downside: sound daemon volume will need to be set a bit higher. I'll try to port it to Perl when I get around to adding argument support to gbr, but if someone else wants to handle this please go ahead.
#!/usr/bin/python """ author: Mats Ahlgren licensed under whatever Gutenbach wants % ./get-loudness.sh MUSICFILE.mp3 {'max_volume': ' -1 dB', 'histogram_3db': ' 10607', 'mean_volume': ' -19 dB', 'n_samples': ' 43497216', 'histogram_4db': ' 29967', 'histogram_5db': ' 53578', 'histogram_1db': ' 1', 'histogram_2db': ' 725'} let $v = 20-mean_volume <-- necessary because boosting volume above 0 can cause distortion then do: mplayer -af volume=$v MUSICFILE.mp3 """ from subprocess import * import sys args = sys.argv[1:] assert len(args)==1 arg = args[0] command = "mplayer -quiet -ao pcm:fast:file=/dev/null -af stats".split() + [arg] output = Popen(command, stdout=PIPE, stderr=PIPE).communicate()[0] stats = dict(line[7:].split(':') for line in output.split('\n') if ('stat' in line)) print stats
Note: See
TracTickets for help on using
tickets.