Splitting MP3s in Perl

Sep 26, 2008

I listen to some podcasts daily that have annoying messages in them that never change. With a bit of research, I came across the MP3::Splitter module on CPAN which has somewhat confusing documentation but provides a method mp3split() that pulls specified pieces of a file. You provide mp3split() with the input MP3 filename, options as a hash and then any number of arrays that specify which portions of the MP3 to copy into new files. The easiest syntax for specifying a portion is to pass the start position and the length of the desired chunk, both in seconds. From the command line, I did this:

Which will leave you with new.mp3 that is a concatenation of the three pieces. Using cat to join them means the resulting file will probably have some artifacts at the join points but that’s not a problem for my use. If it is, you can use something like mp3join to properly join the files.