Hidden Linux : Doing the splits

I've recently been converting a bunch of old spoken-word cassette tapes to digital format. The Audacity audio editor (also available for Windows and Mac users) is the ideal tool. It's built-in effects -- which include normalising and noise removal -- make it even more useful, and it can save files in a variety of formats including WAV, AIFF, FLAC, OGG and MP3. But there's one trick it can't handle...
At the end of my transfer sessions I had a number of very large MP3 files. These are a nuisance because, unless you open them back into an audio editor like Audacity, it's hard to find your way around them. On many portable MP3 players, switch off halfway through a 45 minute track and you're taken back to the start again when you switch back on. What I needed was a way of splitting these large tracks into convenient 5-minute blocks, rather in the manner of commercial audiobooks.
Linux to the rescue!
mp3splt does just that. It's a utility for splitting MP3 and OGG files without decoding. Here's what its manual entrys says...
mp3splt is a free command-line utility that allows you to split mp3 and ogg files from a begin time to an end time, without need of decoding and re-encoding. It’s useful to split large mp3/ogg to make smaller files or to split entire albums to obtain original tracks.
If you are splitting an album you can get split points and filenames automatically from Freedb.org server on internet or from a local.XMCD (.CDDB)or.CUEfile (see -c option), with the possibility to adjust them automatically with silence detection (see -a option).
You can also try to split files automatically with silence detection (see -s option), or by a fixed time length (see -t option)
mp3splt also has a graphical interface called mp3splt-gtk, but I just knocked up a quick batch file to do what I wanted:
| #!/bin/bash
#MP3 Splitter START_TRACK="01" TITLE="Album_Title" OUTPUT_DIR="splits" TRACK_TITLE="" TRACKNUM=$START_TRACK for I in *.mp3 do echo echo "Splitting track " "$I" if test $TRACKNUM -lt "10"; then case $TRACKNUM in 1) TRACKNUM=01;; 2) TRACKNUM=02;; 3) TRACKNUM=03;; 4) TRACKNUM=04;; 5) TRACKNUM=05;; 6) TRACKNUM=06;; 7) TRACKNUM=07;; 8) TRACKNUM=08;; 9) TRACKNUM=09;; esac fi TRACK_TITLE=$TITLE"-"$TRACKNUM echo $TRACK_TITLE #mp3splt variables: # -t = time interval to split tracks into (5.00 = f minutes) # -f = use MP3 frame mode # -a = Auto-adjust mode. Use silence detection to auto-adjust splitpoints. # -n = No Tag. Doesn't write ID3 or Vorbis comment in outputfile. # -d = output directory (created if not present) # -o = output file ("@n*" = incrementing track number) mp3splt -t 5.00 "$I" -f -a -n -d "$OUTPUT_DIR" -o "$TRACK_TITLE"-@n* TRACKNUM=`expr $TRACKNUM + 1` done echo echo "MP3 Split Done!" echo " " "$TRACKNUM" " tracks split" |
Simply copy it into the folder containing your large MP3s, set TITLE= to whatever you like and run it. It's non-destructive. Output files are written to a newly created sub-folder called "splits".
<--Previous Hidden Linux Next Hidden Linux -->

PC World is New Zealand’s top selling computing and technology magazine.
Comments
Hey Geoff. Thank you very much for your script. I altered it it just a little for podcasts here is what I changed
#!/bin/bash
#MP3 Splitter
START_TRACK="01"
TITLE="Album_Title"
OUTPUT_DIR="splits"
TRACK_TITLE=""
TRACKNUM=$START_TRACK
mkdir splits
for I in *.mp3
do
echo
echo "Splitting track " "$I"
if test $TRACKNUM -lt "10"; then
case $TRACKNUM in
1) TRACKNUM=01;;
2) TRACKNUM=02;;
3) TRACKNUM=03;;
4) TRACKNUM=04;;
5) TRACKNUM=05;;
6) TRACKNUM=06;;
7) TRACKNUM=07;;
8) TRACKNUM=08;;
9) TRACKNUM=09;;
esac
fi
TRACK_TITLE=$TITLE"-"$TRACKNUM
echo $TRACK_TITLE
#mp3splt variables:
# -t = time interval to split tracks into (5.00 = f minutes)
# -f = use MP3 frame mode
# -a = Auto-adjust mode. Use silence detection to auto-adjust splitpoints.
# -n = No Tag. Doesn't write ID3 or Vorbis comment in outputfile. # -d = output directory (created if not present)
# -o = output file ("@n*" = incrementing track number)
W=$(echo $I | awk -F"." '{ print $1}')
sudo mkdir "$OUTPUT_DIR/$W"
mp3splt -t 5.00 "$I" -f -a -n -d "$OUTPUT_DIR/$W" -o "$W"-@n*
TRACKNUM=`expr $TRACKNUM + 1`
done
echo
echo "MP3 Split Done!"
echo " " "$TRACKNUM" " tracks split"
Posted by: Matt | October 14, 2008 7:40 PM
Of course Audacity can split files. Check 'Add Label at Selection' and when done select export multiple.
Posted by: chris | March 27, 2008 12:58 PM