Don’t you hate it when your bittorrent download of an album finishes, and you realize that it’s one flac file and one cue file? Unless your goal is to recreate the CD, this format probably won’t be much good to you. You probably want a separate flac file for each song. Splitting the file is easy if you have the right tools. Follow these steps to install and use Free software to do just that.
Get the Tools
You need shntool and cuetools.
Ubuntu users can install these with the package manager.
Fedora users need to compile from source.
- Download the sources: cuetools-1.3.1.tar.gz shntool-3.0.3.tar.gz
- Extract.
- Install gcc if you haven’t already.
yum -y install gcc gcc-c++
- Compile and install the programs with ./configure ; make ; make install
Split the File
Run this command to split the file using the cue sheet.
cuebreakpoints sample.cue | shnsplit -o flac sample.flac
19 Comments
I had some CDs merged in one flac and I followed this howto with success. Thanks for this post.
CDs downloaded in flac/cue format are soooooo useless. Thanks for the info
FLAC can do it without external programs (given the flac file is “test.flac”, the cue file is “test.cue” and both are in the same directory):
flac –decode –cue=- test.flac
This is pretty useful, I download music all the time and I hate it when I just get a huge file. Dammit, I want my music mobile =(. Well, thanks to you, now I do.
If you want to put the tag info back in (shnsplit does not do it) you can use cuetag (available with cuetools)
cuetag sample.cue split-track01.flac split-track02.flac split-track03.flac split-track04.flac
or
cuetag sample.cue split-track*.flac
PS I couldn’t get the suggestion from Michael to work
“cuetag sample.cue split-track*.flac”
That doesn’t work. Any ideas?
Hell yeah man! You’re a life saver, works like a charm :).
kjd: Did you get any errors? Whats the problem?
Try
cuetag.sh sample.cue split-track*.flac
cuetag is crazy buggy and doesn’t play well with files that have spaces in them, nor does it work with recent versions of metaflac due to the use of flags that don’t exist (–remove-vc-all, –import-vc-from).
I managed to convert all my collection (single flac > flac > ogg) this weekend and keep tags. I did have some problems with cuetag including the spaces in filename problem, but worked around them. I also found easytag and musicpicard could easily pick up the slack.
Thanks for the tip
I’ve used it successfully to convert from a single APE+CUE to multiple FLACs:
cuebreakpoints CDImage.cue | shnsplit -i ape -o flac CDImage.ape
There is also an all in one solution - KDE app called soundKonverter
Please ignore last comment, I was temporarily on another planet. soundKonverter does not do this, but it is a good app.
Thanks a lot
this is just what I needed.
I made a little script to automate the splitting and naming process since cuetag doesn’t seem to work very well.
Nothing fancy, doesn’t tag files or anything like that, just splits and names the files accordingly.
#!/bin/bash
#two arguments - cue file and flac-file
CUESHEET=$1
FLACFILE=$2
VA=no
IFS=$’\n’
NROFTRACKS=0
cuebreakpoints “$CUESHEET” | shnsplit -o flac “$FLACFILE”
#Should we tag each file with artist?
ARTIST1=”`cueprint \”$CUESHEET\” -n1 -t \”%c %p\n\”`”
for ARTIST in `cueprint “$CUESHEET” -t “%c %p\n”`; do
if [ "$ARTIST" != "$ARTIST1" ]; then
VA=yes
fi
NROFTRACKS=$((NROFTRACKS + 1))
done
for FILE in split*.flac; do
TRACKNUM=`echo $FILE | cut -b12-13`
KOMMAND=”mv \”$FILE\”"
if [ $VA = "yes" ]; then
NEWFILENAME=”`cueprint \”$CUESHEET\” -n$TRACKNUM -t \”%02n - %c %p - %t\n\”`.flac”
else NEWFILENAME=”`cueprint \”$CUESHEET\” -n$TRACKNUM -t \”%02n - %t\n\”`.flac”
fi
mv “$FILE” “$NEWFILENAME”
done
Paste it in a file, splitcue.sh or something, then do `chmod +x splitcue.sh` and place in somewhere in your path (e.g. /usr/bin)
Blessed you are svenjohan, I was just saying someone should write such a script and was going to start it when I found this thread. It worked perfectly and did exactly what I wanted.
I “fixed” cuetag by adding some “” and updating the options for metaflac. But as it seems like one has to register at BerliOS to submit patches, I’ll post it here.
The following patch is against cuetag(.sh) from cuetools 1.3.1:
Edited by James to fix formatting.
--- /usr/bin/cuetag 2006-09-06 20:24:47.000000000 +0200+++ /usr/local/bin/cuetag 2008-05-08 13:01:44.000000000 +0200
@@ -17,8 +17,9 @@
vorbis()
{
# FLAC tagging
- # --remove-vc-all overwrites existing comments
- METAFLAC="metaflac --remove-vc-all --import-vc-from=-"
+ # --remove-all-tags removes tags
+ # --import-tags-from imports new tags from STDIN
+ METAFLAC="metaflac --remove-all-tags --import-tags-from=-"
# Ogg Vorbis tagging
# -w overwrites existing comments
@@ -63,7 +64,7 @@
(for field in $fields; do
value=""
for conv in `eval echo \\$$field`; do
- value=`$CUEPRINT -n $1 -t "$conv\n" $cue_file`
+ value=`$CUEPRINT -n $1 -t "$conv\n" "$cue_file"`
if [ -n "$value" ]; then
echo “$field=$value”
@@ -141,7 +142,7 @@
cue_file=$1
shift
- ntrack=`cueprint -d ‘%N’ $cue_file`
+ ntrack=`cueprint -d ‘%N’ “$cue_file”`
trackno=1
if [ $# -ne $ntrack ]; then
Oh my, damn autoformatting from Wordpress. Get the patch here: http://pastebin.com/f41a1f6a6
Thanks heaps for the tut. I had issues with my codecs for those who are having issues make sure you install codecs.
One Trackback/Pingback
[...] informacion esta tomada do seguinte post. Percisan-se as seguintes utilidades, cuetools, shntool e flac. Todas elas poden-se desgcargar [...]
Post a Comment