Author image Sander van Zoest


MP3::ID3v1Tag - Edit ID3v1 Tags from an Audio MPEG Layer 3.


  use MP3::ID3v1Tag;

  $mp3_file = new MP3::ID3v1Tag("filename.mp3");

  if($mp3_file->got_tag()) {
     $save_status = $mp3_file->save();


The ID3v1Tag routines are useful for setting and reading ID3 MP3 Audio Tags. Just create an MP3::ID3v1Tag Object with the path to the file of interest, and query any of the methods below.

To get a print out of all the header information (Default FileHandler), simply state the following


With an optional number of columns argument (default is 3) this will return a list of genre numbers with their appropriate genre.


Checking for the Existance of ID3 Tags

There is a handy method named got_tag() that can be easily used to determine if a particular MP3 file contains an ID3 Tag.

  if $mp3_file->got_tag() {

Viewing Tag Compontents individually

There exist several methods that will return you the individual components of the ID3 Tag.

  $title     = $mp3_file->get_title();
  $artist    = $mp3_file->get_artist();
  $album     = $mp3_file->get_album();
  $year      = $mp3_file->get_year();
  $genre     = $mp3_file->get_genre();
  $genre_num = $mp3_file->get_genre_num();
  $comment   = $mp3_file->get_comment();

Editing and Removing Tags

Similar methods exist to allow you to change the components of the Tag, but none of the changes will actually be changed in the file until you call the save() routine.

  $mp3_file->set_title("New Title");
  $mp3_file->set_artist("New Artist");
  $mp3_file->set_album("New Album");
  # Or use the genre numbers ->

To remove an tag in its entirely just calling the remove_tag() method should work for you.

 $mp3_file->remove_tag() if $mp3_file->got_tag();

 You could access all the components directly for a read only loop such
as the following

foreach (sort $mp3_file->tag) { print "$_: " . $mp3_file->tag($_) . "\n"; }


Sander van Zoest <>


Matt Plummer <>, Mike Oliphant <>, Matt DiMeo <>, Olaf Maetzner, Jason Bodnar and Peter Johansson


Copyright 2000, Alexander van Zoest. All rights reserved. Copyright 1999-2000, Alexander van Zoest,, Inc. All rights reserved.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


For general overview of MPEG 1.0, Layer 3 (MP3) Audio visit <> or get the book, "MP3: The Definitive Guide" by O'Reilly and Associates <>.

For technical details about MP3 Audio read the ISO/IEC 11172 and ISO/IEC 13818 specifications, obtained via <> in the US or <> elsewhere in the world. For more information also check out <> compiled by Gabriel Bouvigne.

For more specific references to the MP3 Audio ID3 Tags visit <>

For information about ID3v2 and a perl implementation see MPEG::ID3v2Tag written by Matt DiMeo <>.