Encourage FUNIX

The consultation of the site is completely free and without advertisements. Donations are nevertheless appreciated to pay for hosting and encourage its author


Manage audio metadata and playlists

[ Overview    | Tagging your audio files ( Automatically tagging with MusicBrainz Picard   , manually tagging with kid3 ) Managing playlists ( playlist formats , creating playlists automatically , creating playlists manually ) ]

Manage audio metadata and playlists

Last modified February 20, 2025

This site has been automatically translated with Google Translate from this original page written in french, there may be some translation errors

Presentation

The purpose of this page is to introduce you to tools for managing the metadata of your audio files which will then allow you to create playlists.

We assume that you have installed the basic libraries for making video .

Tag your audio files

First of all just a quick word about the audio metadata format. ID3 is the de facto standard used for audio metadata which stands for "IDentify an MP3", but actually it doesn't only apply to MP3 files, it also works for FLAC or OGG files. It comes in several versions:
  •    ID3v1 : this is the first version, where we find the title, the artist, the album, the year of release, a comment and the musical genre
  •    ID3v1.1 : same with the track number on the album
  •    ID3v2 : it's much richer, you can add just about anything and everything, in addition to the album image, you can go as far as the lyrics of the track, the composer, the arranger, etc. the ReplayGain field makes its appearance, it gives the sound volume of the track and allows an audio player to normalize the sound. The latest version of this standard is ID3v2.4 which dates from 2000.
ID3 is not the only format for encoding audio metadata, without mentioning proprietary formats (iTunes, ASF/Windows media, ...) there are also documented and open formats:
  • the APE  tags that exist in the APEv1 and APEv2 versions , of which we will find here the description of all the fields, it has the defect of not embedding an image of the album
  • the vorbis  tags which can be used for Vorbis , FLAC , Theora and Speex audio files , we will find the format of the different fields there
It is quite difficult to compare these different formats, they all integrate the different fields that go well including ReplayGain, ID3 is the most used format and it is the assurance that most readers recognize it even in its latest version, the APE format is given to be simpler and more flexible with better recognition of different languages, but it does not integrate images.
On the other hand, looking to the future, we can see that the latest version of ID3 dates back to 2000, which is a century in terms of IT, and that the official site has not changed for over 10 years now. It still smells a bit like a screeching halt and we can wonder if other formats will not eventually supplant it. The problem also arises for the MP3 format , but that is another subject.

In any case, it will be necessary to avoid the mix of metadata formats made possible by the fact that ID3 and APE tags can be found in the same file at the beginning and at the end (and vice versa), this can lead to conflicts and reading errors depending on the player.

Automatically tag with MusicBrainz Picard

On most modern audio players, regardless of the medium ( mp3 player , mobile phone, etc.), the tags of the audio files are displayed during playback (artist, title, album, illustration image, ...) but it may turn out that they are badly tagged (tagged to speak French correctly!) for x reasons. Moreover, the interest of tags is to be able to create playlists by selecting the year, the artist or the name of the album for example.
MusicBrainz Picard is a tool to identify audio tracks and tag them properly more or less automatically. For the record and Star Trek fans, the name Picard comes from the name of the Enterprise ship commander Jean Luc Picard in the series Star Trek: The Next Generation.
To install picard, nothing could be simpler, we will first install the packages chromaprint and python3-fasteners , python3-qt5-multimedia then mutagen , which is a python module to manipulate audio metadata, which can be found here  https://github.com/quodlibet/mutagen . We unzip it by typing:

tar xvfz mutagen-release-1.47.0.tar.gz

then in the mutagen-release-1.47.0 directory thus created we type as root:

python setup.py install

On the Picard site we retrieve the archive which we decompress by typing:

tar xvfz picard-2.13.3.tar.gz

this gives the picard-2.13.3 directory   in which we type as root:

python setup.py install

It seemed useful to me to create an account on the MusicBrainz site , which defines itself as a free musical encyclopedia that collects musical metadata that anyone can contribute to and enrich.

You launch picard by simply typing picard in a shell. In the options, I indicated my MusicBrainz account, picard then sends me back to the site and gives me an activation code that I have to enter, so in the end it gives this

I left the settings at their defaults, or almost, here are some interesting configuration pages, first on the tag format.


My audio files are correctly named for me (Artist - title.extension), so I don't want Picard to rename them for me, so I explicitly indicated it in the window below, if it's a mess on your side, it is probably useful to check the Rename files on save box.


In the window below we must indicate the tool to take the audio fingerprint of a file, that is to say fpcalc (acoustID fingerprinter) we also enter the API key that we will obtain by clicking on Obtain the API key

On this page, you can activate plugins, for the moment I have not considered it useful to add any


Here is an interesting page, you have to indicate the port (by default 8000) which will serve as a link between the default browser and picard


This is the main window of Picard

On the left we move in the tree, we select the titles to identify that we drag and drop in the middle column, by default all the files are unmatched. We select them and click on Search, Picard will search in its database for the files whose tags correspond best to ours, on the right we will see all the corresponding albums that Picard has found. We can just regret that for many it is compilation albums that appear and not the original album, there are also false positives, a song that is attributed to someone else, but we will see later how to deal with this. For some we will have a message impossible to load the album , to resolve this you must select the unloaded albums and with the menu accessible by a right click choose Refresh , do not hesitate to insist, it sometimes loads after 4 or 5 times. There are still a number of files in the middle column without a match, you will have to select them again and do Search several times, because strangely it continues to identify files when it had not done so before. For those that it would not have identified, it could come from a file not tagged well at the base or badly named, in this case check and modify the Artist and Title tags and start again. In the end I often have less than 5% of unidentified files which is not huge, we select the albums in the banner on the right that were found and we save the total from the context menu. All the files will be modified with the correct tags by also adding an illustration image and that's it. The unsaved albums and files appear in the banner on the right with a small star on the disk.

If your files are poorly tagged at the base, the search can be more laborious, you must start by tagging them correctly. It can be laborious to modify the tags of the files one by one, so if they are well named like my artist – my title.mp3. We have a very practical tool that will do this automatically, we select the files, then we click on Tools->Tag from file names. For the naming style above, we will take %artist% – %title% which will allow us to properly tag the file and then launch a more efficient search. If the correctly tagged files have still not been identified, I encourage you to at least save them (select the files in the middle banner then save from the context menu.

When the search becomes unsuccessful, we can move on to searching based on their acoustic signature by clicking on Analyze, Picard will calculate the acoustic fingerprint of the file by comparing it with those present on the fingerprint server.

For the remaining files, we can assume that they are not in the Picard database, so we can enrich it and share it with the community with the correct associated tags by selecting the track and clicking on Send AcoustIDs

You will have noticed that Picard classifies audio files by album and not by artist (for example), each file is attached to an album and the image associated with the file visible in the audio player is the one attached to the album. For my part, my mp3s are stored in directories by musical genre, when I move from one directory to another I quit Picard and restart it to start from a blank screen without preloaded albums. In Picard's philosophy, the files are basically classified by album, with one directory per album, in this case you will have to use the Clusters function instead , this page (in English) explains how to do it. In summary, we select the album directory, drag it into the middle banner and click on the Group tool, the album will be found at the Cluster tree level in the middle banner and in the same way we will click on Search or Analyze to find the corresponding album.

Now what to do with unmatched files? Just select the corresponding file in the middle banner and then with the context menu choose Search for similar tracks


and there normally we should find our happiness, sometimes we have to try several entries, not all are necessarily associated with an image of the artist or the album. Once the file is associated with a track, it will automatically switch to the right banner, attached to the corresponding album which will appear (with a small star to show that it has not yet been saved).
Another method, we select the track then we click on Search in the browser, automatically we are sent back to the browser which displays the matching tracks



We select the one that seems closest to us and we click on the TAGGER button, it then automatically returns us to picard, the file is automatically switched to the right in the album tree. All that remains is to save it from the context menu.



For the false positives in the banner on the right, that is, the files that have been associated with bad tracks, in the banner on the right we will select the track in the corresponding album, and in the same way from the context menu we will choose Search for similar tracks.
We will proceed in the same way for the tracks associated with compilations if we want to associate them with the albums of the artist concerned.

The problem with Picard is that everything is almost automatic and there is no way to manually modify the audio metadata of an audio track, for that you will have to first create or modify an entry directly on the MusicBrainz site. There are many other tools that allow you to modify them but few allow you to integrate an image directly into the file. I turned away from easyTAG which still does all that automatically without you really having control over what is happening.
To be able to really control what is happening, I turned to Kid3, which we will get from the site https://kid3.kde.org/, I settled for the version provided by my Mageia system for the installation. Actually Kid3 is also capable of automatically filling in audio track tags but we will use it to do it manually for which it is very powerful.
Kid3 looks like this

An audio track can be identified by ID3v1.1 and ID3v2.30 tags, the information is obviously much richer with the latest version and the information fields are longer (especially for the name of the artists and the album), we also find the image of the album. The fields of the ID3v2.30 tags, they were filled in automatically by picard.

Note that a number of tracks are marked in red, in fact it is because they do not fully respect the ID3 standard. If we look at the configuration, they appear because the " Mark violations of the standard " field is checked by default.

By default we will also choose the ID3v2.30 version which is better recognized by most readers than v2.40 even if the latter dates from 2000!

for the character set, we have the choice between

  • ISO -8859-1 , which allows almost all French characters to be recorded;
  • ISO -8859-15 , a variation of ISO -8859-1 , which adds the "euro" symbol and the "e in the o"
  • UTF -8 , which theoretically allows all languages ​​to be encoded, from French to Japanese to Arabic.

Even if UTF -8 is preferred today, here too we would prefer to use ISO-8859-1 which is still the most recognized by audio players.

Let's go back to our tracks whose metadata does not respect the format, the field concerned appears in red, this problem could be problematic on some players and it is better to fix it. Simply select the field concerned and modify or delete it (be careful to use the Delete button at the bottom of the list, above the image and not the one above which deletes all v2.30 tags).


In this case we see that it is the Arranger field that is causing the problem, we are not going to delete it track by track, you can select several tracks and delete this Arranger field globally


In the same way, you can modify any field of a track group in a single manipulation. In the same way, you can filter the tracks according to certain criteria from the Tools->Filter... menu.
In the case below we will filter only the tracks that do not have an embedded image.

M3U (MPEG version 3.0 URL) is the most common format that was originally created by the WinPlay3 software published by the German company Fraunhofer, incidentally the creator of MP3, and has become a de facto standard. It contains a list of multimedia files simply identified by their address ( URL ). It is a simple file with one address per line with the extension .m3u if the text is encoded with a non- unicode encoding or with the extension .m3u8 if the text is encoded in unicode UTF-8. The address can have the following format:
  • Absolute path to the file
  • Relative path to the file relative to the M3U file
  • URL of a remote file
The Extended M3U contains additional fields identified at the beginning of the line by a "#" and ending with a ":" if there is text that follows, without being exhaustive, we find for example :
  • #EXTM3U - placed in the file header indicating that the Extended M3U format is used
  • #EXTINF: track information
  • #PLAYLIST: The title of the playlist

Here is an example of a file in extended M3U format

#EXTM3U
#EXTINF:227,Roé - Soledad
/ultra/data/music/genre ranking/pop/Roe - soledad.mp3
#EXTINF:141,Al Martino - Volare
/ultra/data/music/genre ranking/pop/Al Martino - Volare.mp3
#EXTINF:218,Nek - Laura non c'e
/ultra/data/music/genre ranking/pop/Nek and Cerena - Laura non ce.mp3

(...)

/ultra/data/music/genre ranking/pop/Manu Chao - Bongo Bong.mp3
#EXTINF:219,Gilberto Gil - Toda menina baiana
/ultra/data/music/genre ranking/pop/Gilberto Gil - Toda Menina Baiana.mp3
#EXTINF:248,Umberto Tozzi - tu
/ultra/data/music/genre ranking/pop/Umberto Tozzi - tu.mp3

The number in front of the track name is the length of the track in seconds.

Another format XSPF is a free alternative to M3U or other proprietary list formats that we will not discuss here such as PLS for iTunes or ASX for Windows Media. It also works on the principle of an address list but in XML format and supports unicode. It gives something like this:

<?xml version="1.0" encoding="UTF-8"?>
<playlist version="1" xmlns="http://xspf.org/ns/0/">
  <trackList>
    <track>
      <location>/ultra/data/musiques/classification by genre/pop/Roe - soledad.mp3</location>
      <title>Soledad</title>
      <creator>Roé</creator>
      <album>Roé</album>
      <duration>227000</duration>
      <trackNum>1</trackNum>
      <image>(embedded)</image>
    </track>
    <track>
      <location>/ultra/data/music/sort by genre/pop/Al Martino - Volare.mp3</location>
      <title>Volare</title>
      <creator>Al Martino</creator>
      <album>Best of Al Martino</album>
      <duration>141000</duration>
      <trackNum>1</trackNum>
      <image>(embedded)</image>
    </track>

(...)

    <track>
      <location>/ultra/data/music/classification by genre/pop/Umberto Tozzi - tu.mp3</location>
      <title>tu</title>
      <creator>Umberto Tozzi</creator>
      <album>Tu</album>
      <duration>248000</duration>
      <trackNum>1</trackNum>
      <image>(embedded)</image>
    </track>
  </trackList>
</playlist>

Now to automatically create your playlists, assuming that the audio files have been correctly ID3 tagged, we can do it automatically by bash script. As a first approach, we can always create simple playlists that will not take ID3 tags into account by simply browsing a directory and subdirectory and putting all the audio files in a playlist.m3u file.

#!/bin/bash
read -p "Chemin absolu ou relatif (par défaut relatif) " chemin
if [ "$chemin" = "absolu" ]
then
    path=$(pwd)
else
    path="."
fi
playlist="playlist.m3u"
rm -f $playlist
IFS=$'\n'
for fichier in $(find $path type f | grep '/*.ogg\|/*.mp3\|/*.flac')
do
      echo "Fichier trouvé $fichier"
      echo $fichier>>$playlist
done;
unset IFS

Ce script a la particularité de laisser le choix entre mettre un chemin absolu ou relatif dans la liste de lecture, le chemin relatif sera intéressant si vous importez votre bibliothèque audio sur un téléphone mobile. Il faudra faire en sorte d'avoir une arborescence relative identique et le fichier de liste de lecture placé au même endroit pour qu'il puisse retrouver les fichiers audio sans se soucier de leur chemin absolu.

Maintenant si on veut exploiter les métadonnées ID3, on pourra utiliser la commande ffprobe qui vient avec la suite ffmpeg, le script ci-dessous va créer automatiquement une liste de lecture en filtrant sur le genre musical, toujours en demandant si l'on souhaite un chemin absolu ou relatif

#!/bin/bash
read -p "Genre musical : " genre
read -p "Chemin absolu ou relatif (par défaut relatif) " chemin
if [ "$chemin" = "absolu" ]
then
    path=$(pwd)
else
    path="."
fi
playlist="playlist-$genre.m3u"
rm -f $playlist
IFS=$'\n'
for fichier in $(find $path type f | grep '/*.ogg\|/*.mp3\|/*.flac')
do
   if ffprobe -loglevel quiet -hide_banner -show_entries format_tags=genre -of default=noprint_wrappers=1:nokey=1 $fichier 2>&1 | grep -i $genre ; then
      echo "Fichier trouvé $fichier"
      echo $fichier>>$playlist
   fi
done;
unset IFS

To convert your .m3u playlists to .m3u8 or .xspf which can be more portable on other media, you can simply use vlc , load the playlist in M3U format and then from the Media->Save Playlist... menu you will choose the output format from the drop-down list.



To create your playlists manually and simply, you can use an application. Personally, I use Clementine, which integrates intelligent multi-criteria playlist management based on ID3 metadata.



You will then have the choice of saving your playlist in different formats M3U , XSPF , PLS and ASX as already mentioned here but also CUE and WPL.

Whatever the format, clementine will save the paths in absolute, to convert them to relative for the reason mentioned above, we can use this little script

#!/bin/bash
read -p "Enter filename: " file
read -p "Enter string to replace: " string1
read -p "Enter replacement string: " string2
echo "Processing $file ..."
tempfile=$(basename "$file" | cut -d. -f1)
extension="${file##*.}"
sed "s|$string1|$string2|g" $file > "$tempfile-relative.$extension"

[ Back to home ] [ Back to top of page ]