Read an Mp3s Files Information

The ID3 format used by Mp3 is considerably more complicated than other metadata formats, so you might need want to use the low level interface described as well as the common interface. An Mp3 can contain both a ID3v1 tag and an ID3v2 tag, both tags are optional. The ID3v1 tag can be version 1.0 or version 1.1. An ID3v2 tag can be version 2.2, 2.3 or 2.4 and the differences between the versions is quite considerable.

The stuff you might want to know about but you can't change is stored in the AudioHeader class

MP3File f      = (Mp3File);
MP3AudioHeader audioHeader = f.getAudioHeader();

Mp3 provides a subclass called MP3AudioHeader that contains additional information.


The metadata information that you can change is stored in tags. The getTag() method only returns the ID3v1 Tag , this is probably the tag you are least interested in. To get the ID3v2 tag you can use the getID3v2Tag() method. Alternatively Jaudiotagger provides a getID3v2TagAsv24() method, this returns the v2Tag converted to v24 format if it was not already in v24 format, the advantage of this is that you can treat all Mp3 files as if their v2 tag is in v24 format whether or not it actually is.

MP3File f      = (Mp3File);
Tag tag        = f.getTag();
ID3v1Tag         v1Tag  = (ID3v1Tag)tag;
AbstractID3v2Tag v2tag  = f.getID3v2Tag()
ID3v24Tag        v24tag = (AbstractID3v2Tag)f.getID3v2TagAsv24();

The v1 tag only contains a very limited set of fields, these can be read as follows


The rest of this document deals with the ID3v2 tag, you can check that an ID3v2 tag exists with


In ID3v2, fields are known as frames, for simple text fields you can extract the information with


Or you can retrieve the frame itself and then get details of its body with

AbstractID3v2Frame frame = v2Tag.getFirstField(ID3v24Frames.FRAME_ID_ARTIST);
if(frame.getBody() instanceof AbstractFrameBodyTextInfo)
	AbstractFrameBodyTextInfo textBody = (AbstractFrameBodyTextInfo)frame.getBody(); 

The list of all valid identifiers can be found in the class ID3v24Frames