1. Andrew's Corner »
  2. Linux Explorations...

Using qaac under Linux...

This is a page that aims to promote and facilitate the use of the great AAC/ALAC commandline encoder qaac under a Linux environment. It provides a simple copy and paste approach to an installation that can otherwise be somewhat complex as well as including instructions on commandline usage and finally most exciting for me personally: details of how to use qaac with the commandline ripper abcde.

If this page helps anyone to get their first usage of this great command line encoder I will be very happy. If perhaps the page falls short of this mark please email me using the link at the base of this page to let me know what shortcomings of this page should be addressed. And remember: "Have fun!!".


One fundamental fact of qaac is that it is native Windows application so under Linux you will need to install the Wine package appropriate for your distro and you will also need both the 7z file archiver and the unzip utility. If you are running Ubuntu for example you will need something like the following:

sudo apt-get install wine p7zip-full unzip

It would be wise to now spend a little quality time with the application winecfg and get your Wine installation running exactly as you would like.

From here you will need both the qaac application zip file as well as a modern copy of iTunes from which we will extract the appropriate dll files that qaac needs. The following single command makes a build directory, downloads and then unzips qaac to the appropriate location. The syntax presupposes that your wine prefix is the default ~/.wine, if it is not you will need to adjust the output path:

mkdir $HOME/qaac_build && cd $HOME/qaac_build && \
wget https://github.com/nu774/qaac/releases/download/v2.62/qaac_2.62.zip && \
unzip -j qaac_2.62.zip 'qaac_2.62/x86/*' -d ~/.wine/drive_c/qaac/

The next single command downloads the 32bit iTunes installation file and extracts the Apple Application Support msi file needed by qaac:

cd $HOME/qaac_build && \
wget \
https://secure-appldnld.apple.com/itunes12/031-86054-20161212-CC264356-BE1D-11E6-BD92-B3E982FDB0CC/iTunesSetup.exe && \
7z e -y iTunesSetup.exe AppleApplicationSupport.msi

Rather than fully install the Apple Installation Support msi file we are going to extract what we need from it. The author of qaac has created a very nice Windows batch file called makeportable.bat which extracts all the relevant dlls and packages them nicely (under Windows) and I have shamelessly followed his example with the following native Linux syntax which extracts the required dll files, renames them appropriately a nd then moves them to the qaac directory. Again this is a single command that can be copied and pasted into your Terminal window:

cd $HOME/qaac_build && \
7z e -y AppleApplicationSupport.msi \
     -i'!*AppleApplicationSupport_ASL.dll' \
     -i'!*AppleApplicationSupport_CoreAudioToolbox.dll' \
     -i'!*AppleApplicationSupport_CoreFoundation.dll' \
     -i'!*AppleApplicationSupport_icudt*.dll' \
     -i'!*AppleApplicationSupport_libdispatch.dll' \
     -i'!*AppleApplicationSupport_libicu*.dll' \
     -i'!*AppleApplicationSupport_objc.dll' \
     -i'!F_CENTRAL_msvc?100*' && \
for j in *.dll; do mv -v $j $(echo $j | sed 's/AppleApplicationSupport_//g'); done && \
for j in F_CENTRAL_msvcr100*; do mv -v "$j" msvcr100.dll; done && \
for j in F_CENTRAL_msvcp100*; do mv -v "$j" msvcp100.dll; done && \
mv -v *.dll ~/.wine/drive_c/qaac/ && \
rm -v AppleApplicationSupport.msi

Now that is pretty cool I think and I thank the qaac developer for showing the way here! Now to extend qaac a little in terms of media file types it can read directly. The developer has carefully detailed the individual steps required on the qaac installation page but for you, Gentle Reader, I have already assembled the required dlls and placed them in a download section of this website. The qaac developer has already done this for 64bit systems, my offerings are for the 32bit Wine installation. The following is a single command:

cd $HOME/qaac_build && \
wget http://www.andrews-corner.org/downloads/x32DLLs_20161112.zip && \
unzip -j x32DLLs_20161112.zip 'x32DLLs_20161112/*' -d ~/.wine/drive_c/qaac/

And now your copy of qaac can take take several new import formats on top of those supported by the Core Audio Toolbox! All that remains now is to make an alias in either your ~/.bashrc file or in the usual file that you use for such aliases, so that you can run qaac (and the Open Source refalac) more easily. I include here as well a line to turn off some painful Wine debugging messages:

# So I can launch qaac or refalac with a single command:
alias qaac='wine ~/.wine/drive_c/qaac/qaac.exe'
alias refalac='wine ~/.wine/drive_c/qaac/refalac.exe'

# Turn off a few pesky warnings (well, actually all of them!):
export WINEDEBUG=-all

And now you should be able to run qaac directly from the commandline (once you have sourced your ~/.bashrc file appropriately of course) and a good test is to run the following:

andrew@ilium~$ qaac --check                                                                           
qaac 2.62, CoreAudioToolbox
libsoxconvolver 0.1.0
libFLAC 1.3.1
wavpackdll 5.0.0
tak_deco_lib 2.3.0 compatible

All done! Next I will describe the commandline usage of qaac, show how to import multiple flac files with a bash 'for' loop and finally I will give you an ~/.abcde.conf for the commandline ripper abcde to produce Apple Lossless Audio Codec (alac) files using the abcde 2.7.1!

Commandline usage...

It is possible to use qaac purely from the commandline (although I personally believe the magic comes when qaac is used from within abcde!). But to perhaps clear up some confusion first a few words about AAC encoding in general. Currently (December 2015) for our purposes there are 3 recognised forms of AAC encoding and 1 more on the way:

  1. AAC-LC: Otherwise known as "MPEG AAC Low Complexity", this is AAC encoding which produces excellent sound at bitrates up to 256 kbit/s per channel and sampling rates from 8 to 96 kHz. This is the form of AAC that most will use for computer playback, use in iTunes, mobile phones etc. qaac produces AAC-LC files.
  2. HE-AAC: Otherwise known as "High Efficiency AAC". This is AAC encoding which produces excellent encoding at lower bitrates: 48 to 64 kbit/s Stereo and sampling rate 24 to 96 kHz. This is specifically designed for low bitrate streaming from TV or radio and can be used by those keen to have quality files at low bitrates. It uses AAC-LC and adds in a technique called Spectral band replication (SBR). Also known as HE-AAC v1. qaac produces HE-AAC files.
  3. HE-AAC v2: Otherwise known as "High Efficiency AAC version 2". This is the successor to the original HE-AAC and aims to produce quality AAC at 24 to 32 kbit/s Stereo and sampling rate 24 to 96 kHz. It adds in a technique called Parametric Stereo (PS). qaac does not produce HE-AAC v2 files.
  4. xHE-AAC: Otherwise known as "Extended High Efficiency AAC". This is the most recent addition to the AAC family and it aims to unify speech and music encoding primarily for broadcast with high quality encoding at low bitrates. As far as I know there is no Linux encoder available yet and the few samples I have found have been unplayable on Linux. Early days...

qaac also has the added bonus of producing Apple Lossless Audio Codec (alac) files by either using qaac itself or by using "refalac", an encoder based on the Open Source reference implementation of alac released by Apple. The biggest advantage of refalac is that it does not require any extra Apple libraries to function. Now to demonstrate some of the commandline requirements for each output of qaac, I use my favourite wav file to demonstrate and you are welcome to download and use it as well for testing:

wget samples.mplayerhq.hu/A-codecs/lossless/luckynight.wav.bz2 && \
bzip2 -dkv luckynight.wav.bz2

Consider as well looking at the words of the qaac developer on the subject of encoding with qaac.


If you are not completely sure where you AAC files will end up being used then AAC Low Complexity (AAC-LC) is what you probably should be using. My own practice is to use qaac's True Variable Bitrate (tvbr) option and at the very least this will make a good start in your own exploration of qaac. The tvbr settings take an integer betwen 0-127 which map to the following settings. I have constructed a fairly crude test with a sample wav file to show what the average bitrate will be:

AAC True VBR mode
Testing with this file: qaac --tvbr <n> luckynight.wav
tvbr setting 0 9 18 27 36 45 54 63 73 82 91 100 109 118 127
Overall Bitrate in kbps 44.4 51.2 58.0 65.7 71.5 87.6 102 114 131 150 190 232 269 305 346

But experiment a little and see what sounds better on your system and go with that rather than follow the numbers only. To add in some meta data you should try something like the following:

qaac --tvbr 100 --quality 2 --verbose \
     --band "Treasure Quest Soundtrack" \
     --artist "Jody Marie Gnant" \
     --track "9" \
     --title "Lucky Night" \
     --genre "Soundtrack" \
     --date "1995" \
     --comment "Testing qaac encoding..." \
     -o luckynight.m4a \

That is usually enough for me but there are many more options that I will leave for you, Gentle Reader, to explore. Have a look at qaac --help and explore the options for Constrained Variable Bitrate mode (CVBR), Average Bitrate mode (ABR) and Constant Bitrate Mode (CBR) encoding. But now to the exciting world of High Efficiency AAC encoding with qaac!


For the most part you will not need High-Efficiency AAC (HE-AAC) encoding and AAC-LC should normally be enough. However if you would like to produce high quality, low bitrate AAC files this is the mode you are after. To produce a decent quality HE-AAC file with qaac something like the following will suffice:

qaac --cvbr 48k --he --quality 2 --verbose luckynight.wav

qaac will not produce HE-AAC v2 files unfortunately and for this you will need to go to fdkaac or indeed fhgaacenc under Wine. However I think you will be very pleasantly suprised with the sound quality of qaac's HE-AAC (version 1) files. A final note in this section: if you find a file that qaac will not natively import (and to tell the truth there are actually not too many of these courtesy of the CoreAudio AudioFile interface) it is possible to use FFmpeg to achieve this. I give an example here, complete with tagging options, with this Windows Audio Lossless file:

ffmpeg -i luckynight.wma -f wav - | \
qaac --cvbr 48k --he --quality 2 --ignorelength --verbose \
     --band "Treasure Quest Soundtrack" \
     --artist "Jody Marie Gnant" \
     --track "9" \
     --title "Lucky Night" \
     --genre "Soundtrack" \
     --date "1995" \
     --comment "Testing qaac encoding..." \
     -o luckynight.m4a \

There are many more options to explore with HE-AAC and I encourage you to look at qaac --help and both read and experiment! Now to have a look at qaac and ALAC encoding.

Apple Lossless Audio Codes (alac)...

Encoding with alac under qaac is easy, in part because there are not that many commandline options to worry about! Perhaps the biggest choice is whether to use CoreAudio or the Open Source refalac. To use CoreAudio simply run the following:

qaac --alac luckynight.wav

It really could not be much easier could it? If you would like to go Open Source simply substitute refalac for qaac in the above commandline and you will have a great encode and slight self-righteous glow as well! For the sake of completion I give here as well the appropriate syntax to encode as well as tag the little demonstration file:

qaac --alac --verbose \
     --band "Treasure Quest Soundtrack" \
     --artist "Jody Marie Gnant" \
     --track "9" \
     --title "Lucky Night" \
     --genre "Soundtrack" \
     --date "1995" \
     --comment "Testing qaac encoding..." \
     -o luckynight.m4a \

Using a bash 'for' loop it is also possible to import multiple files and then use qaac to convert the import files, this is documented below:

Importing flacs with a 'for' loop..

If you have loaded the extra 32bit dlls that enable import from multiple formats as well as wav you can also convert flac files, which are relatively common online. On my own system I have used this import facility for several very large collections of flac audio files which I have converted to alac using the following code snippet:

mkdir converted && \
for f in *.flac; do
   title=$(metaflac --show-tag=title "$f" | cut -d '=' -f 2)
   artist=$(metaflac --show-tag=artist "$f" | cut -d '=' -f 2)
   album=$(metaflac --show-tag=album "$f" | cut -d '=' -f 2)
   date=$(metaflac --show-tag=date "$f" | cut -d '=' -f 2)
   track=$(metaflac --show-tag=tracknumber "$f" | cut -d '=' -f 2)
   genre=$(metaflac --show-tag=genre "$f" | cut -d '=' -f 2)
   wine ~/.wine/drive_c/qaac/qaac.exe --alac --verbose \
   --title "$title" --artist "$artist" --album "$album" \
   --date "$date" --track "$track" --genre "$genre" --comment "" \
   --artwork cover.jpg \
  "$f" -o converted/"${f%.flac}.m4a"

Note the embedding here for a suitable cover art image. Works very nicely on my system and then the resulting files are then ready for my iPod. However for me the real magic comes from converting an entire CD to alac using the power of the commandline ripper abcde and this is illustrated in the next section.

Using qaac with abcde...

Working as a developer for the commandline ripper abcde has been an exciting time for me and never let it be unsaid that it has been an immense learning curve! One of the great moments for me has been the release of abcde 2.7.1 which allows the use of qaac via Wine. To support this release I have not only researched and written this page detailing the installation and commandline use of qaac but also produced a ready made ~/.abcde.conf file to produce alac files with qaac (or alternatively the Open Source refalac) and abcde. And here it is:

# -----------------$HOME/.abcde.conf----------------- #
# A sample configuration file to convert music cds to 
#   Apple Lossless Audio Codec (alac) using qaac or 
#     refalac and abcde version 2.7.1
#       http://andrews-corner.org/qaac.html
# -------------------------------------------------- #

# Encode tracks immediately after reading. Saves disk space, gives
# better reading of 'scratchy' disks and better troubleshooting of
# encoding process but slows the operation of abcde quite a bit:

# Specify the method to use to retrieve the track information,
# the alternative is to specify 'cddb':

# Make a local cache of cddb entries and then volunteer to use 
# these entries when and if they match the cd:

# Specify the encoder to use for AAC or in our case
# Apple Lossless Audio Codec (alac):

# The path for qaac can be problematic as abcde cannot cope
# with the 'standard' Wine location with spaces:
#   "$HOME/.wine/drive_c/Program\ Files/qaac/qaac.exe"
# However the following works well:             

# Or use the Open Source alac encoder with this small hack:
# QAAC="$HOME/.wine/drive_c/qaac/refalac.exe"

# Specify your required encoding options here, these options
# give Apple Lossless Audio Codec (alac) encoding:
QAACENCOPTS="--alac --threading --verbose"   

# Output type for alac:

# The cd ripping program to use. There are a few choices here: cdda2wav,
# dagrab, cddafs (Mac OS X only) and flac. New to abcde 2.7 is 'libcdio'.
# Give the location of the ripping program and pass any extra options,
# if using libcdio set 'CD_PARANOIA=cd-paranoia'.

# Give the location of the CD identification program:       

# Give the location for the 'compatibility layer software application'
# known as Wine:
# Give the base location here for the encoded music files.

# The default actions that abcde will take.


# Create playlists for single and various-artist encodes. I would suggest
# commenting these out for single-track encoding.

# This function takes out dots preceding the album name, and removes a grab
# bag of illegal characters. It allows spaces, if you do not wish spaces add
# in -e 's/ /_/g' after the first sed command.
mungefilename ()
  echo "$@" | sed -e 's/^\.*//' | tr -d ":><|*/\"'?[:cntrl:]"

# What extra options?
MAXPROCS=2                                # Run a few encoders simultaneously
PADTRACKS=y                               # Makes tracks 01 02 not 1 2
EXTRAVERBOSE=2                            # Useful for debugging
COMMENT='abcde version 2.7.2'             # Place a comment...
EJECTCD=y                                 # Please eject cd when finished :-)

Bear in mind that it is possible to use qaac for AAC encoding instead of alac by altering the QAACENCOPTS to something like: "--tvbr 100" which will produce a very high quality AAC file. Enjoy exploring all of the new possibilities with the addition of this encoder to abcde! Remembering as well that you will need the release version of abcde 2.7.1 for this to work.

And in conclusion...

This page represents my own exploration of the great commandline encoder qaac and my efforts to make it both easy to install and use under Linux. I hope that your own exploration of this great encoder will take you even further and that you thoroughly enjoy the quality audio that you will undoubtedly produce!!