Jump to content

Gapless tags


Recommended Posts

I was quite happy with the implementation of gapless:

Optional gapless based on tags (if any) or based on silence detection (if no gapless tag set) (done - v1.4)

However soon I realized that none of my mp3's have `gapless tags' set...

Since I am paranoid with applications changing the id3 tags on my mp3's I'm using the python library mutagen to directly mass-edit tags and clean them up.

I'm not aware of a gapless id3 tag(http://www.id3.org/id3v2.4.0-frames) and did some research without any conclusions.

I read somewhere that Poweramp uses iTunes's unofficial id3 tags to receive gapless data however can not find much about the specifications of this presumably existing tag.

Can you point me in the right direction?

Thanks in advance!

Link to comment
Share on other sites

These tags are not strictly id3 tags.

For iTune encoded mp3 - they are id3 comment tag contents (numbers like 0000000040000 000000020000 etc).

For lame (and few other encoders) encoded files, it's special mp3 lame binary header.

As for mp4/m4a, these are also special iTune metadata "atoms".

Also, if your files was processed by some mp3 tagging software which modifies comments tag, iTunes gapless information will be lost.


Link to comment
Share on other sites

Unfortunately using mutagen, I can not easily edit the lame header. (unless, of course I learn the lame header specifications from part 0 and create my own API for it).

This makes the iTune comment tag the only way for me to change gapless data.

Now, the python module mutagen provides a really easy API to edit, create, delete id3 comment tags.

Pymad is a python module that gives me easy access to the MPEG audio decoder library, I can use numpy or some other mathematical python module to take a good guess at the skip lengths at the beginning and end of a song.

Now the only real problem left is getting the iTune comment tag's specifications so I can write recognizable gapless tags.

The problem is that I can not find any specifications for the iTune comment tag on the internet. Currently the only information I know about these tags is:

  • [*:lxz5qm6f]All numbers are 4 bytes long.
    [*:lxz5qm6f]There are 10 numbers in a iTune comment tag
    [*:lxz5qm6f]Numbers are shown as plain text hex, seperated by spaces.

What I ask of you is to give me some information on the following questions:

  • [*:lxz5qm6f]Are the numbers encoded big-endian or little-endian or do they use some kind of special encoding?
    [*:lxz5qm6f]What should the comment description and other id3 comment information like COMM.encoding COMM.language be? (I presume iTunes uses the comment description to easily recognize it's own comment tags..
    [*:lxz5qm6f]What number(s) is/are used for gapless?
    [*:lxz5qm6f]What logic do the gapless numbers use? skip-duration in milliseconds? (I presume two numbers, one for a positive skip at the beginning of the song, and two for a early end at the end of the song..

Thanks in advance!

Link to comment
Share on other sites

You can check this thread (http://www.hydrogenaudio.org/forums/ind ... opic=87847) and few others on this forum for information on iTunes gapless format.

The numbers are just usual hex numbers written as text (i.e. big endian). Encoding can be anything supported by id3 (i.e. plain ascii will do) and language=eng.

Note that mp3 decoder also has so-called latency, it's 529 stereo samples for layer3. It should be also accounted in your calculations.

Mp3 is trimmed at the beginning for delay plus latency and at the end - for padding minus latency.

Link to comment
Share on other sites


This topic is now archived and is closed to further replies.

  • Create New...