Help: Adding ID3 Tags

Discussion in 'iPod' started by mrzeve, Sep 13, 2005.

  1. mrzeve macrumors 6502a

    Joined:
    Jan 25, 2005
    #1
    Hey let me just get right to the point.

    From my understanding of the subject the ID3 Tags are located in the last 128 bytes of the MP3 File.

    Those tags are:

    "Song title 30 characters
    Artist 30 characters
    Album 30 characters
    Year 4 characters
    Comment 30 characters
    Genre 1 byte

    If you one sum the the size of all these fields we see that 30+30+30+4+30+1 equals 125 bytes and not 128 bytes. The missing three bytes can be found at the very beginning of the tag, before the song title. These three bytes are always "TAG" and is the identification that this is indeed a ID3 tag. The easiest way to find a ID3v1/1.1 tag is to look for the word "TAG" 128 bytes from the end of a file."

    Okay so Ive created a technique for my program to grab the information of those tags, however, what if I want to add a new field.

    For example if you use iTunes 5 you can now add lyrics to the ID3 information. My question is, where in the tags are these lyrics added? How many bytes do I have to read into, how much can be stored in these tags for lyrics, etc etc.

    Any help in understanding this subject to a greater extent would be appreciated.
     
  2. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #2
    Short answer. Only ID3V1 stored them at the end of the file. ID3V2 as used in iTunes, places them at the beginning of the file and provides a lot more flexibility in what fields are supported. See http://www.id3.org for more info.

    B
     
  3. mrzeve thread starter macrumors 6502a

    Joined:
    Jan 25, 2005
    #3
    So can I assume that once a song is added to the iTunes database (atleast in iTunes 5) its converted to use ID3V2?

    I checked the site but couldnt find information on where in the actual id3 tag the lyrics are stored (for example at bit 30 or 50 or 95).
     
  4. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #4
    Not that simple. ID3V2 is essentially freeform compared with V1, allowing for variable size tags such as lyrics, album art, etc... These don't all have to be present in a given file and will not occur at fixed offsets.

    http://www.id3.org/id3v2.4.0-frames.txt details all the valid frames, and the one you are looking for is ths "USLT" unsynchronized lyrics frame. So if you look for USLT in the file you should find the lyrics.

    The best thing you could do is look at the sample implementations at http://www.id3.org/implement.html

    Note also that M4A files use a different tagging scheme, that is tangentially related to ID3V2, but is not the same.

    B
     
  5. mrzeve thread starter macrumors 6502a

    Joined:
    Jan 25, 2005
    #5
    Not to doubt, but are you sure that when iTunes adds the lyrics tag it is "USLT"?

    Also, any idea of my previous question of all these songs automatically getting a lyrics tab when they are added to the iTunes library?
     
  6. balamw Moderator

    balamw

    Staff Member

    Joined:
    Aug 16, 2005
    Location:
    New England
    #6
    Sorry, the original place I pointed you was documentation for the current ID3V2.4. Apparently iTunes uses the earlier ID3V2.3, in which the lyrics tag is stored in a "ULT" frame. See http://id3lib.sourceforge.net/id3/id3v2-00.txt. I verified this with a file on iTunes 5 on Windows. I put some lyrics in a file, and then loaded it in emacs. I can see the lyrics right after "ULT". I can also see the TT2, TP1, TYE, TCO, etc... headers and content representing the other tags of the file.

    As I said before, just because the file can have a lyrics tag (or a lyrics tab is shown in the UI) it doesn't mean that the file actually has a lyrics tag. This is true for all tags, including title, composer, grouping, artwork, etc...

    For example the file I'm looking at has no Composer tag, and thus "TCM" doesn't appear in the file, yet the empty composer field is in the UI.

    Make sense?

    EDIT: I just tried "Advanced -> Convert ID3 tags" and converted the file I added lyrics to to ID3V2.4. The ULT tag header was changed to USLT. Seems like iTunes supports more than one version of ID3.

    B
     
  7. mrzeve thread starter macrumors 6502a

    Joined:
    Jan 25, 2005
    #7
    Thanks a bunch.

    I think I have a pretty clear vision of what path I need to take and how Im going to make this all come together.

    I'll update the thread accordingly when the time is right.
     

Share This Page