User Tools

Site Tools


Split Audio Files into separate Tracks

1.0 Introduction

Some people like to rip CDs into a single, monolithic file which, with the help of a 'cue file', can still be played as a sequence of separate tracks. Other people prefer to rip each track of a source CD into its own, separate audio file. There is then a third group of people (myself amongst them) who once thought that the single-large-file approach was a good idea but who have now come to regret it and wish they had a bunch of separate audio files!

Should you, therefore, find yourself owning a large, single file representing an entire audio CD, what follows is how you split it up into a multitude of individual tracks.

2.0 Software Requirements

On Linux, the main tool needed to perform this split is called cuetools, although you use it in conjunction with a second application called shntool.

On Fedora 29 (and CentOS, Red Hat and similar distros) you can generally install this software with the following command:

sudo yum install cuetools shntool

If you are hoping to produce each track in flac format, you will also need to have installed the flac libraries:

sudo yum install flac

To properly tag your new, separate audio files with metadata about the composer, performers and piece details, you will additionally need to use external programs such as Easytag or Puddletag (the use of these programs is, however, outside the scope of this short article).

3.0 Audio Requirements

You will obviously need a single, large CD rip file to break apart in the first place; but you will additionally need the 'cue file' which specifies what tracks exist 'within' that single CD rip and where each one starts and stops. As an example: let us work with the following files:

Three separate symphonies exist in the xxx.flac file; the file setting out what tracks exist is the xxx.cue file next to it.

Now those file names are terribly clumsy to work with: they've got a bazillion spaces and commas and are just very, very long! Every space and comma would need to be 'escaped' for the splitting process to work, so you'd end up issuing commands such as:

cuebreakpoints Hans\ Werner\ Henze\ -\ Sinfonien\ Nr.\ 1\,\ 5\ und\ 6.cue...

…and so on, which is very awkward. So I'm going to suggest that you begin by renaming your source files so that they are short, space-less and comma-less. In my case, for example, I end up with this:

…which is a lot nicer to work with!

Now, opening that cue file in a text editor reveals this sort of thing:

…which tells us that track 1 starts 0 seconds in, and track 2 starts at 5 minutes, 56.33 seconds in, and so on. But notice also that line 4 of the file tells us the name of the input file… and it's the old name! So that won't do, and instead you need to edit it to match what you've actually called the input file. In my case, I ended up with this:

Once the FILE… line correctly mentions the right input file name, save the file and you're then ready to move on to the actual splitting!

4.0 Splitting the file

The basic command to split a CD file into a bunch of separate tracks is:

cuebreakpoints name-of-cue-file.cue | shnsplit -o flac name-of-input-file.flac

In my specific case, therefore, that needs to become:

cuebreakpoints Henze_1.cue | shnsplit -o Henze_1.flac

…and that command needs to be issued within the directory that both the cue and input flac files are stored in. With that in mind, here is me breaking my input file into its separate tracks:

I've travelled to my 'Music' directory, in which both cue and source flac file are located; I issue the cuebreakpoints…shnsplit command and a lot of feedback is then produced. Rather more importantly:

…a re-listing of the directory's contents now shows that there are lots of individual audio tracks, not just one great big one. Notice, though, that splitting the source file into its component tracks doesn't destroy the original file: it's still listed there, so if there's anything wrong with the output tracks, you can re-think and have another go when you're ready.

None of the individual audio tracks produced at this point have any tag information contained within them, so it's now over to you to use tools such as Puddletag or Easytag to add such metadata to your audio files.

5.0 Troubleshooting

The only real problem you sometimes get when splitting audio files in this way is that you may occasionally get this error:

shnsplit: error: m:ss.ff format can only be used with CD-quality files

If you see that message, it’s because shnsplit is mistaking the time format in your cue file for minutes/seconds/frames where you (probably) have minutes/seconds/milliseconds. If the third time component consists of only two digits, shnsplit thinks “frames”, whereas if it's a three-digit number, it thinks “milliseconds”.

Whether your milliseconds data is 2-digit or 3-digit depends on who produced the cue file and with what tools. Whether shnsplit actually misinterprets 2-digit numbers also depends on what version of shnsplit you're using: I'm using 3.0.10 and it doesn't seem to have this problem. Earlier versions did, however.

Anyway, the quick fix for this error if you encounter it is to manually edit your cue file and stick a zero on the end of the two-digit milliseconds time component so they have the three digits that shnsplit is expecting to indicate 'fractional seconds'.

As I say, however, I haven't encountered this particular error in any recent version of shnsplit, so it's probably a fix you won't need to implement!

wiki/linux/cuetools.txt · Last modified: 2019/04/28 13:11 by dizwell