Lossless audio files can be split by cue file using “shnsplit” (part of the “shntool” package). You will also need the “cuebreakpoints” tool (part of the “cuetools” package). To install cuetools and shntool in Ubuntu/ Kubuntu, open a terminal window and enter the following:
sudo aptitude install cuetools shntool
You will also need software for your prefered lossless audio format. For Monkey’s Audio you need to install “mac” - see here for details. For FLAC and WavPack formats you need to install “flac” and “wavpack” respectively:
sudo aptitude install flac wavpack
Shnsplit requires a list of break-points with which to split an audio file. Conveniently, cuebreakpoints prints the break-points from a cue or toc file in a format that can be used by shnsplit. You can pipe the output of cuebreakpoints to shnsplit as follows:
cuebreakpoints sample.cue | shnsplit -o flac sample.flac
In this example, a flac file called “sample.flac” is split according to the break-points contained in “sample.cue” and the results are output in the flac format.
The output file format is specified via the “-o” option. If you don’t specify an output format your split files will be in shntool’s default format (i.e., wave files, “wav”).
To split a monkey’s audio file by cue file and output the results in the flac format:
cuebreakpoints sample.cue | shnsplit -o flac sample.ape
Note that a default prefix “split-track” is used to name the output files. (The default output format is split-track01, split-track02, split-track03, …). You can specify your own prefix via the “-a” option.
To see all the options for shntool split type “shntool split -h” or “shnsplit -h”.
Transferring tags
The audio files output by shnsplit do not contain tag data. However you can use the “cuetag” script (installed as part of the cuetools package) to transfer tag data directly from a cue file to your split audio files. You specify the individual audio files corresponding to the tracks contained in your cue file as follows:
cuetag sample.cue split-track01.flac split-track02.flac split-track03.flac split-track04.flac
This will transfer the tag data contained in “sample.cue” to the flac audio tracks “split-track01.flac” “split-track02.flac” “split-track03.flac” and “split-track04.flac”.
The above command could be streamlined as:
cuetag sample.cue split-track*.flac
Cuetag works with flac, ogg and mp3 files. The cuetag script is not currently able to handle file names containing spaces.
Note: If you are running flac version 1.1.4 or higher then you may need to make some small changes to the cuetag script before it will work correctly with flac files. Open the cuetag script (for Ubuntu installations it will be located at /usr/bin/cuetag) in a text editor and make these two changes: 1) search for the text “remove-vc-all” and replace it with “remove-all-tags”. 2) search for the “import-vc-from” and replace with “import-tags-from”.
28 Comments
This was kind of what I was looking for.
To bad it’s still rather useless, since all id tags are lost.
I am trying to split flac files into individual songs and convert them into oggs. I do
cuebreakpoints sample.cue | shntool split -o flac sample.flac and then use soundconverter to convert into oggs. All works fine and the only problem is that I cannot get songs names from the cuesheet written anywhere. They are neither in tags nor in file names.
Thank you, this worked flawlessly.
Foxy: The best way I’ve found to re-tag music is Musicbrainz Picard. The newest version is nearly automated.
This splits a flac file with cue sheet, into multiple flacs, but leaves out the tags.
I’ve a cue sheet which contains the track meta tags. There must be a way to the add the tags in the cue sheet to each new flac file.
Picard is great for retagging. But I like to do things the elegant way. If I can do it all on one line I’ll be happy.
unfortunately shnsplit does not put tag data from the cue file into the new files that it outputs.
however mp3split (which is able to split mp3 and ogg files by cue file) will insert tag details into the individual mp3 or ogg files.
Foxy, if you are wanting to produce ogg files from a flac+cue file, a better method might be to convert the flac file to ogg first (using soundkonverter or other preferred method) and then split the ogg file by cue file using mp3splt:
mp3splt -c sample.cue sample.ogg
(where sample.cue is a cue file and sample.ogg is the music file you want to split)
I was trying to use oggsplt, but when I try to play processed files in Amarok, it almost crashes my system due to some memory problem. It goes to about 80 percent of memory on my system and settles to about 25 (that is something around 200 MB). When I play the original ogg file it is fine and memory that is used by amarok goes up to 6 percent… :/ very strange… ogg123 plays those files OK so I suspect this is xine engine problem… or is it oggsplt?
Hey, there is a way to do it without oggsplt and keeping the cue file information!
cuetag is the tool
cuetag file.cue track1.ogg track2.ogg …
and I got rid of the bug
Thanks for that tip on cuetag, Bartek. It seems that the cuetag script gets installed when you install cuetools. I didn’t know about it until reading your comment. I’ve now tried it with flac files and it works as expected (successfully transfers tag data from within a cue file to individual flac files).
thanks muchly for this guide, its helped me hugely.
For me cuetag didn’t worked out of the box for flac files (in Debian Sid). It was something about non existing parameters for metaflac, and nothing was written to the file.
So I manually edited cuetag (/usr/X11R6/bin/cuetag), and changed the line:
METAFLAC=”metaflac –remove-vc-all –import-vc-from=-”
with this one:
METAFLAC=”metaflac –import-tags-from=-”
Now it works as expected. Maybe someone googleing around has the same problem as I did, and will find this usefull.
thanks for the tip, mugurelu
Thanks alot mate!
Use k3b dude and Plugin for ape + cue
Thanks a lot!
First, I had a same problem as mentioned above: cuetag doesn’t work because of the problems with metaflac usage. In Ubuntu 7.10 the way to fix it is to edit /usr/bin/cuetag like this:
# METAFLAC=”metaflac –remove-vc-all –import-vc-from=-”
METAFLAC=”metaflac –remove-all-tags –import-tags-from=-”
Second, you mention “-n” option of shnsplit to specify default file prefix, but whis is wrong and the correct option in “-a”. Also, the files are numbered by default with only one leading zero, not two.
Maybe you update your post? It is really very helpful and comes out first when you google for “ubuntu ape cue”, so I guess it’s important to keep it up to date
Thanks for you comments, Dmitry, I’ve incorporated your corrections into the text.
Thank you for this post, and the corrections in the comments. I was just looking for this.
Just a hint: a more compact syntax for selecting a interval may be:
cuetag sample.cue split-track0[1-4].flac
Which also works with “a-z”, “A-Z”, and probably more.
@EKrava
Well, explain your method. I first tried to write a CD Audio image from the cue file using k3b. But it refused to just write an image.
Directly spliting and tagging the flac file is far more efficient!
Adding a few “’s in the cuetag.sh script seems to fix the issue of files with spaces in their names.
66c65
value=`$CUEPRINT -n “$1″ -t “$conv\n” $cue_file`
141a141
>
144c144
ntrack=`cueprint -d ‘%N’ “$cue_file”`
Hello, thanks for the great post. I’ve made an extremely simple script which uses this, you can check it out here: http://jottit.com/2qyze/
Hervé wrote:
> Just a hint: a more compact syntax for selecting a interval may be:
> cuetag sample.cue split-track0[1-4].flac
> Which also works with “a-z”, “A-Z”, and probably more.
I’ve changed the example in the post to use the * wildcard, which represents the least amount of typing.
Everything works fine except I can’t get cuetag to work. It says “command not found” even though I have cuetools installed. Hmmm…..
that’s odd. what distribution are you running? is the cuetag script present in /usr/bin (i.e., /usr/bin/cuetag)?
Mandriva 2008. It seems there is no “cuetag” anywhere on my computer. Perhaps it wasn’t included in this version of cuetools (cuetools-1.3.1-3). So I had to update the tags manually after consulting with the cue file via kwrite.
if you want to use cuetag and it isn’t being installed along with cuetools on your distribution, you could get a copy from the cuetools home page:
http://developer.berlios.de/project/showfiles.php?group_id=2130
(Download “cuetools-1.3.1.tar.gz” and open it up - the cuetag script is contained inside the extras folder.)
I put a copy of cuetag here as an alternative place to grab it:
http://members.iinet.net.au/~aidanjm/cuetag
Alright, thanks, the script from that second link works. Now I’m off to install YellowDog on my PS3. Cheers.
Don’t know if shntools has been upgraded recently, but I found that
shnsplit -o flac -f sample.cue -t “%n - %t” sample.flac
worked pretty well: you get
“01 - First.flac”, “02 - Second.flac” style names then.
(you can also use %a for album and %p for performer).
I found I had to do:
cuebreakpoints sample.cue | shnsplit -o flac -f sample.cue -t “%n - %t” sample.flac
in order to make it work.
Wow, thanks a lot, it works like a charm! You just made my day
Thanks for the tip!
I made a french translation here:
http://fluoblog.wordpress.com/2008/04/12/decouper-un-fichier-audio-a-laide-dun-fichier-cue/
2 Trackbacks/Pingbacks
[...] Split lossless audio (ape, flac, wv, wav) by cue file in Ubuntu « aidanjm?s stuff [...]
[...] Source: Adanjm’s Stuff [...]
Post a Comment