HOWTO splitt lossless audio files (ape, flac, wv, wav) using .cue files

From LinuxReviews
Jump to: navigation, search

Lossless audio such as music albums sometimes come as one huge file and a small .cue file with the actual track information. CD recording software such as K3B can use this huge file and the .cue to create an exact CD copy of the music album.

[edit] Let's split them

Music CDs are out. Most people like to keep their music collection on a harddrive or portable player. Huge files are not suitable for music software like mpd and audacious. This is why you probably want to split your huge complete-album .flac into separate files for each track. You need two small tools to accomplish this: cuebreakpoints from cuetools and shntool.

  • Debian/Ubuntu: sudo apt-get install cuetools shntool
  • Gentoo: emerge -v app-cdr/cuetools media-sound/shntool

You also need some software for the lossless audio format you will be using. If you want to use .flac and .wav files then you'll need flac and wavpack,

  • Debian/Ubuntu: sudo apt-get install flac wavpack
  • Gentoo: emerge media-libs/flac media-sound/wavpack

The trick that is used so powerfully by the power l33t hax0rs is to use cuebreakpoints to print all the break-points from a .cue or .toc file. These breakpoints are then piped to shnsplit like this:

Shell command:
cuebreakpoints example.cue | shnsplit -o flac example.flac

This splits example.flac according to the breakpoints listed in example.cue. You will have separate files named split-track01.flac, split-track02.flac, etc after running this command. The prefix for the output files can be changed wth the -a option if you want something different from split-track. You likely want to rename your newly created files regardless.

The output format must be specified with the -o option. shntool's default is to make .wav wave files, and you don't want that.

You can split one format and output another, to split monkey's audio and output flac you could do:

Shell command:
cuebreakpoints example.cue | shnsplit -o flac example.ape

shntool split -h or shnsplit -h will give you a list of all available options.

[edit] Creating tag metadata

shnsplit does not add any metadata when it creates new split audio files. There is a script called you can use to transfer tag data from .cue files directly into the split files.

Debian/Ubuntu based distributions will install this script for you. Gentoo will place it in the doc folder (like /usr/share/doc/cuetools-1.3.1/extras/, adjust path for version). cp it to your /usr/local/bin and chmod a+x it. Now edit the script!

Line 21 of the script should contain this line:

METAFLAC="metaflac --remove-vc-all --import-vc-from=-"

The commmands --remove-vc-all and --import-vc-from are no longer used by metaflac (unless you have a seriously old version). The new valid option is --import-tags-from. Change METAFLAC in the script to:

METAFLAC="metaflac --import-tags-from=-"

You can now use the script like this:

Shell command:
cuetag example.cue split-track01.flac split-track02.flac split-track03.flac split-track04.flac

Or simpler:

Shell command:
cuetag example.cue split-track*.flac

Cuetag can work with with flac, ogg and mp3 files. Cuetag will freak out if you try to use it on files with spaces in their names.

Personal tools
hardware tests
Privacy policy
linux events


linux newz | random page | poetry | free blog