MyID3: a Java ID3 Tag Library.
Description
Mp3 files encode their metadata (artist, song title, etc.) in ID3 tags.
This tag format is well documented at the site for the
open source c/c++
id3lib library,
which I strongly recommend over any other tag library.
MyID3 is a pure-Java library that can read & write ID3v1 and ID3v2 tags.
Although not yet version 1.0, MyID3 is working. I've tested it with a wide variety of mp3s.
It is
Open Source; free as in freedom and free as in beer.
Full support for .m4a/.aac/.mpa files coming soon.
Downloads
Version 0.82 released July 22nd, 2008.
Source distribution includes binary, source and this document.
This project has three dependencies:
-
Jakarta Regexp,
and
(tested up to version 5.2). Jakarta Regexp is available under the same license as MyID3:
the ASF (Apache) License.
-
Nanoxml,
a lightweight XML parsing library.
(tested up to version 5.2). Nanoxml is available under
the zlib/libpng License.
Note: Nanoxml is only neccesary if you use the included GUI test tool.
-
I've recently open sourced the last dependency of this project, sharedlib.
Usage
MyID3 exposes two apis: a simplified interface, and a "raw" interface.
The Simple Interface hides the differences between the ID3v1 and ID3v2.
It maps values from both tags into a MusicMetadata object which has
typed accessor methods for the following fields:
Album, Artist, Comment, Compilation, Composer, Composer2, DurationSeconds, Genre, Producer, ProducerArtist, SongTitle, Year.
import org.cmc.music.myid3.*;
import org.cmc.music.common.MusicMetadata;
File src = ?;
MusicMetadataSet src_set = new MyID3().read(src); // read metadata
if (src_set == null) // perhaps no metadata
...
Debug.debug("src_set", src_set); // dump all info.
Debug.debug("src_set", src_set.getArtist());
MusicMetadata metadata = src_set.getSimplified();
String artist = metadata.getArtist();
String album = metadata.getAlbum();
String song_title = metadata.getSongTitle();
Number track_number = metadata.getTrackNumber();
metadata.setArtist("Bob Marley");
File dst = ...
new MyID3().write(src, dst, src_set, metadata); // write updated metadata
The Raw Interface exposes the differences between the ID3v1 and ID3v2,
every frame,
as well as the underlying bytes, etc.
import org.cmc.music.myid3.*;
import org.cmc.music.common.MusicMetadata;
File src = ?;
MusicMetadataSet src_set = new MyID3().read(src); // read metadata
String id3v1_artist = src_set.id3_v1_raw.values.getArtist();
String id3v2_artist = src_set.id3_v2_raw.values.getArtist();
byte id3v1_tag_bytes[] = src_set.id3_v1_raw.bytes; // tag bytes
byte id3v2_tag_bytes[] = src_set.id3_v2_raw.bytes; // tag bytes
Vector id3v2_frames = src_set.id3_v2_raw.frames; //
if (id3v2_frames.size() > 1)
{
MyID3v2Frame first_frame = (MyID3v2Frame) id3v2_frames
.get(0);
String frame_frame_id = first_frame.frame_id;
byte frame_frame_bytes[] = first_frame.data_bytes;
}
Project status
Version 0.82 released July 22nd, 2008.
-
Windows Media Player chokes on string encoded in big-endian UTF-16.
I've switched to using little-endian.
-
Slightly improved Genre handling.
-
Rolled up a number of small changes and code cleanup.
Version 0.81 released November 18th, 2007.
-
Added Javadocs to source distribution.
I need to add javadocs for the primary public classes, but... it is a start.
-
Add support for PIC/APIC.
MusicMetadata now has getPictureList(), etc. methods.
PIC images are now preserved when upgrading ID32 tags from version 2 to 3 or 4.
Version 0.80 released October 6th, 2007.
-
Fixed subtle issues around Unicode handling. Removed dependency on nio to parse unicode.
Version 0.79 released August 19th, 2007.
-
Fixed a series of major bugs involving differences between ID3 version 2.3.0 and 2.4.0 tag and frame flags.
-
Remove a great deal of old cruft.
-
Fixed bugs around handling of UTF-8 text frames.
-
Reorganized the package structure of the project.
Version 0.78 released June 17th, 2007.
-
I've open sourced the last dependency of this project, sharedlib.
Version 0.77 released December 8th, 2006, fixing two encoding bugs.
-
Now writes ID3v2 tags in ID3v2.3.0 rather than ID3v2.4.0 as WinAmp and
iTunes weren't reading version 2.4.0 tags properly.
-
I've changed the frame order so that text frames always appear first.
-
I've added the MyID3Listener interface which makes debugging & extending the code easier.
Version 0.76 released September 16th, 2006, fixing a text encoding bug.
Version 0.75 released September 2nd, 2006.
To do list:
-
Improve support for embeded images (PIC/APIC).
-
m4a support.
-
Make "cleaning up" of metadata optional.
-
Better handling of non-numeric track numbers.
-
Finer-grained error handling.
-
-
Complete refactor of music metadata unification, metadata cleanup and &
binary frame handling.
Other music metadata libraries
I strongly recommend
id3lib.
It's fast, open source, and well-maintained. It is written in c/c++.
Javazoom's
JLayer & JLayerME.
This Java library decodes MP3 audio as well. Include a J2ME edition.
I'm sure there are others as well.
License