Monday, June 04, 2007

Splitting CUE/FLAC Files

I do so dislike large single files (unless it's a cue/bin of a game/software CD). Life just sucks when you have to deal with an album in the form of a single large audio file. At least it has a cue sheet, which creates the possibility of relatively easily splitting the file sanely.

And so, a little research lead me to this interesting command line:

~$ cuebreakpoints "filename.cue" | shntool split -o flac "filename.flac"

To work this little magic, you'll first need a few tiny packages installed. So, install cuetools & shntool like so:

~$ sudo apt-get install cuetools shntool

After which (assuming the cue/flac files are in your current working directory) you run the above mentioned command line to split the file into individual tracks named 001.flac, 002.flac, etc...

A little explanation is probably in order. I doubt I'd remember what the command means a few months from now. The first part of the command takes the cue sheet, and outputs where a track ends and the next begins:

cuebreakpoints "filename.cue"

Next, we redirect the output to shntool for splitting and naming:

shntool split -o flac "filename.flac"

Here, we're telling shntool that we want to split the flac file into individual files. Using -o flac means we want the output format to be in flac as well. There's other formats that could be specified including wave (just use -o wav instead). Read the manual for more info.

Note: You need to use shntool split -n '' -o flac "filename.flac" instead if you happen to have an older version of shntool.

Put everything together, and we have a fairly simple command to split cue/flac files into individual audio tracks. Enjoy! :-)

Related posts:

Dealing with uif files
Converting cue/bin to ISO
Converting CCD images to ISO

12 comments:

  1. this is a simplified command, which accomplishes the same thing:

    shntool split -f filename.cue -o flac filename.flac

    where 'filename' is replaced with the name of your cue and flac files (obviously...)

    ReplyDelete
  2. Thanks for pointing that out :-D

    ReplyDelete
  3. Great stuff, glad I found it. Now if people would just stop using Monkey Audio and get flac...

    ReplyDelete
  4. a new version of shntool is out, thus you should use this command without -n '', otherwise you'll yet an error.

    :~$ cuebreakpoints "filename.cue" | shntool split -o flac "filename.flac"

    ReplyDelete
  5. Thanks for pointing it out, Andrew.

    ReplyDelete
  6. it's a complex and useful tool, and i'm resurrecting an old post, a really old one, but, i found this blog cause i forgot how to use it again. since i'll likely need to remember, and end up here again, and others will come too...
    shntool split -f "cuesheet.cue" -o filetype "filename.filetype" -t %p_%a_%n_%t
    works for me, and names my files properly, automatically.

    ReplyDelete
  7. This is good. But also you can use k3b to load the cue sheet & then convert to flac.
    (Basically just splitting it).
    All the tag and file name are used from the cue sheet.
    If you have .cue linked to k3b it's a two click operation.
    ie click .cue file
    then click convert (From within k3b).
    No disk burning is required obviously.

    ReplyDelete
  8. @Oz: Thanks. I never used K3B before. This is nice to know :-)

    ReplyDelete
  9. Use Flacon instead, has gui, is in Ubuntu Software Center, works well on FLAC/APE/CUE.

    ReplyDelete
  10. @Jon

    Which Ubuntu version are you using? It's not in Ubuntu Software Center on my side.

    ReplyDelete
  11. It's not working on my ubuntu 12.04 :(

    ReplyDelete