Using fhgaacenc under Linux...

It is perhaps no coincidence that I am watching 'Star Trek: Picard' at the moment and seeing Jean-Luc Picard struggling with ghosts, lost opportunities and long dead friends. Some similarity perhaps in this resurrection of what could have been one of the best AAC encoders available and also the resurrection of a page on my own web site that has never been terribly popular. Nevertheless, like Jean-Luc's final appearance, here we are again...

fhgaacenc is a wrapper for the commercial AAC encoder licensed to the defunct Winamp and has the virtue of not only producing great AAC-LC files but also HE-AAC and HE-AAC v2 files. It is the aim of this page to allow keen Linux users to be able to experiment with fhgaacenc and hear for themselves the quality of the audio produced by ffhgaacenc and the enc_fhgaac.dll of WinAmp.


fhgaacenc and WinAmp were created for Windows users so will need to install the Wine package appropriate for your distro, I have successfully tested this guide running Wine 5.22 under Slackware Linux. You will also need the 7z file archiver packaged for your Linux distro. If you are running Ubuntu for instance you will need something like the following:

sudo apt-get install wine p7zip-full

With these installed you will need both the fhgaacenc application zip file and a modern copy of WinAmp from which we will extract the appropriate dll files. The following single command makes a build directory, downloads and then unzips fhgaacenc 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/fhgaacenc_build && \
cd $HOME/fhgaacenc_build && \
wget && \
7z e \
     fhgaacenc.exe libsndfile-1.dll -r \
     -o$HOME/.wine/drive_c/fhgaacenc/ && \
chmod +x $HOME/.wine/drive_c/fhgaacenc/fhgaacenc.exe

The next single command downloads the WinAmp installation file and extracts the dll files needed by fhgaacenc. You will notice, Gentle Reader, that I have taken the substantial liberty of hosting the WinAmp installation file on my own web space, WinAmp is now dead in terms of development so I am doing my own little bit to preserve at least the installation file!

cd $HOME/fhgaacenc_build && \
wget && \
unzip && \
7z e winamp5666_full_en-us_redux.exe \
     enc_fhgaac.dll libmp4v2.dll \
     nsutil.dll -r \

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 fhgaacenc more easily. I include here as well a line to turn off the painful Wine debugging messages:

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

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

All done! With the installation done I will next describe the commandline usage of fhgaacenc. Bear in mind that it is also possible to use fhgaacenc with the commandline audio CD ripper abcde (actually I made this possible when I was an abcde developer!) but times have moved along and I will leave you, Gentle Reader, to sort this one out yourself...

Commandline usage...

Before launching straight into the command line usgae of fhgaacenc let us clear up some confusion about AAC encoding in general. Currently (March 2021) for our purposes there are 4 recognised forms of AAC encoding available to Linux users:

  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. fhgaacenc 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. ghgaacenc 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). fhgaacenc 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!

To demonstrate the commandline usage of fhgaacenc I will use my favourite wav file and perhaps you should also download it? The options for fhgaacenc are remarkably simple and I will demonstrate the usage for both VBR and CBR encoding:

fhgaacenc and Variable Bitrate Mode (VBR)...

fhgaacenc's default mode is VBR and certainly if you have no special needs this is the mode you should also use. Rather than target a specific bitrate there are a set of profiles numbered from 1-6 which will achieve a certain overall bitrate as well as allowing fhgaacenc to automatically select the appropriate AAC mode. The table below show the typical bitrates and modes achieved with each preset:

fhgaacenc VBR Presets
VBR preset 1 2 3 4 5 6
Overall Bitrate in kbps 38.0 64.5 98.6 132.0 207.0 253.0
Testing with this file: fhgaacenc --vbr <n> luckynight.wav

Note that fhgaacenc does not have any tagging capabilities and I have personally been using the latest version of AtomicParsley to achieve easy tagging. So to get great AAC-LC sound and appropriate tagging something like the following would be fine for our sample file:

fhgaacenc --vbr 5 luckynight.wav luckynight.m4a && \
AtomicParsley luckynight.m4a \
              --album "Treasure Quest Soundtrack" \
              --artist "Jody Marie Gnant" \
              --tracknum "9" \
              --title "Lucky Night" \
              --genre "Soundtrack" \
              --year "1995" \
              --comment "Testing fhgaacenc encoding..." \

And this may very well be enough for all of your encoding needs with fhgaacenc, it certainly is enough for my own usage. But if you would like a little more have a look at the following section which deals with the use of CBR encoding:

fhgaacenc and Constant Bitrate Mode (CBR)...

If you have decided to use CBR encoding you will have a few more choices to play with. You can select a bitrate from 8kbps to a mind-altering 576kbps as well as either allowing fhgaacenc to select the most appropriate AAC format or manually selecting it yourself with the --profile option (by default set to 'auto'). To illustrate this point So the following commandline creates an HE-AAC v1 file of the correct bitrate:

fhgaacenc --cbr 64k luckynight.wav

But this bitrate is on the cusp of the boundary where you could with some degree of sanity prefer to use AAC-LC and this can be forced as follows:

fhgaacenc --cbr 64k --profile lc luckynight.wav

The profile options are: --profile <auto|lc|he|hev2> and to tell the complete truth the defaults are quite sane and will not need tampering with all that much. But I am pretty sure many will have turned to this page to experiment a little with HE-AAC v2 so I give an example below of such an encoding along with the addition of metadata:

fhgaacenc --cbr 32k --profile hev2 luckynight.wav luckynight.m4a && \
AtomicParsley luckynight.m4a \
              --album "Treasure Quest Soundtrack" \
              --artist "Jody Marie Gnant" \
              --tracknum "9" \
              --title "Lucky Night" \
              --genre "Soundtrack" \
              --year "1995" \
              --comment "Testing fhgaacenc encoding..." \

It all works beautifully on my system and I sincerely hope, Gentle Reader, that it all works nicely on your own system as well. After you have heard the quality of this sound you will question your need for a higher bitrate, ever...

And multiple files...

I rarely receive email about this page which I confess saddens me a little! However I did recently receive a request for a command that would convert an entire directory of wav files using fhgaacenc. This can be easily accomplished with something like the following bash 'for' loop:

mkdir converted && \
for f in *.wav; do
fhgaacenc --vbr 5 "$f" converted/"${f%.wav}.m4a"

And so I have included this snippet here in case any future readers of this site find it useful...

And in conclusion...

This page represents my own exploration of the commandline encoder fhgaacenc and my efforts to make it both easy to install and to use under Linux. If I have perhaps made your own usage of fhgaacenc a little easier let me know. Also let me know of any errors on this page or indeed if there are better ways to accomplish the various tasks I have outlined here. And above all "Have fun!".