Audio::MPEG Perl Module
Back in early 2001, I wanted to automate the management of my ever burgeoning MP3 library. At first, I wanted a piece of software to manage the ID3 tags in a bulk manner (according to rules I was setting up). Then, I wanted something to verify the integrity of the MP3 audio data as well (ensure there were no corrupt frames, etc.) and excise those bad frames. Additionally, I was interested in on-the-fly transoding (i.e. convert to different bitrates) to stream audio data from home, through a skinny (by today’s standards) DSL link to where I was working (remember, these were the pre-iPod days… it wasn’t easy to cart around 60GB of music…) And, it had to run under Linux. On a PowerPC platform. Quite a tall order.
After much fruitless searching for a freeware solution, I decided I had to home-roll some software. Since I was (and still am) quite a Perl junkie, it seemed natural to hack it up in Perl. All I needed was a core component (something that understood MP3 audio files) to make this a reality. Thus, Audio::MPEG was born.
This module will allow a Perl program to verify an MP3 file (fixed and variable bitrate), decode it into a high-resolution (24 bit) PCM stream, apply filtering effects to the data (stereo->mono, fade in/out, equalizer), transform that stream into an audio stream (Microsoft WAV, Sun AU, integer PCM, floating point PCM), and finally encode a PCM stream as an MP3.
The interface is quite Perl-like, and treats the data stream as an opaque blob of data (however it is simple to transform, using unpack and pack, between the opaque data and a Perl array - recipes are given in the man page).
It should be possible, given a reasonably modern computer, to decode/filter/re-encode an MP3 file in real-time.
However, many years have passed since I wrote this code, and my interest in maintaining it has faded to, well, zero. I don’t have the time (or interest) to maintain it, as I’ve moved on to other solutions (I’m using iTunes to maintain my library, modern encoders rarely corrupt audio files, and I mostly work out of my home, so there’s no need for streaming). So, I’m offering this as completely unsupported code. Yep. You read that right. Unsupported, as in, you’re on your own if you choose to use this software.
Now, it’s not all that gloomy: the code itself is pretty rock-solid (it had hundreds of hours of use by me). The problem is that it’s based on old LAME library code, which catches most people when building the library. So, if you are able to build the old library code, it should work just fine for you.
And just to make it perfectly clear: you must use the exact versions of the libraries noted below to link against. Audio::MPEG will not work with newere versions of the libraries, as their interfaces have changed in later versions.
All that said, here is the code (and mirrored code of the exact versions of external libraries I developed against) for your enjoyment (or frustration).
- README
- The distribution’s README file.
- Man page
- The man page. See if you like the interface or not.
- Audio::MPEG 0.04
- The complete distribution in gzip tar format.
- MAD 0.13.0 (beta)
- Local mirror of the MPEG Audio Decoder library in gzip tar format. Official site is
http://www.mars.org/home/rob/proj/mpeg/ - LAME 3.88 (beta 1)
- Local mirror of the LAME Ain’t MP3 Encode library in gzip tar format. Official site is
http://www.mp3dev.org/
Copyright and License
© 2001 Peter Timofejew. All rights reserved.
This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.