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. qaac is an application that uses Apple AAC to produce the best AAC quality available today which is otherwise not available in a Linux environment. This page provides a simple copy and paste approach to an installation that can otherwise be somewhat complex. As well I have included instructions on basic command line usage so once the installation is complete, Gentle Reader, you can launch straight into encoding...

If this page helps anyone to get their first usage of this great command line encoder I will be very happy. I have revisited this page in August 2019 and followed all of the steps on a fresh Slackware install and it all worked beautifully, so hopefully it will work just as well on your own system!


One fundamental fact of qaac is that it is a native Windows application so under Linux you will need to install the Wine package appropriate for your distro. 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 && \
unzip -j 'qaac_2.68/x86/*' -d ~/.wine/drive_c/qaac/

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

cd $HOME/qaac_build && \
wget \ && \
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 and 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 && \
unzip -j '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 Apple's core audio framework Core Audio! 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.68, CoreAudioToolbox
libsoxconvolver 0.1.0
libFLAC 1.3.1
wavpackdll 5.0.0
tak_deco_lib 2.3.0 compatible

All done and when I repeated these steps in August 2019 with a fast computer and a good broadband speed the whole installation took only 5 minutes! I believe this is the most current version of Core Audio from Apple (as of January 2019), remembering that Apple AAC is still scored by HydrogenAudio the best AAC encoder available today. Next I will describe the command line usage of qaac and show how to import multiple flac files with a bash 'for' loop a

Commandline usage...

Before launching straight into the command line usgae of qaac let us clear up some confusion about AAC encoding in general. Currently (August 2019) 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", or some may even use the more umbrella term Unified Speech and Audio Coding (USAC). 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. There is now an encoder: exhale which produces playable xHE-AAC files under Linux. Exciting times!

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 && \
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
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
Testing with this file: qaac --tvbr <n> luckynight.wav

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. 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 playback with a nice piece of album art showing!