© copyright 29.Jan.2009 by Paul Bradley filed under Perl
Some of the technology podcasts I listen to routinely run longer than 80 minutes, and while I do have an iPod, I like to listen to them while doing a 200 mile commute, and so I usually burn them to CD-RW's so that I can play them through the car CD player.
There are a lot of MP3 file cutters available on the Internet, but I was reminded recently that this can be done with a little Perl program called mp3cut, written by Johan Vromans. As Perl is available on most linux distros and can be freely downloaded for Windows from the Active Perl website; I prefer this method over using a closed source program.
The mp3cut.pl script is called from the command line like :
perl mp3cut.pl cue.dat
Where cue.dat is a valid Cue Sheet data file, which tells mp3cut where the time indexes that the MP3 file should be cut at; and into how many tracks the file should be split into.
The format for the cue.dat file is quite straight forward, it's just a plain text file that can be created by any text editor. It has a FILE command which names the MP3 file, in this case it using a file called TWit179.mp3 - It then has one or more TRACK entries which state the time frames that the file should be split. In the example below we are stating that Track 01 starts at time index 00:00:00 and lasts until Track 02 starts at 80 minutes into the file.
FILE "TWiT179.mp3" MP3
TRACK 01 AUDIO
TITLE "TWiT179"
INDEX 01 00:00:00
TRACK 02 AUDIO
TITLE "TWiT179"
INDEX 01 80:00:00
If we run the mp3cut.pl Perl script against this cue sheet data file, then we end up with two MP3 files called :
01-TWiT179.mp3
02-TWiT179.mp3
Where 01-TWiT179.mp3 will be exactly 80 minutes long, the 02-TWiT179.mp3 file will be however long is left in the original MP3 file.
About the Author
Paul Bradley is a VB.NET software developer living and working in Cumbria. He provides PHP & MySQL bespoke development services via his software development company, Carlisle Software Limited.
He has over 20 years programming experience.