Splitting big mp3 files

When splitting big mp3 files (like audiobooks) into digestible chunks (say 20 minutes) with ffmpeg, there are several things to keep in mind:

  1. It really, really matters where you put the -ss option on the command line! If you use it as an output option (i.e. after -i), input is read but discarded, so you end up with a file containing silence at the start. You have to use it as an input option (i.e. before -i) to get the proper result.
  2. Same goes for -t, only that you have to use this one as an output option (i.e. after -i but before the output file name. Also note that -t denotes a duration, not a position!
  3. If you want to transfer the split files to an Android device, you need to adjust the IDv3-tag “title”. Android uses that plus the original extension as the display file name. If the title-tag does not contain some string to differentiate files, you end up with identical file names. So you have to fix the title to something like “audiobook – 01 of 37”. Of course the track-tag is ignored (why bother with something so obvious 🙁 ).

But do not fret. I put this all together in a quick and dirty quick and dirty perl script. First argument is the input file, second the base for output file names and third the base for the title tag:

$ splitmp3.pl "Big Input file.mp3" "Output file" "Name"

outputs files like this:

Output file - 01.mp3
Output file - 02.mp3
...

with titles like this:

Name - 01 of 37
Name - 02 of 37
...

That’s all, folks!

Powershell and square brackets

Have you ever tried mass renaming files with square bracket in the path? Then I’m pretty sure you failed, because you can’t escape them easily. You have to do it manually by setting up temporary variables and replace ‘[]’ by ‘“[“]’.  It’s a nightmare. Find a box with a bash shell or install cygwin. Then simply do this:

$ for i in * ; do mv "$i" "newname $i" ; done

instead of this shit! That makes PowerShell almost useless for file operations 🙁