Introduction
I recently set up a Raspberry Pi-based music player based on Rune Audio. At its core it uses Music Player Daemon (MPD) – but I found that MPD wouldn’t read the ID3 tags on a lot of my music tracks. After some investigation I narrowed it down to the .mp3 music tracks that had been created by iTunes on my Windows PC around 2014 – the tags could be read OK by iTunes and my iPod, but MPD couldn’t read them. (The .m4a tracks were fine.)
So what to do about it? I reckoned that I had two options: re-rip my entire music collection, or try and repair the ID3 tags. I chose the latter. I must admit it did take me a while to work out the quickest way of doing this, hence my writing this article in case it saves anyone else some pain. But I’m sure that this approach will be quicker than re-ripping the tracks.
I used two Linux tools: id3v2
and eye3D
. I found that eye3D
was that it was more restrictive in the tags that it would understand, so this has the benefit that if eye3D
can display the tags correctly then MPD will read them correctly too. The fact that eye3D
is more restrictive in the tag format that it can handle is also a disadvantage – if it’s not happy with the existing ID3 tags then it may not be able to re-write them – so that’s where id3v2
comes in. I found that even if the tags are incorrect then it is capable of re-writing them correctly. In fact id3v2
can read both ID3v1 and ID3v2 tags and it’s more tolerant about the input format that it can accommodate.
The fact that both ID3v1 and ID3v2 tags exist contributed to the confusion: if a track has just ID3v1 tags then it might appear absolutely fine on some systems but be invisible to MPD. I also found that for some albums the tracks were listed on Rune Audio in the wrong order.
Warning
There are no guarantees that this will work for you, and make sure that you read the help messages associated with the tools in order to understand what the various commands do.
Installing the tools
The exact process for installing the tools will depend on the flavour of Linux that you’re using. RuneAudio is built on ArchLinux, so you can install the tools on that by running the following commands:
pacman -S id3v2 pip install eyeD3
Approach
In the end the approach that I adopted was as follows:
1. Back up the whole music collection so that if there is a problem with the tag manipulation you can always revert to the original version.
2. Work on one directory at a time, and do the following:
3. Use eye3D
to view the tracks in a directory (eye3D *.mp3
) – if for each track the track name, artist name, album name etc are visible then the tracks are fine.
A quick way of checking all the files in a directory is by running the following command:
clear; eyeD3 *.m* |grep disc; eyeD3 *.m* |grep track; eyeD3 *.m* |grep title; eyeD3 *.m* |grep album; eyeD3 *.m* |grep artist
(If they are all displayed correctly then nothing else needs to be done with the tracks in this directory.)
4. Use id3v2
to delete the COMM and PRIV tags as they may be causing a problem, and it also re-writes the ID3 tags in a correctly formatted manner.
A quick way of doing this is to run the following command:
id3v2 -r COMM *.m*; id3v2 -r PRIV *.m*
5. Use id3v2
to delete the ID3v1 tags.
A quick way of doing this is to run the following command:
id3v2 -s *.m*
6. Force some ID3 tags to be over-written by writing the disc number tag and the tag for the total number of discs in the collection, first of all setting it to an incorrect value and then setting it to the correct value. This can be combined with the previous step.
For single albums run the following:
id3v2 -s *.m*; eyeD3 -d 2 -D 2 *.m*; eyeD3 -d 1 -D 1 *.m*
(It’s initially setting it to album 2/2, then updating it to 1/1, to ensure that the tags are definitely being overwritten.)
For the first CD from double albums run the following:
id3v2 -s 1*.m*; eyeD3 -d 2 -D 2 1*.m*; eyeD3 -d 1 -D 2 1*.m*
For the second CD from double albums run the following:
id3v2 -s 2*.m*; eyeD3 -d 1 -D 1 2*.m*; eyeD3 -d 2 -D 2 2*.m*
7. Fill in the gaps.
Run this set of commands again:
clear; eyeD3 *.m* |grep disc; eyeD3 *.m* |grep track; eyeD3 *.m* |grep title; eyeD3 *.m* |grep album; eyeD3 *.m* |grep artist
If the album name is missing then run this command:
id3v2 -A "<album name>" *.mp3
If the artist name is missing then run this command:
id3v2 -a "<artist name>" *.mp3
If the total number of tracks is missing then run this command:
eyeD3 -N <total number of tracks> *.mp3
For example, this will set the total number of tracks to 12 on all the audio tracks:
eyeD3 -N 12 *.mp3
Sample results
This is the output from running this command:
clear; eyeD3 *.m* |grep disc; eyeD3 *.m* |grep track; eyeD3 *.m* |grep title; eyeD3 *.m* |grep album; eyeD3 *.m* |grep artist
on one of the directories in my collection:
disc: 1/2 disc: 1/2 disc: 1/2 disc: 1/2 ... track: 1/20 track: 2/20 track: 3/20 track: 4/20 ... title: So This Is Christmas title: Do They Know Its Christmas title: Merry Christmas Everybody title: I Wish It Could Be Christmas E ... album: Now! The Christmas Album (Disc 1) album: Now! The Christmas Album (Disc 1) album: Now! The Christmas Album (Disc 1) album: Now! The Christmas Album (Disc 1) ... artist: John Lennon & Yoko Ono artist: Band Aid artist: Slade artist: Wizzard ...
Final notes
It may seem clunky at first but after a while you’ll be able to rattle through the various operations you need to do on the files in each directory, and I’m sure it ends up being quicker than re-ripping the whole music collection.
So hopefully this will save someone out there some time.
Vaughan
Leave a Reply