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 aptitude 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 aptitude 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.)

6 Comments

  1. Posted June 8, 2007 at 6:56 pm | Permalink

    Hello!

    there is a “small” problem : mac-port isn’t available anymore. I’ve made a script which convert ape->flac using win32 binary. It preserves id3tags and filename.
    You can find it here : http://nimo.internux.ch/?p=4&news=47 wich MAC.exe binary. All you have to install in addition is:
    flac - apetag (I don’t know ubuntu package name, I’m on gentoo).

    cheers

  2. Posted June 8, 2007 at 8:37 pm | Permalink

    thanks for your comments and link, Tengu. :) Sadly the author of the linux mac port is no longer maintaining the project, apparently due to time constraints. although of course version 3.99 of mac-port is perfectly adequate for converting the occasional ape file to a preferred format such as flac. but your method of using the win32 binary in conjunction with wine is an interesting solution!

  3. audionut
    Posted July 3, 2007 at 11:58 pm | Permalink

    is there any way to have flac include replaygain info during the conversion process?

  4. andrew
    Posted September 29, 2007 at 6:59 am | Permalink

    Very helpful and clear instructions. Thank you, it worked perfectly.

  5. Roland Minner
    Posted October 29, 2007 at 9:26 pm | Permalink

    you can get the mac-port files from the slackware repository:
    http://www.slacky.eu/repository/slackware-11.0/multimedia/mac/3.99-u4-b5/src/

  6. ronocdh
    Posted December 20, 2007 at 12:19 am | Permalink

    This was a really helpful post… thank you so, so much.

2 Trackbacks/Pingbacks

  1. [...] to mp3. Recently I had to convert a cue/APE to mp3. While searching for ways to do it I came across this post in the aidanhm’s stuff blog. While it has very few posts (the last one in mid February) it [...]

  2. [...] Źródło: http://aidanjm.wordpress.com/ [...]

Post a Comment

Your email is never published nor shared.