10 @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS $VERSION $REVISION
11 @mp3_genres %mp3_genres @winamp_genres %winamp_genres $try_harder
12 @t_bitrate @t_sampling_freq @frequency_tbl %v1_tag_fields
13 @v1_tag_names %v2_tag_names %v2_to_v1_names $AUTOLOAD
14 @mp3_info_fields %rva2_channel_types
19 set_mp3tag get_mp3tag get_mp3info remove_mp3tag
20 use_winamp_genres, use_mp3_utf8
22 @EXPORT_OK = qw(@mp3_genres %mp3_genres use_mp3_utf8);
24 genres => [qw(@mp3_genres %mp3_genres)],
25 utf8 => [qw(use_mp3_utf8)],
26 all
=> [@EXPORT, @EXPORT_OK]
30 ($REVISION) = ' $Revision$ ' =~ /\$Revision:\s+([^\s]+)/;
37 MP3::Info - Manipulate / fetch info from MP3 audio files
43 my $file = 'Pearls_Before_Swine.mp3';
44 set_mp3tag($file, 'Pearls Before Swine', q"77's",
45 'Sticks and Stones', '1990',
46 q"(c) 1990 77's LTD.", 'rock & roll');
48 my $tag = get_mp3tag($file) or die "No TAG info";
49 $tag->{GENRE} = 'rock';
50 set_mp3tag($file, $tag);
52 my $info = get_mp3info($file);
53 printf "$file length is %d:%d\n", $info->{MM}, $info->{SS};
59 # set all lower-case and regular-cased versions of genres as keys
60 # with index as value of each key
61 %mp3_genres = map {($_, ++$c, lc, $c)} @mp3_genres;
63 # do it again for winamp genres
65 %winamp_genres = map {($_, ++$c, lc, $c)} @winamp_genres;
70 my $mp3 = new MP3::Info $file;
71 $mp3->title('Perls Before Swine');
72 printf "$file length is %s, title is %s\n",
73 $mp3->time, $mp3->title;
80 =item $mp3 = MP3::Info-E<gt>new(FILE)
82 OOP interface to the rest of the module. The same keys
83 available via get_mp3info and get_mp3tag are available
84 via the returned object (using upper case or lower case;
85 but note that all-caps "VERSION" will return the module
86 version, not the MP3 version).
88 Passing a value to one of the methods will set the value
89 for that tag in the MP3 file, if applicable.
94 my($pack, $file) = @_;
96 my $info = get_mp3info
($file) or return undef;
97 my $tags = get_mp3tag
($file) || { map { ($_ => undef) } @v1_tag_names };
103 @self{@mp3_info_fields, @v1_tag_names, 'file'} = (
104 @
{$info}{@mp3_info_fields},
105 @
{$tags}{@v1_tag_names},
109 return bless \
%self, $pack;
114 return $self->SUPER::can
(@_) unless ref $self;
116 return sub { $self->$name(@_) } if exists $self->{$name};
122 (my $name = uc $AUTOLOAD) =~ s/^.*://;
124 if (exists $self->{$name}) {
125 my $sub = exists $v1_tag_fields{$name}
128 $_[0]->{$name} = $_[1];
129 set_mp3tag
($_[0]->{FILE
}, $_[0]);
131 return $_[0]->{$name};
134 return $_[0]->{$name}
142 carp
(sprintf "No method '$name' available in package %s.",
152 =item use_mp3_utf8([STATUS])
154 Tells MP3::Info to (or not) return TAG info in UTF-8.
155 TRUE is 1, FALSE is 0. Default is TRUE, if available.
157 Will only be able to turn it on if Encode is available. ID3v2
158 tags will be converted to UTF-8 according to the encoding specified
159 in each tag; ID3v1 tags will be assumed Latin-1 and converted
162 Function returns status (TRUE/FALSE). If no argument is supplied,
163 or an unaccepted argument is supplied, function merely returns status.
165 This function is not exported by default, but may be exported
166 with the C<:utf8> or C<:all> export tag.
170 my $unicode_module = eval { require Encode
; require Encode
::Guess
};
171 my $UNICODE = use_mp3_utf8
($unicode_module ?
1 : 0);
176 if ($unicode_module) {
178 $Encode::Guess
::NoUTFAutoGuess
= 1;
180 } elsif ($val == 0) {
188 =item use_winamp_genres()
190 Puts WinAmp genres into C<@mp3_genres> and C<%mp3_genres>
191 (adds 68 additional genres to the default list of 80).
192 This is a separate function because these are non-standard
193 genres, but they are included because they are widely used.
195 You can import the data structures with one of:
197 use MP3::Info qw(:genres);
198 use MP3::Info qw(:DEFAULT :genres);
199 use MP3::Info qw(:all);
203 sub use_winamp_genres
{
204 %mp3_genres = %winamp_genres;
205 @mp3_genres = @winamp_genres;
211 =item remove_mp3tag (FILE [, VERSION, BUFFER])
213 Can remove ID3v1 or ID3v2 tags. VERSION should be C<1> for ID3v1
214 (the default), C<2> for ID3v2, and C<ALL> for both.
216 For ID3v1, removes last 128 bytes from file if those last 128 bytes begin
217 with the text 'TAG'. File will be 128 bytes shorter.
219 For ID3v2, removes ID3v2 tag. Because an ID3v2 tag is at the
220 beginning of the file, we rewrite the file after removing the tag data.
221 The buffer for rewriting the file is 4MB. BUFFER (in bytes) ca
222 change the buffer size.
224 Returns the number of bytes removed, or -1 if no tag removed,
225 or undef if there is an error.
230 my($file, $version, $buf) = @_;
233 $buf ||= 4096*1024; # the bigger the faster
236 if (not (defined $file && $file ne '')) {
237 $@
= "No file specified";
242 $@
= "File is empty";
246 if (ref $file) { # filehandle passed
249 if (not open $fh, '+<', $file) {
250 $@
= "Can't open $file: $!";
257 if ($version eq 1 || $version eq 'ALL') {
260 if (<$fh> =~ /^TAG/) {
261 truncate $fh, $tell or carp
"Can't truncate '$file': $!";
266 if ($version eq 2 || $version eq 'ALL') {
267 my $v2h = _get_v2head
($fh);
272 my $off = $v2h->{tag_size
};
274 while ($off < $eof) {
276 read $fh, my($bytes), $buf;
277 seek $fh, $off - $v2h->{tag_size
}, 0;
282 truncate $fh, $eof - $v2h->{tag_size
}
283 or carp
"Can't truncate '$file': $!";
284 $return += $v2h->{tag_size
};
290 return $return || -1;
296 =item set_mp3tag (FILE, TITLE, ARTIST, ALBUM, YEAR, COMMENT, GENRE [, TRACKNUM])
298 =item set_mp3tag (FILE, $HASHREF)
300 Adds/changes tag information in an MP3 audio file. Will clobber
301 any existing information in file.
303 Fields are TITLE, ARTIST, ALBUM, YEAR, COMMENT, GENRE. All fields have
304 a 30-byte limit, except for YEAR, which has a four-byte limit, and GENRE,
305 which is one byte in the file. The GENRE passed in the function is a
306 case-insensitive text string representing a genre found in C<@mp3_genres>.
308 Will accept either a list of values, or a hashref of the type
309 returned by C<get_mp3tag>.
311 If TRACKNUM is present (for ID3v1.1), then the COMMENT field can only be
314 ID3v2 support may come eventually. Note that if you set a tag on a file
315 with ID3v2, the set tag will be for ID3v1[.1] only, and if you call
316 C<get_mp3tag> on the file, it will show you the (unchanged) ID3v2 tags,
317 unless you specify ID3v1.
322 my($file, $title, $artist, $album, $year, $comment, $genre, $tracknum) = @_;
323 my(%info, $oldfh, $ref, $fh);
324 local %v1_tag_fields = %v1_tag_fields;
326 # set each to '' if undef
327 for ($title, $artist, $album, $year, $comment, $tracknum, $genre,
328 (@info{@v1_tag_names}))
329 {$_ = defined() ?
$_ : ''}
331 ($ref) = (overload
::StrVal
($title) =~ /^(?:.*\=)?([^=]*)\((?:[^\(]*)\)$/)
333 # populate data to hashref if hashref is not passed
335 (@info{@v1_tag_names}) =
336 ($title, $artist, $album, $year, $comment, $tracknum, $genre);
338 # put data from hashref into hashref if hashref is passed
339 } elsif ($ref eq 'HASH') {
345 Usage: set_mp3tag (FILE, TITLE, ARTIST, ALBUM, YEAR, COMMENT, GENRE [, TRACKNUM])
346 set_mp3tag (FILE, $HASHREF)
351 if (not (defined $file && $file ne '')) {
352 $@
= "No file specified";
357 $@
= "File is empty";
361 # comment field length 28 if ID3v1.1
362 $v1_tag_fields{COMMENT
} = 28 if $info{TRACKNUM
};
367 # warn if fields too long
368 foreach my $field (keys %v1_tag_fields) {
369 $info{$field} = '' unless defined $info{$field};
370 if (length($info{$field}) > $v1_tag_fields{$field}) {
371 carp
"Data too long for field $field: truncated to " .
372 "$v1_tag_fields{$field}";
377 carp
"Genre `$info{GENRE}' does not exist\n"
378 unless exists $mp3_genres{$info{GENRE
}};
382 if ($info{TRACKNUM
}) {
383 $info{TRACKNUM
} =~ s/^(\d+)\/(\d+)$/$1/;
384 unless ($info{TRACKNUM
} =~ /^\d+$/ &&
385 $info{TRACKNUM
} > 0 && $info{TRACKNUM
} < 256) {
386 carp
"Tracknum `$info{TRACKNUM}' must be an integer " .
387 "from 1 and 255\n" if $^W
;
388 $info{TRACKNUM
} = '';
392 if (ref $file) { # filehandle passed
395 if (not open $fh, '+<', $file) {
396 $@
= "Can't open $file: $!";
404 # go to end of file if no tag, beginning of file if tag
405 seek $fh, (<$fh> =~ /^TAG/ ?
-128 : 0), 2;
408 $info{GENRE
} = $info{GENRE
} && exists $mp3_genres{$info{GENRE
}} ?
409 $mp3_genres{$info{GENRE
}} : 255; # some default genre
413 if ($info{TRACKNUM
}) {
414 print pack 'a3a30a30a30a4a28xCC', 'TAG', @info{@v1_tag_names};
416 print pack 'a3a30a30a30a4a30C', 'TAG', @info{@v1_tag_names[0..4, 6]};
428 =item get_mp3tag (FILE [, VERSION, RAW_V2])
430 Returns hash reference containing tag information in MP3 file. The keys
431 returned are the same as those supplied for C<set_mp3tag>, except in the
432 case of RAW_V2 being set.
434 If VERSION is C<1>, the information is taken from the ID3v1 tag (if present).
435 If VERSION is C<2>, the information is taken from the ID3v2 tag (if present).
436 If VERSION is not supplied, or is false, the ID3v1 tag is read if present, and
437 then, if present, the ID3v2 tag information will override any existing ID3v1
440 If RAW_V2 is C<1>, the raw ID3v2 tag data is returned, without any manipulation
441 of text encoding. The key name is the same as the frame ID (ID to name mappings
442 are in the global %v2_tag_names).
444 If RAW_V2 is C<2>, the ID3v2 tag data is returned, manipulating for Unicode if
445 necessary, etc. It also takes multiple values for a given key (such as comments)
446 and puts them in an arrayref.
448 If the ID3v2 version is older than ID3v2.2.0 or newer than ID3v2.4.0, it will
451 Strings returned will be in Latin-1, unless UTF-8 is specified (L<use_mp3_utf8>),
452 (unless RAW_V2 is C<1>).
454 Also returns a TAGVERSION key, containing the ID3 version used for the returned
455 data (if TAGVERSION argument is C<0>, may contain two versions).
460 my ($file, $ver, $raw_v2, $find_ape) = @_;
461 my ($tag, $v2h, $fh);
470 $ver = !$ver ?
0 : ($ver == 2 || $ver == 1) ?
$ver : 0;
472 if (not (defined $file && $file ne '')) {
473 $@
= "No file specified";
477 my $filesize = -s
$file;
480 $@
= "File is empty";
484 if (ref $file) { # filehandle passed
487 if (not open $fh, '<', $file) {
488 $@
= "Can't open $file: $!";
495 # Try and find an APE Tag - this is where FooBar2k & others
496 # store ReplayGain information
499 $ape = _parse_ape_tag
($fh, $filesize, \
%info);
504 $v1 = _get_v1tag
($fh, \
%info);
506 if ($ver == 1 && !$v1) {
508 $@
= "No ID3v1 tag found";
513 if ($ver == 2 || $ver == 0) {
514 ($v2, $v2h) = _get_v2tag
($fh);
517 if (!$v1 && !$v2 && !$ape) {
519 $@
= "No ID3 tag found";
523 if (($ver == 0 || $ver == 2) && $v2) {
525 if ($raw_v2 == 1 && $ver == 2) {
529 $info{'TAGVERSION'} = $v2h->{'version'};
533 _parse_v2tag
($raw_v2, $v2, \
%info);
535 if ($ver == 0 && $info{'TAGVERSION'}) {
536 $info{'TAGVERSION'} .= ' / ' . $v2h->{'version'};
538 $info{'TAGVERSION'} = $v2h->{'version'};
543 unless ($raw_v2 && $ver == 2) {
544 foreach my $key (keys %info) {
545 if (defined $info{$key}) {
546 $info{$key} =~ s/\000+.*//g;
547 $info{$key} =~ s/\s+$//;
551 for (@v1_tag_names) {
552 $info{$_} = '' unless defined $info{$_};
556 if (keys %info && exists $info{'GENRE'} && ! defined $info{'GENRE'}) {
562 return keys %info ?
{%info} : undef;
566 my ($fh, $info) = @_;
569 read($fh, my $tag, 128);
571 if (!defined($tag) || $tag !~ /^TAG/) {
576 if (substr($tag, -3, 2) =~ /\000[^\000]/) {
578 (undef, @
{$info}{@v1_tag_names}) =
579 (unpack('a3a30a30a30a4a28', $tag),
580 ord(substr($tag, -2, 1)),
581 $mp3_genres[ord(substr $tag, -1)]);
583 $info->{'TAGVERSION'} = 'ID3v1.1';
587 (undef, @
{$info}{@v1_tag_names[0..4, 6]}) =
588 (unpack('a3a30a30a30a4a30', $tag),
589 $mp3_genres[ord(substr $tag, -1)]);
591 $info->{'TAGVERSION'} = 'ID3v1';
596 # Save off the old suspects list, since we add
597 # iso-8859-1 below, but don't want that there
598 # for possible ID3 v2.x parsing below.
599 my $oldSuspects = $Encode::Encoding
{'Guess'}->{'Suspects'};
601 for my $key (keys %{$info}) {
603 next unless $info->{$key};
605 # Try and guess the encoding.
606 my $value = $info->{$key};
607 my $icode = Encode
::Guess
->guess($value);
609 unless (ref($icode)) {
611 # Often Latin1 bytes are
612 # stuffed into a 1.1 tag.
613 Encode
::Guess
->add_suspects('iso-8859-1');
615 while (length($value)) {
617 $icode = Encode
::Guess
->guess($value);
621 # Remove garbage and retry
622 # (string is truncated in the
623 # middle of a multibyte char?)
628 $info->{$key} = Encode
::decode
(ref($icode) ?
$icode->name : 'iso-8859-1', $info->{$key});
631 Encode
::Guess
->set_suspects(keys %{$oldSuspects});
638 my ($raw_v2, $v2, $info) = @_;
640 # Make sure any existing TXXX flags are an array.
641 # As we might need to append comments to it below.
642 if ($v2->{'TXXX'} && ref($v2->{'TXXX'}) ne 'ARRAY') {
644 $v2->{'TXXX'} = [ $v2->{'TXXX'} ];
647 # J.River Media Center sticks RG tags in comments.
648 # Ugh. Make them look like TXXX tags, which is really what they are.
649 if (ref($v2->{'COMM'}) eq 'ARRAY' && grep { /Media Jukebox/ } @
{$v2->{'COMM'}}) {
651 for my $comment (@
{$v2->{'COMM'}}) {
653 if ($comment =~ /Media Jukebox/) {
655 # we only want one null to lead.
656 $comment =~ s/^\000+//g;
658 push @
{$v2->{'TXXX'}}, "\000$comment";
663 my $hash = $raw_v2 == 2 ?
{ map { ($_, $_) } keys %v2_tag_names } : \
%v2_to_v1_names;
665 for my $id (keys %$hash) {
667 next if !exists $v2->{$id};
669 if ($id =~ /^UFID?$/) {
671 my @ufid_list = split(/\0/, $v2->{$id});
673 $info->{$hash->{$id}} = $ufid_list[1] if ($#ufid_list > 0);
675 } elsif ($id =~ /^RVA[D2]?$/) {
677 # Expand these binary fields. See the ID3 spec for Relative Volume Adjustment.
680 # ID is a text string
681 ($info->{$hash->{$id}}->{'ID'}, my $rvad) = split /\0/, $v2->{$id};
683 my $channel = $rva2_channel_types{ ord(substr($rvad, 0, 1, '')) };
685 $info->{$hash->{$id}}->{$channel}->{'REPLAYGAIN_TRACK_GAIN'} =
686 sprintf('%f', _grab_int_16
(\
$rvad) / 512);
688 my $peakBytes = ord(substr($rvad, 0, 1, ''));
690 if (int($peakBytes / 8)) {
692 $info->{$hash->{$id}}->{$channel}->{'REPLAYGAIN_TRACK_PEAK'} =
693 sprintf('%f', _grab_int_16
(\
$rvad) / 512);
696 } elsif ($id eq 'RVAD' || $id eq 'RVA') {
698 my $rvad = $v2->{$id};
699 my $flags = ord(substr($rvad, 0, 1, ''));
700 my $desc = ord(substr($rvad, 0, 1, ''));
702 # iTunes appears to be the only program that actually writes
703 # out a RVA/RVAD tag. Everyone else punts.
704 for my $type (qw(REPLAYGAIN_TRACK_GAIN REPLAYGAIN_TRACK_PEAK)) {
706 for my $channel (qw(RIGHT LEFT)) {
708 my $val = _grab_uint_16
(\
$rvad) / 256;
710 # iTunes uses a range of -255 to 255
711 # to be -100% (silent) to 100% (+6dB)
715 $val = 20.0 * log(($val+255)/255)/log(10);
718 $info->{$hash->{$id}}->{$channel}->{$type} = $flags & 0x01 ?
$val : -$val;
723 } elsif ($id =~ /^A?PIC$/) {
725 my $pic = $v2->{$id};
727 # if there is more than one picture, just grab the first one.
728 if (ref($pic) eq 'ARRAY') {
738 # look for ID3 v2.2 picture
739 if ($pic && $id eq 'PIC') {
741 # look for ID3 v2.2 picture
742 my ($encoding, $format, $picture_type, $description) = unpack 'Ca3CZ*', $pic;
743 $pic_len = length($description) + 1 + 5;
745 # skip extra terminating null if unicode
746 if ($encoding) { $pic_len++; }
748 if ($pic_len < length($pic)) {
750 $pic_format = $format;
753 } elsif ($pic && $id eq 'APIC') {
755 # look for ID3 v2.3 picture
756 my ($encoding, $format) = unpack 'C Z*', $pic;
758 $pic_len = length($format) + 2;
760 if ($pic_len < length($pic)) {
762 my ($picture_type, $description) = unpack "x$pic_len C Z*", $pic;
764 $pic_len += 1 + length($description) + 1;
766 # skip extra terminating null if unicode
767 if ($encoding) { $pic_len++; }
770 $pic_format = $format;
774 # Proceed if we have a valid picture.
775 if ($valid_pic && $pic_format) {
777 my ($data) = unpack("x$pic_len A*", $pic);
779 if (length($data) && $pic_format) {
781 $info->{$hash->{$id}} = {
783 'FORMAT' => $pic_format,
789 my $data1 = $v2->{$id};
791 # this is tricky ... if this is an arrayref,
792 # we want to only return one, so we pick the
793 # first one. but if it is a comment, we pick
794 # the first one where the first charcter after
795 # the language is NULL and not an additional
796 # sub-comment, because that is most likely to be
797 # the user-supplied comment
798 if (ref $data1 && !$raw_v2) {
799 if ($id =~ /^COMM?$/) {
800 my($newdata) = grep /^(....\000)/, @
{$data1};
801 $data1 = $newdata || $data1->[0];
802 } elsif ($id !~ /^(?:TXXX?|PRIV)$/) {
803 # We can get multiple User Defined Text frames in a mp3 file
804 $data1 = $data1->[0];
808 $data1 = [ $data1 ] if ! ref $data1;
810 for my $data (@
$data1) {
811 # TODO : this should only be done for certain frames;
812 # using RAW still gives you access, but we should be smarter
813 # about how individual frame types are handled. it's not
814 # like the list is infinitely long.
815 $data =~ s/^(.)//; # strip first char (text encoding)
819 # Comments & Unsyncronized Lyrics have the same format.
820 if ($id =~ /^(COM[M ]?|USLT)$/) { # space for iTunes brokenness
822 $data =~ s/^(?:...)//; # strip language
827 if ($encoding eq "\001" || $encoding eq "\002") { # UTF-16, UTF-16BE
828 # text fields can be null-separated lists;
829 # UTF-16 therefore needs special care
831 # foobar2000 encodes tags in UTF-16LE
832 # (which is apparently illegal)
833 # Encode dies on a bad BOM, so it is
834 # probably wise to wrap it in an eval
836 $data = eval { Encode
::decode
('utf16', $data) } || Encode
::decode
('utf16le', $data);
838 } elsif ($encoding eq "\003") { # UTF-8
840 # make sure string is UTF8, and set flag appropriately
841 $data = Encode
::decode
('utf8', $data);
843 } elsif ($encoding eq "\000") {
845 # Only guess if it's not ascii.
846 if ($data && $data !~ /^[\x00-\x7F]+$/) {
848 # Try and guess the encoding, otherwise just use latin1
849 my $dec = Encode
::Guess
->guess($data);
852 $data = $dec->decode($data);
855 $data = Encode
::decode
('iso-8859-1', $data);
862 # If the string starts with an
863 # UTF-16 little endian BOM, use a hack to
864 # convert to ASCII per best-effort
866 if ($data =~ s/^\xFF\xFE//) {
868 } elsif ($data =~ s/^\xFE\xFF//) {
873 $data = pack 'C*', map {
874 (chr =~ /[[:ascii:]]/ && chr =~ /[[:print:]]/)
877 } unpack "$pat*", $data;
881 # We do this after decoding so we could be certain we're dealing
883 if ($id =~ /^(COM[M ]?|USLT)$/) { # space for iTunes brokenness
885 $data =~ s/^(.*?)\000//; # strip up to first NULL(s),
886 # for sub-comments (TODO:
887 # handle all comment data)
890 } elsif ($id =~ /^TCON?$/) {
894 # Turn multiple nulls into a single.
895 $data =~ s/\000+/\000/g;
897 # Handle the ID3v2.x spec -
899 # just an index number, possibly
900 # paren enclosed - referer to the v1 genres.
901 if ($data =~ /^ \(? (\d+) \)?\000?$/sx) {
905 # Paren enclosed index with refinement.
907 } elsif ($data =~ /^ \( (\d+) \)\000? ([^\(].+)$/x) {
909 ($index, $name) = ($1, $2);
911 # List of indexes: (37)(38)
912 } elsif ($data =~ /^ \( (\d+) \)\000?/x) {
916 while ($data =~ s/^ \( (\d+) \)\000?//x) {
918 push @genres, $mp3_genres[$1];
924 # Text based genres will fall through.
925 if ($name && $name ne "\000") {
927 } elsif (defined $index) {
928 $data = $mp3_genres[$index];
932 if ($raw_v2 == 2 && $desc) {
933 $data = { $desc => $data };
936 if ($raw_v2 == 2 && exists $info->{$hash->{$id}}) {
938 if (ref $info->{$hash->{$id}} eq 'ARRAY') {
939 push @
{$info->{$hash->{$id}}}, $data;
941 $info->{$hash->{$id}} = [ $info->{$hash->{$id}}, $data ];
949 my ($key, $val) = split(/\0/, $data);
950 $info->{uc($key)} = $val;
952 } elsif ($id eq 'PRIV') {
954 my ($key, $val) = split(/\0/, $data);
955 $info->{uc($key)} = unpack('v', $val);
959 $info->{$hash->{$id}} = $data;
969 my($off, $end, $myseek, $v2, $v2h, $hlen, $num, $wholetag);
972 $v2h = _get_v2head
($fh) or return;
974 if ($v2h->{major_version
} < 2) {
975 carp
"This is $v2h->{version}; " .
976 "ID3v2 versions older than ID3v2.2.0 not supported\n"
981 # use syncsafe bytes if using version 2.4
982 # my $bytesize = ($v2h->{major_version} > 3) ? 128 : 256;
984 # alas, that's what the spec says, but iTunes and others don't syncsafe
985 # the length, which breaks MP3 files with v2.4 tags longer than 128 bytes,
986 # like every image file.
989 if ($v2h->{major_version
} == 2) {
997 $off = $v2h->{ext_header_size
} + 10;
998 $end = $v2h->{tag_size
} + 10; # should we read in the footer too?
1000 seek $fh, $v2h->{offset
}, 0;
1001 read $fh, $wholetag, $end;
1003 $wholetag =~ s/\xFF\x00/\xFF/gs if $v2h->{unsync
};
1006 my $bytes = substr($wholetag, $off, $hlen);
1007 return unless $bytes =~ /^([A-Z0-9]{$num})/
1008 || ($num == 4 && $bytes =~ /^(COM )/); # stupid iTunes
1009 my($id, $size) = ($1, $hlen);
1010 my @bytes = reverse unpack "C$num", substr($bytes, $num, $num);
1012 for my $i (0 .. ($num - 1)) {
1013 $size += $bytes[$i] * $bytesize ** $i;
1017 if ($v2h->{major_version
} > 3) {
1018 my @bits = split //, unpack 'B16', substr($bytes, 8, 2);
1019 $flags->{frame_unsync
} = $bits[14];
1020 $flags->{data_len_indicator
} = $bits[15];
1023 return($id, $size, $flags);
1026 while ($off < $end) {
1027 my($id, $size, $flags) = &$myseek or last;
1029 my $bytes = substr($wholetag, $off+$hlen, $size-$hlen);
1032 if ($flags->{data_len_indicator
}) {
1034 my @data_len_bytes = reverse unpack 'C4', substr($bytes, 0, 4);
1035 $bytes = substr($bytes, 4);
1037 $data_len += $data_len_bytes[$i] * 128 ** $i;
1041 # perform frame-level unsync if needed (skip if already done for whole tag)
1042 $bytes =~ s/\xFF\x00/\xFF/gs if $flags->{frame_unsync
} && !$v2h->{unsync
};
1044 # if we know the data length, sanity check it now.
1045 if ($flags->{data_len_indicator
} && defined $data_len) {
1046 carp
"Size mismatch on $id\n" unless $data_len == length($bytes);
1049 if (exists $v2->{$id}) {
1050 if (ref $v2->{$id} eq 'ARRAY') {
1051 push @
{$v2->{$id}}, $bytes;
1053 $v2->{$id} = [$v2->{$id}, $bytes];
1056 $v2->{$id} = $bytes;
1067 =item get_mp3info (FILE)
1069 Returns hash reference containing file information for MP3 file.
1070 This data cannot be changed. Returned data:
1072 VERSION MPEG audio version (1, 2, 2.5)
1073 LAYER MPEG layer description (1, 2, 3)
1074 STEREO boolean for audio is in stereo
1076 VBR boolean for variable bitrate
1077 BITRATE bitrate in kbps (average for VBR files)
1078 FREQUENCY frequency in kHz
1079 SIZE bytes in audio stream
1080 OFFSET bytes offset that stream begins
1085 MS leftover milliseconds
1088 COPYRIGHT boolean for audio is copyrighted
1089 PADDING boolean for MP3 frames are padded
1090 MODE channel mode (0 = stereo, 1 = joint stereo,
1091 2 = dual channel, 3 = single channel)
1092 FRAMES approximate number of frames
1093 FRAME_LENGTH approximate length of a frame
1094 VBR_SCALE VBR scale from VBR header
1096 On error, returns nothing and sets C<$@>.
1102 my($off, $byte, $eof, $h, $tot, $fh);
1104 if (not (defined $file && $file ne '')) {
1105 $@
= "No file specified";
1110 $@
= "File is empty";
1114 if (ref $file) { # filehandle passed
1117 if (not open $fh, '<', $file) {
1118 $@
= "Can't open $file: $!";
1126 # Let the caller change how far we seek in looking for a header.
1128 $tot *= $try_harder;
1136 if (my $v2h = _get_v2head
($fh)) {
1137 $tot += $off += $v2h->{tag_size
};
1143 $h = _get_head
($byte);
1144 my $is_mp3 = _is_mp3
($h);
1146 # the head wasn't where we were expecting it.. dig deeper.
1149 # do only one read - it's _much_ faster
1152 read $fh, $byte, $tot;
1156 # now walk the bytes looking for the head
1157 for ($i = 0; $i < $tot; $i++) {
1159 last if ($tot - $i) < 4;
1161 my $head = substr($byte, $i, 4) || last;
1163 next if (ord($head) != 0xff);
1165 $h = _get_head
($head);
1166 $is_mp3 = _is_mp3
($h);
1170 # adjust where we are for _get_vbr()
1173 if ($off > $tot && !$try_harder) {
1175 $@
= "Couldn't find MP3 header (perhaps set " .
1176 '$MP3::Info::try_harder and retry)';
1181 my $vbr = _get_vbr
($fh, $h, \
$off);
1186 $eof -= 128 if <$fh> =~ /^TAG/ ?
1 : 0;
1190 $h->{size
} = $eof - $off;
1191 $h->{offset
} = $off;
1193 return _get_info
($h, $vbr);
1200 # No bitrate or sample rate? Something's wrong.
1201 unless ($h->{bitrate
} && $h->{fs
}) {
1205 $i->{VERSION
} = $h->{IDR
} == 2 ?
2 : $h->{IDR
} == 3 ?
1 :
1206 $h->{IDR
} == 0 ?
2.5 : 0;
1207 $i->{LAYER
} = 4 - $h->{layer
};
1208 $i->{VBR
} = defined $vbr ?
1 : 0;
1210 $i->{COPYRIGHT
} = $h->{copyright
} ?
1 : 0;
1211 $i->{PADDING
} = $h->{padding_bit
} ?
1 : 0;
1212 $i->{STEREO
} = $h->{mode
} == 3 ?
0 : 1;
1213 $i->{MODE
} = $h->{mode
};
1215 $i->{SIZE
} = $vbr && $vbr->{bytes
} ?
$vbr->{bytes
} : $h->{size
};
1216 $i->{OFFSET
} = $h->{offset
};
1218 my $mfs = $h->{fs
} / ($h->{ID
} ?
144000 : 72000);
1219 $i->{FRAMES
} = int($vbr && $vbr->{frames
}
1221 : $i->{SIZE
} / ($h->{bitrate} / $mfs)
1225 $i->{VBR_SCALE
} = $vbr->{scale
} if $vbr->{scale
};
1226 $h->{bitrate
} = $i->{SIZE
} / $i->{FRAMES
} * $mfs;
1227 if (not $h->{bitrate
}) {
1228 $@
= "Couldn't determine VBR bitrate";
1233 $h->{'length'} = ($i->{SIZE
} * 8) / $h->{bitrate} / 10;
1234 $i->{SECS
} = $h->{'length'} / 100;
1235 $i->{MM
} = int $i->{SECS
} / 60;
1236 $i->{SS
} = int $i->{SECS
} % 60;
1237 $i->{MS
} = (($i->{SECS
} - ($i->{MM
} * 60) - $i->{SS
}) * 1000);
1238 # $i->{LF} = ($i->{MS} / 1000) * ($i->{FRAMES} / $i->{SECS});
1239 # int($i->{MS} / 100 * 75); # is this right?
1240 $i->{TIME
} = sprintf "%.2d:%.2d", @
{$i}{'MM', 'SS'};
1242 $i->{BITRATE
} = int $h->{bitrate
};
1243 # should we just return if ! FRAMES?
1244 $i->{FRAME_LENGTH
} = int($h->{size
} / $i->{FRAMES
}) if $i->{FRAMES
};
1245 $i->{FREQUENCY
} = $frequency_tbl[3 * $h->{IDR
} + $h->{sampling_freq
}];
1254 $bytes = _unpack_head
($byte);
1255 @
$h{qw(IDR ID layer protection_bit
1256 bitrate_index sampling_freq padding_bit private_bit
1257 mode mode_extension copyright original
1258 emphasis version_index bytes)} = (
1259 ($bytes>>19)&3, ($bytes>>19)&1, ($bytes>>17)&3, ($bytes>>16)&1,
1260 ($bytes>>12)&15, ($bytes>>10)&3, ($bytes>>9)&1, ($bytes>>8)&1,
1261 ($bytes>>6)&3, ($bytes>>4)&3, ($bytes>>3)&1, ($bytes>>2)&1,
1262 $bytes&3, ($bytes>>19)&3, $bytes
1265 $h->{bitrate
} = $t_bitrate[$h->{ID
}][3 - $h->{layer
}][$h->{bitrate_index
}];
1266 $h->{fs
} = $t_sampling_freq[$h->{IDR
}][$h->{sampling_freq
}];
1272 my $h = $_[0] or return undef;
1273 return ! ( # all below must be false
1274 $h->{bitrate_index
} == 0
1276 $h->{version_index
} == 1
1278 ($h->{bytes
} & 0xFFE00000) != 0xFFE00000
1284 $h->{bitrate_index
} == 15
1288 $h->{sampling_freq
} == 3
1292 !$h->{bitrate_index
}
1294 ($h->{bytes
} & 0xFFFF0000) == 0xFFFE0000
1296 ($h->{ID
} == 1 && $h->{layer
} == 3 && $h->{protection_bit
} == 1)
1297 # mode extension should only be applicable when mode = 1
1298 # however, failing just becuase mode extension is used when unneeded is a bit strict
1300 #($h->{mode_extension} != 0 && $h->{mode} != 1)
1311 read $fh, $$bytes, $n;
1317 my($fh, $h, $roff) = @_;
1318 my($off, $bytes, @bytes, %vbr);
1324 if ($h->{ID
}) { # MPEG1
1325 $off += $h->{mode
} == 3 ?
17 : 32;
1327 $off += $h->{mode
} == 3 ?
9 : 17;
1330 _vbr_seek
($fh, \
$off, \
$bytes);
1331 return unless $bytes eq 'Xing';
1333 _vbr_seek
($fh, \
$off, \
$bytes);
1334 $vbr{flags
} = _unpack_head
($bytes);
1336 if ($vbr{flags
} & 1) {
1337 _vbr_seek
($fh, \
$off, \
$bytes);
1338 $vbr{frames
} = _unpack_head
($bytes);
1341 if ($vbr{flags
} & 2) {
1342 _vbr_seek
($fh, \
$off, \
$bytes);
1343 $vbr{bytes
} = _unpack_head
($bytes);
1346 if ($vbr{flags
} & 4) {
1347 _vbr_seek
($fh, \
$off, \
$bytes, 100);
1348 # Not used right now ...
1349 # $vbr{toc} = _unpack_head($bytes);
1352 if ($vbr{flags
} & 8) { # (quality ind., 0=best 100=worst)
1353 _vbr_seek
($fh, \
$off, \
$bytes);
1354 $vbr{scale
} = _unpack_head
($bytes);
1364 my $fh = $_[0] or return;
1365 my($v2h, $bytes, @bytes);
1368 # check first three bytes for 'ID3'
1370 read $fh, $bytes, 3;
1372 # TODO: add support for tags at the end of the file
1373 if ($bytes eq 'RIF' || $bytes eq 'FOR') {
1374 _find_id3_chunk
($fh, $bytes) or return;
1375 $v2h->{offset
} = tell $fh;
1376 read $fh, $bytes, 3;
1379 return unless $bytes eq 'ID3';
1382 read $fh, $bytes, 2;
1383 $v2h->{version
} = sprintf "ID3v2.%d.%d",
1384 @
$v2h{qw
[major_version minor_version
]} =
1385 unpack 'c2', $bytes;
1388 read $fh, $bytes, 1;
1389 my @bits = split //, unpack 'b8', $bytes;
1390 if ($v2h->{major_version
} == 2) {
1391 $v2h->{unsync
} = $bits[7];
1392 $v2h->{compression
} = $bits[8];
1393 $v2h->{ext_header
} = 0;
1394 $v2h->{experimental
} = 0;
1396 $v2h->{unsync
} = $bits[7];
1397 $v2h->{ext_header
} = $bits[6];
1398 $v2h->{experimental
} = $bits[5];
1399 $v2h->{footer
} = $bits[4] if $v2h->{major_version
} == 4;
1402 # get ID3v2 tag length from bytes 7-10
1403 $v2h->{tag_size
} = 10; # include ID3v2 header size
1404 $v2h->{tag_size
} += 10 if $v2h->{footer
};
1405 read $fh, $bytes, 4;
1406 @bytes = reverse unpack 'C4', $bytes;
1407 foreach my $i (0 .. 3) {
1408 # whoaaaaaa nellllllyyyyyy!
1409 $v2h->{tag_size
} += $bytes[$i] * 128 ** $i;
1412 # get extended header size
1413 $v2h->{ext_header_size
} = 0;
1414 if ($v2h->{ext_header
}) {
1415 read $fh, $bytes, 4;
1416 @bytes = reverse unpack 'C4', $bytes;
1418 # use syncsafe bytes if using version 2.4
1419 my $bytesize = ($v2h->{major_version
} > 3) ?
128 : 256;
1421 $v2h->{ext_header_size
} += $bytes[$i] * $bytesize ** $i;
1428 sub _find_id3_chunk
{
1429 my($fh, $filetype) = @_;
1430 my($bytes, $size, $tag, $pat, $mat);
1432 read $fh, $bytes, 1;
1433 if ($filetype eq 'RIF') { # WAV
1434 return 0 if $bytes ne 'F';
1437 } elsif ($filetype eq 'FOR') { # AIFF
1438 return 0 if $bytes ne 'M';
1442 seek $fh, 12, 0; # skip to the first chunk
1444 while ((read $fh, $bytes, 8) == 8) {
1445 ($tag, $size) = unpack $pat, $bytes;
1446 return 1 if $tag eq $mat;
1454 unpack('l', pack('L', unpack('N', $_[0])));
1459 my $value = unpack('s',substr($$data,0,2));
1460 $$data = substr($$data,2);
1466 my $value = unpack('S',substr($$data,0,2));
1467 $$data = substr($$data,2);
1473 my $value = unpack('V',substr($$data,0,4));
1474 $$data = substr($$data,4);
1478 sub _parse_ape_tag
{
1479 my ($fh, $filesize, $info) = @_;
1481 my $ape_tag_id = 'APETAGEX';
1484 read($fh, my $tag, 256);
1485 my $pre_tag = substr($tag, 0, 128, '');
1487 # Try and bail early if there's no ape tag.
1488 if (substr($pre_tag, 96, 8) ne $ape_tag_id && substr($tag, 96, 8) ne $ape_tag_id) {
1494 my $id3v1_tag_size = 128;
1495 my $ape_tag_header_size = 32;
1496 my $lyrics3_tag_size = 10;
1497 my $tag_offset_start = 0;
1498 my $tag_offset_end = 0;
1500 seek($fh, (0 - $id3v1_tag_size - $ape_tag_header_size - $lyrics3_tag_size), 2);
1502 read($fh, my $ape_footer_id3v1, $id3v1_tag_size + $ape_tag_header_size + $lyrics3_tag_size);
1504 if (substr($ape_footer_id3v1, (length($ape_footer_id3v1) - $id3v1_tag_size - $ape_tag_header_size), 8) eq $ape_tag_id) {
1506 $tag_offset_end = $filesize - $id3v1_tag_size;
1508 } elsif (substr($ape_footer_id3v1, (length($ape_footer_id3v1) - $ape_tag_header_size), 8) eq $ape_tag_id) {
1510 $tag_offset_end = $filesize;
1513 seek($fh, $tag_offset_end - $ape_tag_header_size, 0);
1515 read($fh, my $ape_footer_data, 32);
1517 my $ape_footer = _parse_ape_header_or_footer
($ape_footer_data);
1519 if (keys %{$ape_footer}) {
1521 my $ape_tag_data = '';
1523 if ($ape_footer->{'flags'}->{'header'}) {
1525 seek($fh, ($tag_offset_end - $ape_footer->{'tag_size'} - $ape_tag_header_size), 0);
1527 $tag_offset_start = tell($fh);
1529 read($fh, $ape_tag_data, $ape_footer->{'tag_size'} + $ape_tag_header_size);
1533 $tag_offset_start = $tag_offset_end - $ape_footer->{'tag_size'};
1535 seek($fh, $tag_offset_start, 0);
1537 read($fh, $ape_tag_data, $ape_footer->{'tag_size'});
1540 my $ape_header_data = substr($ape_tag_data, 0, $ape_tag_header_size, '');
1541 my $ape_header = _parse_ape_header_or_footer
($ape_header_data);
1543 for (my $c = 0; $c < $ape_header->{'tag_items'}; $c++) {
1545 # Loop through the tag items
1546 my $tag_len = _grab_int_32
(\
$ape_tag_data);
1547 my $tag_flags = _grab_int_32
(\
$ape_tag_data);
1549 $ape_tag_data =~ s/^(.*?)\0//;
1551 my $tag_item_key = uc($1 || 'UNKNOWN');
1553 $info->{$tag_item_key} = substr($ape_tag_data, 0, $tag_len, '');
1562 sub _parse_ape_header_or_footer
{
1566 if (substr($bytes, 0, 8, '') eq 'APETAGEX') {
1568 $data{'version'} = _grab_int_32
(\
$bytes);
1569 $data{'tag_size'} = _grab_int_32
(\
$bytes);
1570 $data{'tag_items'} = _grab_int_32
(\
$bytes);
1571 $data{'global_flags'} = _grab_int_32
(\
$bytes);
1573 # trim the reseved bytes
1574 _grab_int_32
(\
$bytes);
1575 _grab_int_32
(\
$bytes);
1577 $data{'flags'}->{'header'} = ($data{'global_flags'} & 0x80000000) ?
1 : 0;
1578 $data{'flags'}->{'footer'} = ($data{'global_flags'} & 0x40000000) ?
1 : 0;
1579 $data{'flags'}->{'is_header'} = ($data{'global_flags'} & 0x20000000) ?
1 : 0;
1586 my($file, $fh) = @_;
1587 unless (ref $file) { # filehandle not passed
1588 close $fh or carp
"Problem closing '$file': $!";
1641 'Instrumental Rock',
1645 'Techno-Industrial',
1734 'Christian Gangsta Rap',
1738 'Contemporary Christian',
1749 [0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256],
1750 [0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160],
1751 [0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160]
1753 [0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448],
1754 [0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384],
1755 [0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320]
1758 @t_sampling_freq = (
1759 [11025, 12000, 8000],
1760 [undef, undef, undef], # reserved
1761 [22050, 24000, 16000],
1762 [44100, 48000, 32000]
1765 @frequency_tbl = map { $_ ?
eval "${_}e-3" : 0 }
1766 map { @
$_ } @t_sampling_freq;
1768 @mp3_info_fields = qw(
1790 %rva2_channel_types = (
1793 0x02 => 'FRONT_RIGHT',
1794 0x03 => 'FRONT_LEFT',
1795 0x04 => 'BACK_RIGHT',
1796 0x05 => 'BACK_LEFT',
1797 0x06 => 'FRONT_CENTER',
1798 0x07 => 'BACK_CENTER',
1799 0x08 => 'SUBWOOFER',
1803 (TITLE
=> 30, ARTIST
=> 30, ALBUM
=> 30, COMMENT
=> 30, YEAR
=> 4);
1805 @v1_tag_names = qw(TITLE ARTIST ALBUM YEAR COMMENT TRACKNUM GENRE);
1814 'TRK' => 'TRACKNUM',
1815 'TCO' => 'GENRE', # not clean mapping, but ...
1821 'COMM' => 'COMMENT',
1822 'TRCK' => 'TRACKNUM',
1824 # v2.3 tags - needed for MusicBrainz
1825 'UFID' => 'Unique file identifier',
1826 'TXXX' => 'User defined text information frame',
1831 'BUF' => 'Recommended buffer size',
1832 'CNT' => 'Play counter',
1833 'COM' => 'Comments',
1834 'CRA' => 'Audio encryption',
1835 'CRM' => 'Encrypted meta frame',
1836 'ETC' => 'Event timing codes',
1837 'EQU' => 'Equalization',
1838 'GEO' => 'General encapsulated object',
1839 'IPL' => 'Involved people list',
1840 'LNK' => 'Linked information',
1841 'MCI' => 'Music CD Identifier',
1842 'MLL' => 'MPEG location lookup table',
1843 'PIC' => 'Attached picture',
1844 'POP' => 'Popularimeter',
1846 'RVA' => 'Relative volume adjustment',
1847 'SLT' => 'Synchronized lyric/text',
1848 'STC' => 'Synced tempo codes',
1849 'TAL' => 'Album/Movie/Show title',
1850 'TBP' => 'BPM (Beats Per Minute)',
1851 'TCM' => 'Composer',
1852 'TCO' => 'Content type',
1853 'TCR' => 'Copyright message',
1855 'TDY' => 'Playlist delay',
1856 'TEN' => 'Encoded by',
1857 'TFT' => 'File type',
1859 'TKE' => 'Initial key',
1860 'TLA' => 'Language(s)',
1862 'TMT' => 'Media type',
1863 'TOA' => 'Original artist(s)/performer(s)',
1864 'TOF' => 'Original filename',
1865 'TOL' => 'Original Lyricist(s)/text writer(s)',
1866 'TOR' => 'Original release year',
1867 'TOT' => 'Original album/Movie/Show title',
1868 'TP1' => 'Lead artist(s)/Lead performer(s)/Soloist(s)/Performing group',
1869 'TP2' => 'Band/Orchestra/Accompaniment',
1870 'TP3' => 'Conductor/Performer refinement',
1871 'TP4' => 'Interpreted, remixed, or otherwise modified by',
1872 'TPA' => 'Part of a set',
1873 'TPB' => 'Publisher',
1874 'TRC' => 'ISRC (International Standard Recording Code)',
1875 'TRD' => 'Recording dates',
1876 'TRK' => 'Track number/Position in set',
1878 'TSS' => 'Software/hardware and settings used for encoding',
1879 'TT1' => 'Content group description',
1880 'TT2' => 'Title/Songname/Content description',
1881 'TT3' => 'Subtitle/Description refinement',
1882 'TXT' => 'Lyricist/text writer',
1883 'TXX' => 'User defined text information frame',
1885 'UFI' => 'Unique file identifier',
1886 'ULT' => 'Unsychronized lyric/text transcription',
1887 'WAF' => 'Official audio file webpage',
1888 'WAR' => 'Official artist/performer webpage',
1889 'WAS' => 'Official audio source webpage',
1890 'WCM' => 'Commercial information',
1891 'WCP' => 'Copyright/Legal information',
1892 'WPB' => 'Publishers official webpage',
1893 'WXX' => 'User defined URL link frame',
1896 'AENC' => 'Audio encryption',
1897 'APIC' => 'Attached picture',
1898 'COMM' => 'Comments',
1899 'COMR' => 'Commercial frame',
1900 'ENCR' => 'Encryption method registration',
1901 'EQUA' => 'Equalization',
1902 'ETCO' => 'Event timing codes',
1903 'GEOB' => 'General encapsulated object',
1904 'GRID' => 'Group identification registration',
1905 'IPLS' => 'Involved people list',
1906 'LINK' => 'Linked information',
1907 'MCDI' => 'Music CD identifier',
1908 'MLLT' => 'MPEG location lookup table',
1909 'OWNE' => 'Ownership frame',
1910 'PCNT' => 'Play counter',
1911 'POPM' => 'Popularimeter',
1912 'POSS' => 'Position synchronisation frame',
1913 'PRIV' => 'Private frame',
1914 'RBUF' => 'Recommended buffer size',
1915 'RVAD' => 'Relative volume adjustment',
1917 'SYLT' => 'Synchronized lyric/text',
1918 'SYTC' => 'Synchronized tempo codes',
1919 'TALB' => 'Album/Movie/Show title',
1920 'TBPM' => 'BPM (beats per minute)',
1921 'TCOM' => 'Composer',
1922 'TCON' => 'Content type',
1923 'TCOP' => 'Copyright message',
1925 'TDLY' => 'Playlist delay',
1926 'TENC' => 'Encoded by',
1927 'TEXT' => 'Lyricist/Text writer',
1928 'TFLT' => 'File type',
1930 'TIT1' => 'Content group description',
1931 'TIT2' => 'Title/songname/content description',
1932 'TIT3' => 'Subtitle/Description refinement',
1933 'TKEY' => 'Initial key',
1934 'TLAN' => 'Language(s)',
1936 'TMED' => 'Media type',
1937 'TOAL' => 'Original album/movie/show title',
1938 'TOFN' => 'Original filename',
1939 'TOLY' => 'Original lyricist(s)/text writer(s)',
1940 'TOPE' => 'Original artist(s)/performer(s)',
1941 'TORY' => 'Original release year',
1942 'TOWN' => 'File owner/licensee',
1943 'TPE1' => 'Lead performer(s)/Soloist(s)',
1944 'TPE2' => 'Band/orchestra/accompaniment',
1945 'TPE3' => 'Conductor/performer refinement',
1946 'TPE4' => 'Interpreted, remixed, or otherwise modified by',
1947 'TPOS' => 'Part of a set',
1948 'TPUB' => 'Publisher',
1949 'TRCK' => 'Track number/Position in set',
1950 'TRDA' => 'Recording dates',
1951 'TRSN' => 'Internet radio station name',
1952 'TRSO' => 'Internet radio station owner',
1954 'TSRC' => 'ISRC (international standard recording code)',
1955 'TSSE' => 'Software/Hardware and settings used for encoding',
1956 'TXXX' => 'User defined text information frame',
1958 'UFID' => 'Unique file identifier',
1959 'USER' => 'Terms of use',
1960 'USLT' => 'Unsychronized lyric/text transcription',
1961 'WCOM' => 'Commercial information',
1962 'WCOP' => 'Copyright/Legal information',
1963 'WOAF' => 'Official audio file webpage',
1964 'WOAR' => 'Official artist/performer webpage',
1965 'WOAS' => 'Official audio source webpage',
1966 'WORS' => 'Official internet radio station homepage',
1967 'WPAY' => 'Payment',
1968 'WPUB' => 'Publishers official webpage',
1969 'WXXX' => 'User defined URL link frame',
1971 # v2.4 additional tags
1972 # note that we don't restrict tags from 2.3 or 2.4,
1973 'ASPI' => 'Audio seek point index',
1974 'EQU2' => 'Equalisation (2)',
1975 'RVA2' => 'Relative volume adjustment (2)',
1976 'SEEK' => 'Seek frame',
1977 'SIGN' => 'Signature frame',
1978 'TDEN' => 'Encoding time',
1979 'TDOR' => 'Original release time',
1980 'TDRC' => 'Recording time',
1981 'TDRL' => 'Release time',
1982 'TDTG' => 'Tagging time',
1983 'TIPL' => 'Involved people list',
1984 'TMCL' => 'Musician credits list',
1986 'TPRO' => 'Produced notice',
1987 'TSOA' => 'Album sort order',
1988 'TSOP' => 'Performer sort order',
1989 'TSOT' => 'Title sort order',
1990 'TSST' => 'Set subtitle',
1993 'COM ' => 'Broken iTunes comments',
2005 =head1 TROUBLESHOOTING
2007 If you find a bug, please send me a patch (see the project page in L<"SEE ALSO">).
2008 If you cannot figure out why it does not work for you, please put the MP3 file in
2009 a place where I can get it (preferably via FTP, or HTTP, or .Mac iDisk) and send me
2010 mail regarding where I can get the file, with a detailed description of the problem.
2012 If I download the file, after debugging the problem I will not keep the MP3 file
2013 if it is not legal for me to have it. Just let me know if it is legal for me to
2023 Still need to do more for reading tags, such as using Compress::Zlib to decompress
2024 compressed tags. But until I see this in use more, I won't bother. If something
2025 does not work properly with reading, follow the instructions above for
2028 ID3v2 I<writing> is coming soon.
2030 =item Get data from scalar
2032 Instead of passing a file spec or filehandle, pass the
2033 data itself. Would take some work, converting the seeks, etc.
2037 Do something with padding bit.
2041 Test suite could use a bit of an overhaul and update. Patches very welcome.
2047 Revamp getset.t. Test all the various get_mp3tag args.
2059 Test error handling, check more for missing files, bad MP3s, etc.
2065 Right now, only Xing VBR is supported.
2107 Hermann Schwaerzler,
2116 Pierre-Yves Thoulon,
2127 =head1 CURRENT AUTHOR
2129 Dan Sully E<lt>dan | at | slimdevices.comE<gt> & Slim Devices, Inc.
2131 =head1 AUTHOR EMERITUS
2133 Chris Nandor E<lt>pudge@pobox.comE<gt>, http://pudge.net/
2135 =head1 COPYRIGHT AND LICENSE
2137 Copyright (c) 2006 Dan Sully & Slim Devices, Inc. All rights reserved.
2139 Copyright (c) 1998-2005 Chris Nandor. All rights reserved.
2141 This program is free software; you can redistribute it and/or modify it under
2142 the same terms as Perl itself.
2150 http://www.slimdevices.com/
2154 http://www.zevils.com/linux/mp3tools/
2158 http://www.dv.co.yu/mpgscript/mpgtools.htm
2159 http://www.dv.co.yu/mpgscript/mpeghdr.htm
2163 http://www.dtek.chalmers.se/~d2linjo/mp3/mp3tool.html
2169 =item Xing Variable Bitrate
2171 http://www.xingtech.com/support/partner_developer/mp3/vbr_sdk/
2175 http://rupert.informatik.uni-stuttgart.de/~mutschml/MP3ext/
2179 http://www.xmms.org/