1Info(3)               User Contributed Perl Documentation              Info(3)
2
3
4

NAME

6       MP3::Info - Manipulate / fetch info from MP3 audio files
7

SYNOPSIS

9               #!perl -w
10               use MP3::Info;
11               my $file = 'Pearls_Before_Swine.mp3';
12               set_mp3tag($file, 'Pearls Before Swine', q"77's",
13                       'Sticks and Stones', '1990',
14                       q"(c) 1990 77's LTD.", 'rock & roll');
15
16               my $tag = get_mp3tag($file) or die "No TAG info";
17               $tag->{GENRE} = 'rock';
18               set_mp3tag($file, $tag);
19
20               my $info = get_mp3info($file);
21               printf "$file length is %d:%d\n", $info->{MM}, $info->{SS};
22
23               my $mp3 = new MP3::Info $file;
24               $mp3->title('Perls Before Swine');
25               printf "$file length is %s, title is %s\n",
26                       $mp3->time, $mp3->title;
27

DESCRIPTION

29       $mp3 = MP3::Info->new(FILE)
30           OOP interface to the rest of the module.  The same keys available
31           via get_mp3info and get_mp3tag are available via the returned
32           object (using upper case or lower case; but note that all-caps
33           "VERSION" will return the module version, not the MP3 version).
34
35           Passing a value to one of the methods will set the value for that
36           tag in the MP3 file, if applicable.
37
38       use_mp3_utf8([STATUS])
39           Tells MP3::Info to (or not) return TAG info in UTF-8.  TRUE is 1,
40           FALSE is 0.  Default is TRUE, if available.
41
42           Will only be able to turn it on if Encode is available.  ID3v2 tags
43           will be converted to UTF-8 according to the encoding specified in
44           each tag; ID3v1 tags will be assumed Latin-1 and converted to
45           UTF-8.
46
47           Function returns status (TRUE/FALSE).  If no argument is supplied,
48           or an unaccepted argument is supplied, function merely returns sta‐
49           tus.
50
51           This function is not exported by default, but may be exported with
52           the ":utf8" or ":all" export tag.
53
54       use_winamp_genres()
55           Puts WinAmp genres into @mp3_genres and %mp3_genres (adds 68 addi‐
56           tional genres to the default list of 80).  This is a separate func‐
57           tion because these are non-standard genres, but they are included
58           because they are widely used.
59
60           You can import the data structures with one of:
61
62                   use MP3::Info qw(:genres);
63                   use MP3::Info qw(:DEFAULT :genres);
64                   use MP3::Info qw(:all);
65
66       remove_mp3tag (FILE [, VERSION, BUFFER])
67           Can remove ID3v1 or ID3v2 tags.  VERSION should be 1 for ID3v1 (the
68           default), 2 for ID3v2, and "ALL" for both.
69
70           For ID3v1, removes last 128 bytes from file if those last 128 bytes
71           begin with the text 'TAG'.  File will be 128 bytes shorter.
72
73           For ID3v2, removes ID3v2 tag.  Because an ID3v2 tag is at the
74           beginning of the file, we rewrite the file after removing the tag
75           data.  The buffer for rewriting the file is 4MB.  BUFFER (in bytes)
76           ca change the buffer size.
77
78           Returns the number of bytes removed, or -1 if no tag removed, or
79           undef if there is an error.
80
81       set_mp3tag (FILE, TITLE, ARTIST, ALBUM, YEAR, COMMENT, GENRE [, TRACK‐
82       NUM])
83       set_mp3tag (FILE, $HASHREF)
84           Adds/changes tag information in an MP3 audio file.  Will clobber
85           any existing information in file.
86
87           Fields are TITLE, ARTIST, ALBUM, YEAR, COMMENT, GENRE.  All fields
88           have a 30-byte limit, except for YEAR, which has a four-byte limit,
89           and GENRE, which is one byte in the file.  The GENRE passed in the
90           function is a case-insensitive text string representing a genre
91           found in @mp3_genres.
92
93           Will accept either a list of values, or a hashref of the type
94           returned by "get_mp3tag".
95
96           If TRACKNUM is present (for ID3v1.1), then the COMMENT field can
97           only be 28 bytes.
98
99           ID3v2 support may come eventually.  Note that if you set a tag on a
100           file with ID3v2, the set tag will be for ID3v1[.1] only, and if you
101           call "get_mp3tag" on the file, it will show you the (unchanged)
102           ID3v2 tags, unless you specify ID3v1.
103
104       get_mp3tag (FILE [, VERSION, RAW_V2, APE2])
105           Returns hash reference containing tag information in MP3 file.  The
106           keys returned are the same as those supplied for "set_mp3tag",
107           except in the case of RAW_V2 being set.
108
109           If VERSION is 1, the information is taken from the ID3v1 tag (if
110           present).  If VERSION is 2, the information is taken from the ID3v2
111           tag (if present).  If VERSION is not supplied, or is false, the
112           ID3v1 tag is read if present, and then, if present, the ID3v2 tag
113           information will override any existing ID3v1 tag info.
114
115           If RAW_V2 is 1, the raw ID3v2 tag data is returned, without any
116           manipulation of text encoding.  The key name is the same as the
117           frame ID (ID to name mappings are in the global %v2_tag_names).
118
119           If RAW_V2 is 2, the ID3v2 tag data is returned, manipulating for
120           Unicode if necessary, etc.  It also takes multiple values for a
121           given key (such as comments) and puts them in an arrayref.
122
123           If APE is 1, an APE tag will be located before all other tags.
124
125           If the ID3v2 version is older than ID3v2.2.0 or newer than
126           ID3v2.4.0, it will not be read.
127
128           Strings returned will be in Latin-1, unless UTF-8 is specified
129           (use_mp3_utf8), (unless RAW_V2 is 1).
130
131           Also returns a TAGVERSION key, containing the ID3 version used for
132           the returned data (if TAGVERSION argument is 0, may contain two
133           versions).
134
135       get_mp3info (FILE)
136           Returns hash reference containing file information for MP3 file.
137           This data cannot be changed.  Returned data:
138
139                   VERSION         MPEG audio version (1, 2, 2.5)
140                   LAYER           MPEG layer description (1, 2, 3)
141                   STEREO          boolean for audio is in stereo
142
143                   VBR             boolean for variable bitrate
144                   BITRATE         bitrate in kbps (average for VBR files)
145                   FREQUENCY       frequency in kHz
146                   SIZE            bytes in audio stream
147                   OFFSET          bytes offset that stream begins
148
149                   SECS            total seconds
150                   MM              minutes
151                   SS              leftover seconds
152                   MS              leftover milliseconds
153                   TIME            time in MM:SS
154
155                   COPYRIGHT       boolean for audio is copyrighted
156                   PADDING         boolean for MP3 frames are padded
157                   MODE            channel mode (0 = stereo, 1 = joint stereo,
158                                   2 = dual channel, 3 = single channel)
159                   FRAMES          approximate number of frames
160                   FRAME_LENGTH    approximate length of a frame
161                   VBR_SCALE       VBR scale from VBR header
162
163           On error, returns nothing and sets $@.
164

TROUBLESHOOTING

166       If you find a bug, please send me a patch (see the project page in "SEE
167       ALSO").  If you cannot figure out why it does not work for you, please
168       put the MP3 file in a place where I can get it (preferably via FTP, or
169       HTTP, or .Mac iDisk) and send me mail regarding where I can get the
170       file, with a detailed description of the problem.
171
172       If I download the file, after debugging the problem I will not keep the
173       MP3 file if it is not legal for me to have it.  Just let me know if it
174       is legal for me to keep it or not.
175

TODO

177       ID3v2 Support
178           Still need to do more for reading tags, such as using Com‐
179           press::Zlib to decompress compressed tags.  But until I see this in
180           use more, I won't bother.  If something does not work properly with
181           reading, follow the instructions above for troubleshooting.
182
183           ID3v2 writing is coming soon.
184
185       Get data from scalar
186           Instead of passing a file spec or filehandle, pass the data itself.
187           Would take some work, converting the seeks, etc.
188
189       Padding bit ?
190           Do something with padding bit.
191
192       Test suite
193           Test suite could use a bit of an overhaul and update.  Patches very
194           welcome.
195
196           *   Revamp getset.t.  Test all the various get_mp3tag args.
197
198           *   Test Unicode.
199
200           *   Test OOP API.
201
202           *   Test error handling, check more for missing files, bad MP3s,
203               etc.
204
205       Other VBR
206           Right now, only Xing VBR is supported.
207

THANKS

209       Edward Allen, Vittorio Bertola, Michael Blakeley, Per Bolmstedt, Tony
210       Bowden, Tom Brown, Sergio Camarena, Chris Dawson, Anthony DiSante, Luke
211       Drumm, Kyle Farrell, Jeffrey Friedl, brian d foy, Ben Gertzfield, Brian
212       Goodwin, Todd Hanneken, Todd Harris, Woodrow Hill, Kee Hinckley, Roman
213       Hodek, Ilya Konstantinov, Peter Kovacs, Johann Lindvall, Alex Marandon,
214       Peter Marschall, michael, Trond Michelsen, Dave O'Neill, Christoph
215       Oberauer, Jake Palmer, Andrew Phillips, David Reuteler, John Rutten‐
216       berg, Matthew Sachs, scfc_de, Hermann Schwaerzler, Chris Sidi, Roland
217       Steinbach, Brian S. Stephan, Stuart, Dan Sully, Jeffery Sumler, Predrag
218       Supurovic, Bogdan Surdu, Pierre-Yves Thoulon, tim, Pass F. B. Travis,
219       Tobias Wagener, Ronan Waide, Andy Waite, Ken Williams, Ben Winslow,
220       Meng Weng Wong, Justin Fletcher.
221

CURRENT AUTHOR

223       Dan Sully <dan ⎪ at ⎪ slimdevices.com> & Logitech.
224

AUTHOR EMERITUS

226       Chris Nandor <pudge@pobox.com>, http://pudge.net/
227
229       Copyright (c) 2006-2007 Dan Sully & Logitech. All rights reserved.
230
231       Copyright (c) 1998-2005 Chris Nandor. All rights reserved.
232
233       This program is free software; you can redistribute it and/or modify it
234       under the same terms as Perl itself.
235

SEE ALSO

237       Logitech/Slim Devices
238                   http://www.slimdevices.com/
239
240       mp3tools
241                   http://www.zevils.com/linux/mp3tools/
242
243       mpgtools
244                   http://www.dv.co.yu/mpgscript/mpgtools.htm
245                   http://www.dv.co.yu/mpgscript/mpeghdr.htm
246
247       mp3tool
248                   http://www.dtek.chalmers.se/~d2linjo/mp3/mp3tool.html
249
250       ID3v2
251                   http://www.id3.org/
252
253       Xing Variable Bitrate
254                   http://www.xingtech.com/support/partner_developer/mp3/vbr_sdk/
255
256       MP3Ext
257                   http://rupert.informatik.uni-stuttgart.de/~mutschml/MP3ext/
258
259       Xmms
260                   http://www.xmms.org/
261
262
263
264perl v5.8.8                       2007-07-26                           Info(3)
Impressum