1.0 What is AUAC?
I always rip my CDs to FLAC format. It’s the only format I routinely use for storing my proper music collection: it’s lossless (i.e., no part of the audio signal is discarded in making the file) but is around half the size of the original audio file. Why, then, would I ever need an audio file converter? If it’s in FLAC format, why would I ever need it to be any other format?
Well, FLACs are good for high-quality home audio setups, but they are large files -and if you’re listening to music on the train or an aeroplane, you don’t actually need the perfect audio quality they represent, since the ambient acoustic environment, even with good headphones, is never ideal. For those situations, therefore, I maintain a copy of my FLAC collections in relatively low-quality MP3 files. These are lossy (a lot of the audio signal is simply thrown away, though it’s supposed to be parts of the signal few human ears are ever likely to notice in the first place!), and accordingly much smaller than the source FLAC files (about half the size, at least).
I also occasionally buy music in APE format -another lossless format, which I prefer to convert into equally lossless FLACs.
Even more occasionally, I buy ISO images of SACD discs. These store audio in a ‘high definition’ format: DSF, which usually uses a 24-bit, 88.2Khz sampling rate (by comparison, ordinary CDs use a 16-bit, 44.1Khz sampling rate). SACD audio files are therefore enormous -getting on for 8 times the size of the equivalent, ordinary FLAC… but my ears are old enough that they can’t hear the difference! So why store a 900MB file when you can store it as an 88MB FLAC?
In other words, I often want to convert FLACs into lossless MP3s; I sometimes want to convert one lossless format into another; and I occasionally need to convert from ‘High Definition’ audio into conventional audio. For all these reasons, I needed a simple command line tool to be able to handle lots of possible source formats and output to several possible output formats: the Absolutely Baching Universal Audio Converter (AUAC) is that tool.
2.0 Obtaining and Installing AUAC
AUAC is a simple Bash script which can be downloaded by clicking this link. Once downloaded (I shall assume you’ve downloaded it to your own Downloads folder for what follows), you ‘install’ it by opening a terminal session and typing the following:
sudo mv $HOME/Downloads/auac.sh /usr/bin sudo chmod +x /usr/bin/auac.sh sudo ln -s /usr/bin/auac.sh /usr/bin/auac
That is, as root, you move the downloaded file into the /usr/bin folder (where it will then be in your environment’s PATH). You make it executable. Finally, you create a link to the new executable that lacks the “.sh” extension, so that you can invoke the program just by typing “auac”, rather than “auac.sh”.
Since AUAC is simply a Bash shell script, you are encouraged to open the downloaded file in the text editor of your choice, to satisfy yourself that it does what it claims it will do and nothing else.
2.1 Software Prerequisites
Note that AUAC has some software requirements that you will have to install before you can run AUFC successfully. Principle amongst these are the need to have ffmpeg installed, but there are some others -and they are unfortunately handled differently by different distros.
sudo pacman -Sy ffmpeg fd pv parallel flac lame vorbis-tools mac
sudo apt-get install ubuntu-restricted-extras sudo apt-get install ffmpeg fd-find pv parallel flac lame vorbis-tools
The Restricted Extras metapackage gets you a lot of audio codecs (and a lot of Microsoft fonts which aren’t really needed!), which appears to be necessary to support APE (Monkeys Audio) formats.
sudo apt-get install ffmpeg fd-find pv parallel flac lame vorbis-tools
I have not yet been able to find an easy way of enabling APE support in the latest version of Debian.
sudo dnf -y install https://download1.rpmfusion.org/free/fedora/rpmfusion-free-release-$(rpm -E %fedora).noarch.rpm sudo dnf -y install https://download1.rpmfusion.org/nonfree/fedora/rpmfusion-nonfree-release-$(rpm -E %fedora).noarch.rpm sudo dnf install ffmpeg fd-find pv parallel flac lame vorbis-tools mac
The first two lines are required to enable the rpmfusion repository, without which quite a few audio-related packages cannot be installed
In all cases, ffmpeg is an immensely capable piece of multimedia manipulation software -and accordingly pulls in a huge array of associated packages. Its installation on all platforms can take quite a while, therefore! The “flac lame vorbis-tools mac” components of those installation commands give the OS a capability to understand FLAC, MP3, OGG and APE files. WAV is understood natively.
2.2 Optional SACD ISO Support
If you want to be able to extract and convert SACD ISO images, you’ll need to be running on Manjaro (or Arch, etc) or Ubuntu: it won’t work on Fedora or Debian, unfortunately (not without more work than I’m prepared to put in on installing the relevant decoding software!) On the supported platforms, you need to issue the following commands:
On Arch or Manjaro:
pamac build sacd-decoder-bzr
(don’t edit build files, but agree to apply the transaction)
sudo add-apt-repository ppa:robert-tari/main
sudo apt update
sudo apt install sacd
If you don’t install the “sacd-decoder” program, you can continue to use AUAC to convert between the supported audio formats, but not from SACD ISOs.
3.0 Using AUAC
Once the script has been downloaded and made executable; and once the various software pre-requisites have been installed; you can actually run AUAC successfully. To do so, you first need to open a terminal session and “cd” to a directory that contains the music files you want to convert. See Section 3.8 below for a way to stop needing to do this.
Once there, you invoke AUAC as follows:
auac [ -i=<input format> | -o=<output format> | -q=<quality number | -d=<y or n> ]
This means that the AUAC program is invoked with from 0 to 4 parameters which control what it does and how it does it. We’ll examine each of those parameters in turn now.
3.1 Input and Output Audio Formats
The -i parameter tells AUAC which audio format files it’s supposed to be converting. The default is FLAC. The -o parameter tells AUAC to which audio format it’s supposed to be converting the input files. The default is also FLAC.
The full list of audio formats supported is as follows:
|flac||FLAC is lossless. Can be specified as input and/or output|
|wav||WAV is lossless, but can contain no metadata tags. Can be specified as input and/or output|
|ape||APE is lossless. Can be specified only as an input format. AUAC cannot output to APE|
|mp3||MP3 is lossy. Can be specified as input and/or output|
|ogg||OGG is lossy. Can be specified as input and/or output|
|wma||WMA is lossy. Can be specified as input and/or output|
|iso||ISO files are SACD images. Can only be specified as an input format. AUAC cannot output to ISO|
Lossless audio formats are those which contain the complete audio signal from a CD but are usually compressed to about half their usual size. WAV files are lossless and uncompressed. Lossy formats, however, throw away some of the audio signal (in the belief that you can’t really hear it anyway, so it’s loss won’t matter). Since they discard some of the audio signal, they can achieve much smaller sizes than any lossless format could manage.
Note that AUAC will happily convert a lossy format to another lossy format. This is inadvisable to do (because doing so just compounds the amount of audio signal that is being discarded at each conversion step), but AUAC will not stop you doing it, if you insist on it.
3.2 Quality Setting
The quality parameter determines the aggressiveness with which lossy output formats will discard parts of the audio signal. If they discard large amounts of it, your output files will be very small, but will probably sound a bit rough. If they don’t discard much, they will sound good, but will be significantly larger than they otherwise would be (but still not as big as a lossless FLAC or APE would be).
The quality setting only applies when the specified output audio format is a lossy format. If you are outputting to FLAC, for example, and say ‘-q=6’, the quality parameter is just silently ignored (since lossless formats don’t discard any of the audio signal at all, ever).
The default quality setting is “4”, which approximates to around 128kbps and will result in “reasonable” sound quality for all the lossy formats you might want to use. Unfortunately, MP3 qualities work in the opposite way to the way OGGs and WMAs work. That is, when outputting MP3s, a quality of 9 will sound terrible and a quality of 0 will sound excellent. When outputting OGG or WMA, however, exactly the opposite applies: a quality of 9 for either of those formats will sound great and a quality of 0 or 1 would sound very poor.
3.3 Delete after Conversion
AUAC does not delete the input file(s) by default. If you are converting FLACs to MP3s, for example, the default situation is to end up with a set of FLACs and MP3s. Only if you specify -d=y will the source files be deleted at the end of the conversion process.
You may, however, specify an environment variable called AUAC_AUTODELETE which reverses this behaviour. If that is set to the value of TRUE before you run AUAC, then AUAC’s default behaviour will be to delete your input files unless you say -d=n. To set an environment variable temporarily, you can generally issue the command export AUAC_AUTODELETE=TRUE (with no spaces anywhere). To set it permanently, you can usually add the line AUAC_AUTODELETE=TRUE to your .bashrc or .bash_profile file, though you generally then have to launch a new terminal session before the new variable is automatically set in your session.
You can check whether AUAC_AUTODELETE has been set by issuing the command:
The use of upper-case for this parameter in all contexts is mandatory. The result would be something like:
Once you see it set to ‘TRUE’, you know that your input files will be deleted automatically, unless you explicitly say -d=n.
3.4 Folder Depth
By default, AUAC only looks in the current working directory to find files to convert. There is no run-time parameter you can supply to alter this behaviour, either. However, if you set an environment variable called AUAC_FOLDERDEPTH to a numeric value, either with an interactive “export” command or via your .bashrc or similar environment-setting configuration file, then the program will look that many folders deep to find files.
Consider the following example:
Here I have a folder, called /home/hjr/Desktop/temp, which contains 6 different sub-folders, each containing a set of audio files of a single Haydn symphony. If I invoke AUAC in the ../temp folder directly, with nothing specially configured, this happens:
Since the /temp folder itself contains none of the input files my AUAC command implied, the program simply errors out, having performed no conversions. The ‘normal’ alternative at this point is to descend into each Symphony’s own folder, one by one, and perform the file conversion for each in turn. With a couple of folders to process in this way, this might not be a bad option. But if I set AUAC_FOLDERDEPTH=2, then the program will look in the folder at depth 1 (which is the /temp folder) and then in every folder directly beneath that (which, in my case, would mean considering the contents of each of the symphonies’ folders, too. So first I set the depth to 2:
…and now I re-run AUAC with exactly the command I used before:
This time, AUAC works perfectly well, because it has been able to find source ‘flac’ files. They are not in the /temp directory that, as you can see, I’m still sitting in as my working directory; but it has now been allowed to descend one more folder level down -and it’s found usable FLAC files there.
This feature is designed to allow you to convert multiple source folders’-full of files in one quick pass. It is, potentially, quite lethal: if I accidentally ran AUAC in the root of my master FLAC collection with AUAC_FOLDERDEPTH set to something silly like 99, I’d see all my FLAC files converted to (potentially) a lossy format at a single stroke! For this reason, it is recommended that you only set folder depth to 2, or possibly 3, at the most. AUAC will not warn you if you go beyond that, however, and the consequences are all on you!
3.5 Special Audio Formats
You will see from the above list that there are two formats which AUAC is happy to accept as inputs, but cannot use as outputs: APE and ISO. Ape is a lossless format which the conversion tool which AUAC uses, ffmpeg, cannot normally deal with: licensing issues seem to be the main problem here! ISOs are a special case at the best of times: these are SACD image files, and not the normal ISOs which you might see used, for example, to store a Linux distribution. They accordingly have to be read and extracted by special tools before their contents can be converted into one of the output formats. It would thus make no sense at all to produce an SACD ISO image, even if you wanted to, since you’d never be able to play it on your computer anyway!
AUAC ordinarily converts audio files in parallel (i.e., multiple files at once). The default degree of parallelism is the number of available CPU threads. If, for example, you have a quad core CPU with hyperthreading enabled, the default degree of parallelism would be 8.
A higher degree of parallelism means audio conversion jobs finish more quickly than they would with a lower degree of parallelism. On the other hand, if your CPU is hit hard by a high degree of parallelism, your PC may effectively lock-up and be unable to do any other work for you until the audio conversion job is complete.
You can change the default degree of parallelism by setting and environment variable called AUAC_THREADS. If you set it to 16, for example, then 16 concurrent conversion jobs will be run; set it to 2, and only 2 audio files will be converted at the same time.
You are not required to limit the setting to the actual number of virtual cores your PC has, but it probably makes no sense to do so: you CPU can only process the same number of jobs at any one time as you have virtual cores. If you set AUAC_THREADS higher than the number of virtual cores, the extra threads are simply paused as the maximum that can run do so.
Here is an example of me setting AUAC_THREADS dynamically, immediately before invoking AUAC itself:
If you wish to make a more permanent setting of a default, you can edit your .bashrc or .bash_profile and set the parameter in there, like this:
In my .bashrc, I’m setting all three AUAC-related envionment variables, but you don’t have to do this if the defaults are acceptable. Note that there is no run-time switch that can over-ride the defaults for folder depth or the number of threads to use for conversion jobs.
3.7 General Usage Notes
From the syntax example shown at Section 3.0 above, you can see that all run-time parameters supplied to AUAC are optional. Any which you do not supply have defaults. Input and output formats default to FLAC; quality defaults to 4; delete defaults to ‘no’ (unless the AUAC_AUTODELETE environment variable has been set to TRUE). Additionally, AUAC defaults only to looking in the current folder for input files and will run with a degree of parallelism that matches the number of virtual cores your PC possesses.
There are three possible environment variables which can be set to change the default delete behaviour (AUAC_AUTODELETE), the folder depth used to find input files (AUAC_FOLDERDEPTH) and the degree of parallelism (AUAC_THREADS).
When you don’t specify an input format, the program assumes, as previously mentioned, that it’s being asked to convert from FLAC. When you also don’t specify an output format, the program will assume that it’s being asked to convert to FLAC. When you therefore specify neither an input nor an output format, the program will assume it is being asked to convert from a FLAC to a FLAC – which might seem a bit pointless! However, it is actually a legitimate thing to do, since you might be converting from high definition 24-bit FLACs and wanting to output to CD-quality, 16-bit FLACs. When both input and outputs are explicitly specified to be FLAC; or when they are implicitly defaulted to both be FLAC, then the conversion will always be to 16-bit, 44.1KHz sampling rate CD-quality FLAC -and a ‘-16’ will be added to the file names to indicate the newly converted files are, indeed, 16-bit ones.
When AUAC is asked to convert from a format, it determines whether files of that format are present simply by looking at file extensions. If, for some weird reason, you have decided to name all your FLAC files to be <something>.xyz, for example, then any AUAC job that asks to convert from FLAC to (say) MP3 will fail to run with a ‘no input files of the right format found’ error. AUAC does not inspect files, in other words, to check whether their internal contents match the required format.
AUAC always converts all files of the specified input format, if they exist. That is, if you have a folder containing four FLAC files and you run AUAC to convert FLACs to MP3s, all four files will be converted to MP3. You cannot, in other words, get selective about it: you can’t ask for AUAC to convert only 3 of the 4 FLACs.
AUAC always over-writes any output files it is asked to create. This means that if you convert some FLACs to MP3s (for example), without deleting the inputs, you can run the same conversion job a second time and the MP3 files already present will be re-created without warning. The MP3s created by the first AUAC run will, in other words, be silently over-written by the second. You will not end up with two sets of MP3 files, despite the two runs of AUAC.
Please be aware that AUAC does not delete any files unless asked; and even if asked, it won’t do so until all output files have been created. This means that you need to operate the program on a system that has sufficient free disk space to accommodate both versions of your music files, if only temporarily. If you don’t explicitly ask for source files to be deleted, they won’t be -so, in that case, both versions of your files will co-exist for, potentially, quite a long time!
All AUAC run-time parameters can be specified in a double-hyphen, long-form version, if you prefer to work that way. For example: ––input=, ––output=, ––quality=, ––delete=
3.8 Working Remotely
AUAC’s default mode of working is always to expect to be invoked within a directory that contains the audio files you wish to convert. If the FLAC files you want to convert are stored in /home/hjr/Desktop/temp, for example, then AUAC would normally expect you to first cd to that directory before invoking it. If you are frequently converting files, however, and the directory they’re stored in is always the same, having to cd to that directory before you can do any conversion work can become tiresome.
Accordingly, AUAC has the ability to let you to work ‘remotely’ -that is, to convert files in a directory that you are not currently located within. For example, I could open a new terminal and I would default to being in /home/hjr -which isn’t where I store my FLAC files at all. But, if the AUAC_WORKINGDIR environment variable is set to /home/hjr/Desktop/temp, then I can convert audio files stored in that temp directory, even though I don’t first cd to it.
You can set this environment variable dynamically:
You can set this parameter statically in your .bashrc or .bash_profile files:
Whichever method to set the variable you use, you can always ‘switch it off’ by issuing the command:
…and at that point, AUAC will revert to its default behaviour of expecting to see audio files within the current directory. If the parameter is set statically in your .bashrc or .bash_profile file, however, opening a fresh terminal session will cause the AUAC_WORKINGDIR environment variable to be set once more, and you’re once more back to being able to work on files stored in a directory other than the one you are currently in.
Note that if you decide to set AUAC_WORKINGDIR, it must point to a single directory that actually exists and to which you have read/write access. The program will immediately display an error message and quit if these conditions are not met.
4. Some AUAC Examples
Given this directory of files:
Then we can convert all those files to reasonable-quality MP3s as follows:
cd /home/hjr/Desktop/temp auac -o=mp3
Note that I have not specified an input format (because FLAC will then be assumed). I haven’t altered the default quality (so 4 will be used) and I haven’t asked for the source FLACs to be deleted, so 10 files should be present in the folder when I’m done:
The program reminds you what directory you’re working in, with a message towards the top the screen. Keep an eye on that: it’s there so you don’t accidentally convert files in places you didn’t mean to work in! A reminder of what you’re converting from and to is also displayed towards the top of the screen: here, “flac” has been assumed as the ‘from’ format, even though I didn’t specify it. At the end of the conversion process, we see:
For each FLAC, there now exists an equivalently-named MP3. The FLACs did not disappear, because I did not ask them to be deleted (if you don’t explicitly set -d=y, the default is to assume that -d=n).
Now I will convert all the MP3s to OGG, but I will ask for the MP3s to be deleted:
auac -i=mp3 -o=ogg -d=y
The program display is very similar to before: the only difference is that the ‘Converting…’ message at the top of the screen reminds you that this is an MP3-to-OGG run. Remember that doing this is rather foolish, since the resulting OGGs will be of rather poor quality, since they are being produced from files which were already of only ‘reasonable’ quality. Nevertheless, the point is that it is possible to convert from lossy to lossy formats. AUAC won’t stop you from doing so.
Anyway, the result of this conversion run:
There are still only 10 files in the folder: the original FLACs and now equivalent OGG files. But there are no MP3 files now, since they were deleted once all the OGGs had been created. If you compare the OGG file sizes to those produced earlier by the creation of MP3s, you’ll see the files are in the same sort of size ballpark. File 4, for example: 23.7MB as a FLAC, 7.1MB as an MP3 and 5MB as an OGG. The MP3 and OGG default qualities are not identical, but they are approximately equivalent.
A final example: let us create a set of OGGs of much higher quality, this time from the source FLACs directly. The command would be:
auac -i=flac -o=ogg -q=9
Remember that for MP3s a quality of 9 would be terrible, but for OGGs and WMAs, 9 is about the best you can get (though not as good as the original flac, of course):
Again, we see the FLACs and OGGs co-exist, since I didn’t ask for the source files to be deleted. But we now see that the OGGs are much larger than before (though still around half the size of the source FLACs): File 4, for example, is now 12MB in size, rather than its previous 5MB. By upping the quality parameter, we have discarded less of the source audio signal and thus the file sizes get bigger.
auac -o=wma -d=y
This command doesn’t mention an input format, so FLAC is assumed. It doesn’t mention a quality for the WMA output files, so a quality of 4 is assumed, which works out to be about 140Kbps. And we’re this time asking for the source FLACs to be deleted after the conversion completes:
Notice how this time, the folder contains the earlier OGGs and now a new set of WMAs …but no FLACs. The OGGs persist because they were not part of the AUAC ‘transaction’ just completed. A folder may contain a mix of flacs, oggs, wmas and ISOs, for example: if the auac command says -i=wma, only the WMA files present in the current directory will be read (and deleted, if that’s requested explicitly). The FLACs, OGGs and ISOs that might be present at the same time are simply ignored.
SACD ISOs are a special category of files and the program will look slightly different when you use AUAC to work with them. A command to extract and convert an SACD image might be:
…which implies a conversion of the SACD image contents to 16-bit, CD-quality FLACs (since no output format is explicitly mentioned, and that’s the default):
When extracting SACD ISOs, the AUAC program looks slightly differently than it otherwise would: there is a message indicating that the ‘sacd’ program has been invoked. The inability, easily, to install that program on Fedora or Debian is why working with ISOs is only supported on Ubuntu, Arch and Manjaro distros. As the program extracts the ISO contents, you’ll see this if you look in your file manager:
You will see the presence of a number of WAV files, despite me asking for the ISO to be extracted to FLACs. This is normal. ISOs are extracted to WAVs as an intermediate file format. These intermediate files are then converted to the requested output format (in this case, FLAC). Only then are the intermediate files deleted -and they are deleted whether you said -d=y or not. At the end of this conversion, therefore, I will see this:
Notice that, now, I have a bunch of FLAC files, as requested. The ISO file also exists -because I didn’t say -d=y. But the WAVs have disappeared. When working with ISOs, in other words, the intermediate files are always deleted; the source ISO is only deleted if you explicitly ask for it to be. So, as a final example, I will re-issue my last command with a small additional component:
auac -i=iso -d=y
…and the net result of that is:
This time, I have my FLACs as before (the new ones silently over-wrote the originals produced last time)… but the ISO itself is missing. When working with ISOs, the ––delete or -d parameter governs what happens to the source ISO, not what happens to the intermediate WAVs, in other words.
5.0 Housekeeping and Legal Stuff
AUAC was devised and written by Howard Rogers (email@example.com).
AUAC is copyright © Howard Rogers 2020, but is made available freely under the GPL v2.0 only. That license may be downloaded here.
Bugs Tracking, Feature Requests, Comments
There is no formal mechanism for reporting and tracking bugs, feature requests or general comments. But you are very welcome to email your comments to firstname.lastname@example.org.