Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

Click here to return to the 'Lossless adjusting of loudness for MP3 and AAC files' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
Lossless adjusting of loudness for MP3 and AAC files
Authored by: jctull on Apr 11, '05 05:03:13PM
Sorry, but the command should read:

find -iname "*.mp3" -print0 -or -iname "*.m4a" -print0 | xargs -0 -n1 aacgain -r -p -k -t

Please add corrections if this is not finding all of the files...

VERY IMPORTANT: Requires a newer version of findutils than is installed by default with OS X. I used fink to install a working version of findutils. If you are not familiar with fink, you can find out about it at

[ Reply to This | # ]

Lossless adjusting of loudness for MP3 and AAC files
Authored by: Xris on Apr 28, '10 03:56:40PM

I just used the built in find (in 10.5.8 that is):

Here is what I used (after changing to a directory that contains album folders):

xris$ find . -iname "*.m4a" -print0 | xargs -0 -n 1 /Users/xris/aacgain -r -p -k -t -m 4

I don't use mp3's, but you can easily add that if you need to. Note the "." (period) after find, that means "the current" directory, and I used the "-m #" to adjust the recomended gain UP slightly.

One interesting feature that can be exploited to great effect is the "-P" switch in xargs. This enables you to launch/start MULTIPLE instances of you comand, aacgain in this case, for every match found with find. I have a Core 2 Duo machine. Using only ONE instance of aacgain is a very lengthy process that does not tax the cpu very much... but with "-P 4" I get almost 100% cpu usage and takes a, well, almost half as long. I probably would get the same result with two, but just for kicks I went with 4!

So, the above looks something like:

find . -iname "*.m4a" -print0 | xargs -P 4 -0 -n 1 /Users/xris/aacgain -r -p -k -t -m 4

BTW: I could't get fink/macports/darwinports to install properly, I gave up on that and just fiddled with the buil-in version to get it to work. Ahh, also, I used the intel version of aacgain linked somewhere in this link.

As far as I'm concerned, aacgain works, although I did adjust the gain slighly up. On some stereos, thru the mini 3.5" plug, even at max volume it was a bit quiet for my taste.

[ Reply to This | # ]
Lossless adjusting of loudness for MP3 and AAC files
Authored by: sanzoghenzo on Feb 10, '11 03:39:39AM

Thanks for the hint!
I prefer to use album gain, and use only mp3 files.
The following will do the job:

find . -type d -exec sh -c 'set -- "$0"/*.mp3; [ -e "$1" ]' {} \; -print0 | xargs -P 4 -0 -n 1 -I % sh -c "aacgain -a -p -k -m 4 \"%\"/*.mp3"

This, in conjunction with beets and pylywi will tidy up your collection from CLI!

[ Reply to This | # ]