User Tools

Site Tools


blog:what_is_the_only_correct_way_to_tag_flac_audio_files

What is the ONLY correct way to tag FLAC audio files?

I recently had an email correspondent question my frequent assertions that ID3 tags should not be present in FLAC files and that the only “proper” way to tag FLACs is with Vorbis Comments. It was a good-natured discussion and I thought I should write it up in a bit more detail.

A bit of History

First things first, then: there are two basic 'tagging schemes' available to anyone trying to markup their audio files with metadata: ID3 tags and Vorbis Comments.

ID3 version 1 (ID3v1) was invented around 1996 by Eric Kemp. It was very restrictive: all tags were stored at the end of the music file in just 128 bytes, with title, artist, album and comments having to fit into just 30 bytes each. Note that the tag names were given: you had no flexibility about what they were called, only what data you stored in each one. Accordingly, hardly anyone ever uses ID3v1 tags these days.

ID3v2 really has nothing to do with ID3v1, was invented in 1998 and allows for variable-sized data up to a whopping 256MB (megabytes!), which starts at the beginning of the music. There is a long list of “accepted” ID3 tag names, so you can't just store data in arbitrarily-named fields. If you wanted to store “bar number where key first modulates”, for example, there's no such tag in ID3 land! (But you'd be certifiable if you wanted to store that sort of data in the first place, so the loss is not -usually- a show-stopper!).

Both ID3 formats were thus invented around the time that MP3 was becoming a favourite audio format, thanks to its small size (and the poor modem speeds of the era which made small music files highly desirable). ID3 is therefore highly associated with MP3 files, though not exclusively, as I'll demonstrate shortly.

Vorbis Comments were invented around 2005 or so by the xiph.org development community, who were busy at that time inventing the open source Ogg Vorbis audio format. Hence the use of the name 'vorbis'. It just happens that xiph.org also invented the FLAC audio format; they naturally used the same tagging format that they'd invented for Ogg files when wondering how to tag FLAC files. A Vorbis tag is a list of fields in the field-name/data format; field names are case-insensitive and you can have up to 4 billion fields at a time (though most software won't read or wrote that many!). Any tag name is permitted and there's no specific format for the data stored in the tag; that said, certain 'standard' tags have become established (such as TITLE, TRACKNUMBER and so on, so that software can be written expecting certain bits of data to be found in certain places). But if you were really desperate to create a tag for “Bar number where first modulation occurs”, Vorbis Comments lets you do that.

So that's a bit of history: the story basically boils down to ID3 being associated with MP3s and Vorbis Comments with FLACs, largely because of the timing of their respective developments: ID3 were invented when fast Internet connections were rare and thus music downloads were generally of the smaller MP3 type; Vorbis Comments were invented at around the same time as FLAC, which began to be more useful as faster Internet speeds made sharing multi-Megabyte-sized files more feasible.

But it's not that simple: FLAC files can store ID3 tags!

A Worked Example

To take a simple example. Here I have a single FLAC track:

[[email protected] ~]$ cd Music/Symphony/
[[email protected] Symphony]$ ls
track01.flac

I can check if it has any Vorbis Comments in it:

[email protected] Symphony]$ metaflac --list track01.flac 
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4096 samples
  maximum blocksize: 4096 samples
  minimum framesize: 69 bytes
  maximum framesize: 8801 bytes
  sample_rate: 44100 Hz
  channels: 2
  bits-per-sample: 16
  total samples: 20844600
  MD5 signature: 1f06351acf4bac40cd153e5b4f07f5be
METADATA block #1
  type: 1 (PADDING)
  is last: true
  length: 25603

There are no Artist, Album, Track or similar-looking tags there!

I can also check that the file has no ID3 tags in it at all:

[[email protected] Symphony]$ id3v2 -l track01.flac 
track01.flac: No ID3 tag

(The 'id3v2' application needs to be installed for these examples to work, of course, as does 'metaflac', which is part of the 'flac' package. Both id3v2 and flac are commonly available in most distro's standard respositories).

In other words, this particular track01.flac is a clean slate, something we can also prove by looking at it in Easytag:

Look at the totally blank set of fields over on the right-hand side of the screen: not a jot of metadata in any of them!

Now let me add an ID3 tag to this file, even though it's a FLAC file. I shall achieve this feat by using the id3v2 program once more, this time with the -A switch, which means “set the Album name tag”:

[[email protected] Symphony]$ id3v2 -A "Symphony1" track01.flac

And let's check that:

[[email protected] Symphony]$ id3v2 -l track01.flac 
id3v1 tag info for track01.flac:
Title  :                                 Artist:                               
Album  : Symphony1                       Year:     , Genre: Unknown (255)
Comment:                                 Track: 0
id3v2 tag info for track01.flac:
TALB (Album/Movie/Show title): Symphony1

So the ID3v2 tag is definitely there, but we are still Vorbis Comment-less:

[[email protected] Symphony]$ metaflac --list track01.flac 
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4096 samples
  maximum blocksize: 4096 samples
  minimum framesize: 69 bytes
  maximum framesize: 8801 bytes
  sample_rate: 44100 Hz
  channels: 2
  bits-per-sample: 16
  total samples: 20844600
  MD5 signature: 1f06351acf4bac40cd153e5b4f07f5be
METADATA block #1
  type: 1 (PADDING)
  is last: true
  length: 25603

…with metaflac's output being no different from before. And, as before, we can check what our command-line addition of an ID3 tag to a FLAC file looks like in Easytag:

Note that Easytag is showing “Symphony1” in the Album field over on the right-hand side of its display: though it's a FLAC file, Easytag has no problem displaying an ID3 tag for it, if it's been put there by some other program.

Now let me add a Vorbis Comment to this same file, whilst doing nothing with the ID3 tag:

metaflac --set-tag=Artist=Beethoven track01.flac

Check with ID3:

[[email protected] Symphony]$ id3v2 -l track01.flac
id3v1 tag info for track01.flac:
Title  :                                 Artist:                               
Album  : Symphony1                       Year:     , Genre: Unknown (255)
Comment:                                 Track: 0
id3v2 tag info for track01.flac:
TALB (Album/Movie/Show title): Symphony1

Note that ID3 still knows this is Symphony1 but has no concept of who the Artist is. Back in metaflac, we see:

[[email protected] Symphony]$ metaflac --list track01.flac 
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4096 samples
  maximum blocksize: 4096 samples
  minimum framesize: 69 bytes
  maximum framesize: 8801 bytes
  sample_rate: 44100 Hz
  channels: 2
  bits-per-sample: 16
  total samples: 20844600
  MD5 signature: 1f06351acf4bac40cd153e5b4f07f5be
METADATA block #1
  type: 4 (VORBIS_COMMENT)
  is last: false
  length: 60
  vendor string: reference libFLAC 1.3.2 20170101
  comments: 1
    comment[0]: Artist=Beethoven
METADATA block #2
  type: 1 (PADDING)
  is last: true
  length: 25539

So, Vorbis Comments show the Artist is Beethoven, but has no idea what the piece is. From this, we can tell that whilst ID3 tags can co-exist with Vorbis ones, it's not a good idea to mix them in the one file, because each will only tell you part of the picture, and there's no way to synchronise them -so ID3 might tell you this is a work by Beethoven whilst Vorbis insists it's actually by Mozart.

What does Easytag show of this confusing state? This:

Hmm: this is where it gets interesting. Easytag is now displaying the Artist as Beethoven, in the 'Common' area of its tag display, but it's now stopped showing that the Album is “Symphony1”. Incidentally, if you think I'm not displaying the Vorbis Comments, because there's a heading there saying “FLAC Vorbis Tag” and I'm only showing the contents of the 'Common' area… well, you can click on those 'Flac Vorbis Tag' words all you want and it won't change the display or show you anything different at all. Only the 'Common' area is actually usable.

Putting it bluntly, confronted with a FLAC file containing both ID3 and Vorbis tags, Easytag ignores the ID3 tags completely (even though we can prove they are still contained within the audio file itself) and only displays the Vorbis tag contents.

So, if I were to add a piece of text to the “Copyright” field in Easytag, do you think that will be stored as a Vorbis tag or as an ID3 one, or maybe as both? There's only one way to find out. Here's me saving some text in that field in Easytag:

…the file name has gone bold, because the contents of the file have been changed. If I then click the 'Save' option, the tag will be written into the file… but in what format? Let's see:

[[email protected] Symphony]$ metaflac --list track01.flac 
METADATA block #0
  type: 0 (STREAMINFO)
  is last: false
  length: 34
  minimum blocksize: 4096 samples
  maximum blocksize: 4096 samples
  minimum framesize: 69 bytes
  maximum framesize: 8801 bytes
  sample_rate: 44100 Hz
  channels: 2
  bits-per-sample: 16
  total samples: 20844600
  MD5 signature: 1f06351acf4bac40cd153e5b4f07f5be
METADATA block #1
  type: 4 (VORBIS_COMMENT)
  is last: false
  length: 92
  vendor string: reference libFLAC 1.3.2 20170101
  comments: 2
    comment[0]: ARTIST=Beethoven
    comment[1]: COPYRIGHT=2019 Howard Rogers
METADATA block #2
  type: 1 (PADDING)
  is last: true
  length: 25507

So the new COPYRIGHT tag is there as a Vorbis Comment, along with the previous ARTIST tag added with metaflac as a Vorbis Comment. But has it been saved as an ID3 tag as well, perhaps?

[[email protected] Symphony]$ id3v2 -l track01.flac 
track01.flac: No ID3 tag

Wow! Without any warning, getting Easytag to write tags to a FLAC file has completely erased the ID3v2 tag we previously put there!

What do we conclude from this short trip through tagland? Well:

  1. It is possible to store ID3 tags in FLAC files;
  2. But a lot of GUI software will expect FLAC files to store Vorbis tags;
  3. And will write only Vorbis tags when saving to FLAC files;
  4. And will, moreover, erase any ID3 tags that were somehow previously stored in the FLAC file.

Most tagging software you will meet, therefore, expects FLAC and Vorbis Comments to go hand-in-hand, to the point where if a combination of tag types is found within a FLAC file, most tagging software will ignore (at best) or erase (at worst) the ID3 tags and their associated data… without asking permission or giving any form of warning.

It is for this reason that I strongly assert that you must use Vorbis Comments when tagging FLAC files and using ID3 tags with them is just wrong. It's not that it's impossible to use ID3 with FLACs, but you will be skating on thin ice if you do: one day, your carefully-crafted data stored in the 'wrong' sort of tag will be simply erased by the software you use, no questions asked nor apologies offered!

Another Worked Example

Now, if I'm using a more KDE-based distro, I'll tend to use Puddletag as my GUI tagger rather than Easytag. Does that behave any differently? Well, let's start off with a clean-slate FLAC file once more, add an ID3v2 tag to it and see what Puddletag makes of a FLAC file containing an ID3v2 tag:

Here, the situation is -if anything- even worse than before! When Easytag found an ID3 tag in a FLAC file, it at least displayed it (before eventually erasing it!). But here, though the id3v2 program for sure knows there's an Album tag in the file, Puddletag declares there is no metadata in the file at all!

But if I use Puddletag to set 'Beethoven' as the artist… id3v2 knows nothing about it:

Here you see Puddletag has “Beethoven” showing in the “Artist” field over on the right-hand side of the screen, but a fresh listing of tags in id3v2 in the terminal session displays… only the Album name as before.

Meanwhile, as you might expect by now, metaflac knows the Artist (a Vorbis tag written by Puddletag), but not the Album (an ID3 one, put there earlier by id3v2):

So, once again, although I'm now using a totally different tag editor than before, we have the same situation as before: Puddletag knows, just as Easytag did, that if it's writing to a FLAC file, it must save to Vorbis Comments tags.

Fine… But just to completely mess your head up, now that I've saved the Vorbis comment “Artist”, what's happened to my original ID3 tag “Album”? Let's just see:

Now there's quite a lot going on in that screenshot. The terminal window displays the metaflac output as before: it knows that artist=Beethoven, but nothing else. But then I run id3v2 and prove that Album=Symphony1, as previously set by id3v2 itself. In other words, we see that the file contains both sorts of tags simultaneously… and therefore my previous saving of the file in Puddletag did NOT silently erase the ID3v2 tags, as it did in Easytag.

Meanwhile, Puddletag itself remains convinced that there's an Artist tag, but no Album one.

If anything, this is even more confusing than Easytag (and is the reason I think I'd choose to use Easytag over Puddletag if I had the choice): Easytag at least makes everything consistently Vorbis Comments, albeit by the rather drastic expedient of silently deleting ID3 tags from FLAC files; Puddletag, however, displays only Vorbis Comments, but is quite happy to leave ID3v2 tags sitting there in the background whilst it's at it.

Ugh.

I come back to my original point with my email correspondent: stick to using Vorbis Comments for FLACs, because they are the only tags which both Easytag and Puddletag will display when working with FLAC files. And on the other side of the coin, definitely avoid using ID3v2 tags when working with FLACs, because one program will wipe them without warning and the other will simply ignore them without tell you!

So now you know!

blog/what_is_the_only_correct_way_to_tag_flac_audio_files.txt · Last modified: 2019/05/30 16:52 by dizwell