This is an update to the replaygain tag script posted previously to
rockbox-dev. This version fixes a bug, where files with some special
characters in the filename (namely ') could not be processed.
The script works that way:
First use the well known mp3gain program to calculate track and album
gain and peak values. mp3gain does write this information as APE-tags,
not suitable for rockbox. So, the replaygain information is read back
from the APE tags (via mp3gain) and then ID3V2 tags are written with
mp3gain needs to be called twice for every file, because in the first
step we have to give it all files of a folder as argument, so it will
calculate album gain, then that information is read beack
individually. Consequently, all files inside a folder are treated like
one album with the same album gain for all of them. This may not be
true quite often, but does no harm, as you would play a totally mixed
up folder with activated track gain and only switch to album gain for
Be aware: Because mp3gain is calculating the album gain for a
directory, it will recalculate the whole directory, if only one file
has been added.
Put all three fills in a directory which is in your executable path.
will take a directory as argument and process all mp3 files in that
will also take a directory as argument. It`s a wrapper for
replaygain_tag.sh, that will call it for every subdirectory.
contains some shared functions for the two scripts above.
Yes, there are some bugs. Therefore this is only a beta version.
All bugs relate to the usage of eyeD3 as ID3V2 tagger.
First bug, maybe fixed: If a file contains ID3V1 tags, eyeD3`s output
clearly says, that it is writing the replaygain tags. However,
re-reading them with eyeD3 still shows only ID3V1 and of course there
a no gain tags. So, I tried extenting the script by converting ID3V1
tags to ID3V2 with the --to-v2.4 option first. This proved to be a
good solution, but I wonder if it is possible, that a file holds ID3V1
and ID3V2 with different content and what the results would be. Had no
time to make the neccessary tests yet. Anyone enlighted?
eyeD3 V0.6.4 would not show the user text info, when any of the tags
contained characters outside the ascii range. Instead this error msg
was shown: "'ascii' codec can't encode character u'\xf3' in position
61: ordinal not in range(128)". Therefore the old tag data was always
read as empty and the tags rewritten with every update run. This has
been fixed for some files with at least eyeD3 V0.6.10, but still some
files remain raising this error.
eyeD3 V0.6.4 can not process ID3V2.2 tags. Converting ID3V2.2 tags
will therefore fail and applying the replaygain tags also. Seems to
be fixed with eyeD3 V0.6.10.
BTW: Converting to ID3V2 beforehand is neccessary. It you would just
write ID3V2 tags with the -v2 option, the replaygain tags would be
written, but the resulting file would then contain ID3V2 tags with
only replaygain information and ID3V1 tags with the artists
information. At least rockbox cannot merge this, so you would
practically lose the artist information.
Thanks for all comments and improvements,
Received on 2006-09-29