Apple AAC

From Hydrogenaudio Knowledgebase
Current AAC encoders
(most to least recommended)
1 Apple AAC M/W
2 FhG AAC (Winamp) W
3 Fraunhofer FDK AAC S/L/M/W
4 Nero AAC L/W
5 FFmpeg 3.0+ AAC encoder S/L/M/W
6 FAAC S/L/M/W
7 Libav (pre-3.0 FFmpeg) AAC encoder S/L/M/W
S Source code available; L Linux; M macOS; W Windows
List of AAC encoders

Apple AAC is an AAC codec developed by Apple Inc. and included in Apple's audio framework, Core Audio. Core Audio is used in iTunes, Safari web browser, and other Apple products. Apple's AAC encoder is known to be one of the highest quality medium-bitrate CBR and VBR LC AAC encoders. The encoder started as part of the QuickTime media framework, but Apple has transitioned away from QuickTime, to AV Foundation and AudioToolbox.

The encoder does consistently well in Hydrogenaudio listening tests.

Bitrate modes

Four rate settings are present in Apple AAC:[1]

Constant bitrate (CBR)
Similar to MP3 CBR in how it handles the bit reservior, but can still swing a little from the target
Average bit rate (ABR)
Self-explanatory
Constrained VBR
Like ABR, but seems to be more open to using more bits
Variable bitrate (VBR)
"True" VBR (TVBR, unofficial name)
Takes a quality from 0 to 127 (kAudioCodecPropertySoundQualityForVBR). Seems to perform similarly to cVBR once the below table is used for bitrate conversion.
TVBR bitrate mapping (AAC)
-ue / -Q ffmpeg q bitrate (bps)
45 9.11 96
64 7 128
73 6 144
82 5 160
91 4 192
109 2 256
127 0 320

The above is approximated by a piece-wise function, although the neatness is likely more indicative of how HA users pick values for tests:

Bitrate(q) = (40 * q - 1184) / 9   82 <= q < 128
             (16 * q + 128)  / 9   64 <= q < 82 

TVBR is not available for HE-AAC.

Format support

Apple's CoreAudioBaseTypes lists the following AAC-derived codecs on macOS 11.3:[2]

  • AAC-LC (MPEG-4)
  • AAC-LD
  • AAC-ELD
  • AAC-ELD + SBR
  • HE-AAC v1 (AAC + SBR)
  • HE-AAC v2 (v1 + PS)
  • USAC
  • MPEG-4 Spatial

There should also be support for a number of other format, at least in decoding: Apple does not ship a standalone AAC codec, but a whole audio-processing kit.

Actual support depends on library version and whether the program used to call the library knows how to use these formats.

  • afconvert is clumsy but exposes almost everything.
  • QAAC only does LC and HEv1. It can use some of the audiotoolkit filters while it works.
  • FFmpeg only knows about using Apple AAC with LC, LD, ELD, HE, and HEv2.

afconvert

Apple's macOS includes a command-line utility for transcoding audio files that employs this encoder when encoding to AAC.

Usage:

afconvert [options] <infile> <outfile>

Options:

-f --file <string>
File format. Several; use 'm4af' for '.m4a' file or 'adts' for raw '.aac' file.
-d --data <string>
Data format. Several; use 'aac' for AAC-LC. See CoreAudioBaseTypes.h link in footnote.[2]
-s --strategy <0,1,2,3>
Bitrate allocation strategy. 0 for CBR, 1 for ABR, 2 for VBR_constrained, 3 for VBR
-b --bitrate <n>
Bitrate in bits per second. Does nothing when used with strategy 3.
-ue vbrq <0-127>
Output quality for VBR mode. Only applicable when using strategy 3.
-q --quality <0-127>
Speed/quality trade-off. Internally rounded to a value of either 32, 64, or 96.

afconvert has way more options than those listed above, but not all are useful for AAC. Run afconvert --help to see them all, or see SS64 for an unofficial list.

QAAC

qaac

Developer(s) nu774
Release information
Initial release {{{released}}}
Stable release 2.82
Preview release
Compatibility
Operating system Windows
Additional information
Use Encoder
License Various
Website github/qaac

QAAC is an open-source wrapper for Core Audio's AAC and ALAC encoders that allow them to be used directly in applications that don't otherwise use Core Audio. It exists only for Windows.

Linux users should be able to use wine. The most fragile part apparently is getting AppleApplicationSupport to install.


ffmpeg

On macOS, ffmpeg 4.4 and above can use the aac_at codec to use Apple AAC via the new AudioToolbox.framework. In addition to AAC-LC, HE-AAC (v1/v2), AAC-LD, and AAC-ELD are available, the same selection of profiles as FDK AAC. FFmpeg uses a 0-14 quality range to be converted to the 0-127 scale, using the expression q = 127 - q * 9;.[3]

On Windows, ffmpeg's build process can be tricked into linking to an CoreAudioToolbox.dll commonly distributed alongside iTunes, using AudioToolboxWrapper.

External links