вторник, 18 ноября 2008 г.

Split lossless audio (ape, flac, wv, wav) by cue file in Ubuntu

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 apt-get 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 apt-get 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”.

Source: http://aidanjm.wordpress.com/2007/02/15/split-lossless-audio-ape-flac-wv-wav-by-cue-file/

Converting Monkey’s Audio (ape) to flac in Ubuntu

Converting Monkey’s Audio (ape) to flac in Ubuntu

Converting .ape files to the flac format in linux requires both the “mac” and “flac” software packages. For details on installing mac in ubuntu see here. To install flac enter the following in a terminal window:

sudo apt-get install flac

Audio file format conversions can be performed from the command line, or via the GUI using soundKonverter.

If you prefer to work from the command line, then you will want to install shntool:

sudo apt-get install shntool

Shntool functions as a frontend of sorts for lossless audio software (mac, flac, wavpack). It performs a range of functions including facilitating the conversion of music files between the various lossless formats (ape, flac, wv, wav, etc). Note that shntool has native support for .wav files only; if you want it to work with .ape, .flac or .wv files then you must have the appropriate helper programs (mac, flac, wavpack respectively) installed. For a full list of the lossless formats supported by shntool type “shntool -f”. To convert all .ape files in a directory to flac using shntool:

shntool conv -o flac *.ape

This command can also be given as:

shnconv -o flac *.ape

An alternative to using shntool is to work via the mac and flac programs directly; to convert a monkey’s audio file to flac:

mac sample.ape sample.wav -d
flac -o sample.flac sample.wav

It is possible to pipe the output of mac directly into the flac tool - you would get equivalent results by issuing:

mac sample.ape - -d | flac -o sample.flac -

To convert a directory of ape files to flac:

for i in *.ape; do mac “$i” - -d | flac -o “${i%*.ape}.flac” -; done

(Note: if you are copying the above command and it pasting into the terminal window, you will need to replace the “curly quotes” used by WordPress with the straight/ non-curly quotation marks used by the shell.)

You could put the above line in a bash script to simplifiy the conversion process.

SoundKonverter - Audio file format converter

SoundKonvertor is a GUI frontend to programs such as mac and flac. It allows you to convert your music files between the various formats using a point and click interface. This is an excellent option if you find working with the command line to be tedious. Note that SoundKonverter requires mac and flac to be installed to be able to work with monkey’s audio and flac formats respectively. To install soundKonverter:

sudo aptitude install soundkonverter

soundKonverter can be launched by selecting the appropriate icon from your applications menu (in KDE it is installed under the Multimedia menu).

Preserving ape tags

Unfortunately shntool and soundKonverter do not preserve existing tag information (album, artist, genre, etc.) when converting monkey’s audio files to flac or other lossless formats.

Jared Breeland has written a nice bash script (convtoflac.sh) which will convert your monkey’s audio files to flac preserving your precious tag information in the process. The convtoflac.sh script was written on a Gentoo system but with a very slight amount of tweaking it will work on your Ubuntu/ Kubuntu system. Note: the script calls on a small program (apeinfo) to extract tag information information from the ape files which is then transferred to your converted files. Jared provides a binary (compiled) version of apeinfo and the source code. The binary was compiled on a Gentoo Linux system (running GCC 3.4.4 and glibc 2.3.5) - it works fine on my Ubuntu and Kubuntu 7.04 installations. Instructions for Ubuntu/ Kubuntu users: If you don’t already have one, create a directory called “bin” in your home directory, and download and place the convtoflac.sh script and the apeinfo binary file there. Open the convtoflac.sh script in a text editor and make these two small changes to the script: 1) look for the line containing “SED=/usr/bin/sed” and change it to “SED=/bin/sed” (this is needed because the sed binary - a text processing program - is located differently in Ubuntu than Gentoo). 2) Look for the line containing “APEINFO=/usr/local/bin/apeinfo” and change it to “APEINFO=~/bin/apeinfo”. You also need to ensure that the script and also the apeinfo binary have their execute bit set (this allows them to be run):

chmod a+x ~/bin/convtoflac.sh
chmod a+x ~/bin/apeinfo

To convert an ape file to flac using the convtoflac.sh script enter the following in a terminal window:

convtoflac.sh sample.ape

To convert an entire directory of ape files to flac:

for i in *.ape; do convtoflac.sh “$i”; done

(Note: if you are copying the above command and it pasting into the terminal window, you will need to replace the “curly quotes” used by WordPress with the straight/ non-curly quotation marks used by the shell.)

Source: http://aidanjm.wordpress.com/2007/02/04/converting-monkey%E2%80%99s-audio-ape-files-to-flac-in-ubuntu/