Ubuntu: Native Flac .cue splitter


I have some .Flac albums I ripped as one big file to save some space (Lossless CD rips are roughly 500mb each), now I have more storage I would like to split them back to there original files.

Is there a Native .Flac/.cue splitter for debian based systems ?

I found some information but it is either old, just for mp3 or using wine, this is not what I want.

Also I found a Nautilus script but I don't think this will be lossless, also it only performs a very specific task and I would like some customization options, http://ubuntuforums.org/showthread.php?t=853794

So can anyone provide a lossless Flac .cue splitter with native support, and a lot of conversion options ?




First you need to install cuetools and shntool. From the terminal type:

sudo apt-get install cuetools shntool flac  

To split a flac file back to the original files using a .cue file:

cuebreakpoints '<cue file>' | shnsplit -o flac '<audio flac file>'    

You can drag the cue file and the audio flac file into the terminal in order to autocomplete the paths for '<cue file>' and '<audio flac file>'. When you run the command, the terminal will show you the results of each new flac file as it is created, one new flac file at a time ("split-track01.flac" "split-track02.flac" ...), and then stop after all of the new flac files have been created. It only takes a few seconds to create each new flac file. If your .cue file is accurate, the results will be more accurate and less time-consuming than if you split the flac file manually in Audacity.


I needed to split large flac and set file name and tag from the cue file, and this worked best for me:

  1. cd to a folder with one pair of cue and flac
  2. type this: shnsplit -f *.cue -t "%n - %p - %t" -o "flac flac -s -8 -o %f -" *.flac
  3. delete the original flac file
  4. tag the files using: cuetag *.cue *.flac

Example of output:

Splitting [Edvard Grieg - Complete Songs Vol.III.flac] (76:03.40) --> [25 - Edvard Grieg - Sighs, EG 134.flac] (2:43.08) : 100% OK  

reference: CUE_Splitting


I wrote the following script for my convenience. To use it - cd to a directory with one pair of matching ape and cue files.

mkdir -p orig  mv *ape orig/.  shnsplit -f *.cue -t "%n - %p - %t" -o "flac flac -s -8 -o %f -" orig/*.ape  rm -f 00*  cuetag *.cue *.flac  #fix bad file names  find . -exec rename 's/[^\x00-\x7F]//g' "{}" \;  

name this script as split_ape, chmod +x it and put in some directory in your path. I made a similar script for flac file as source, just replace every ape with flac in this script.


The easiest way is using K3B.

1.- Open the CUE file in K3B. 2.- Choose convert tracks to FLAC. 3.- Press Start.

It will not re-convert the tracks but only split them into tracks according to the CUE file. It will keep the original name of each track and it takes second to complete the "convertion/split".


There is a app called "flacon" which does exactly this.


To install:

sudo add-apt-repository ppa:flacon  sudo apt-get update  sudo apt-get install flacon  


and for flac:

    cat file.cue | shnsplit -o flac -t %n-%t file.flac  

split the flac file and add to the resulting files track number (%n) and title name (%t)


Here is a solution with FFmpeg and the POSIX Awk stdlib library:

#!/usr/local/bin/awklib -f  $1 == "FILE" {    split($0, un, "\42")    vi = un[2]  }  $1 == "TRACK" {    wh[++xr] = $2  }  $1 == "TITLE" && xr {    split($0, un, "\42")    ya[xr] = un[2]  }  $1 == "INDEX" && $2 {    split($3, un, ":")    zu[xr] = sprintf("%d:%02d:%06.3f", un[1] / 60, un[1] % 60, un[2] + un[3] / 75)  }  END {    _ = RS    for (xr in wh) {      split("ffmpeg" _ "-i" _ vi _ "-ss" _ zu[xr] _ \      (zu[xr + 1] ? "-to" _ zu[xr + 1] _ : "") \      "-metadata" _ "track=" wh[xr] _ "-metadata" _ "title=" ya[xr] _ \      wh[xr] FS ya[xr] ".m4a", br, _)      sh_trace(br)    }  }  



Install shntool

sudo apt-get install shntool  

If you wish to automatically preserve file names, you can simply use:

cat infile.cue | shnsplit -t "%n - %p - %t" infile.wav  


You can split CUE file into separate FLAC tracks using fmedia (http://fmedia.firmdev.com) with a single command:

fmedia YOUR_FILE.cue --out='$tracknumber. $artist - $title.flac'  

With this command you'll split all tracks from one CUE file into separate FLAC files named like "01. ARTIST - TITLE.flac". Note, that the output files will have exactly the same audio quality and track duration precisely as the original.

Or you may copy just one track from the .cue file:

fmedia YOUR_FILE.cue --out='$tracknumber. $artist - $title.flac' --track=7  

You can also overwrite meta information during the splitting, e.g.:

fmedia YOUR_FILE.cue --out=mytrack.flac --meta='artist=COOL ARTIST'  

fmedia has minimum external dependencies (i.e. cuetools, libFLAC, etc. are NOT needed to be installed on your system), it works on 64-bit Debian-based systems, but it doesn't work on 32-bit systems.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »