Apple AAC: Difference between revisions
(remake a little) |
Logan589XP (talk | contribs) m (Updated version number to 2.82.) |
||
(43 intermediate revisions by 16 users not shown) | |||
Line 1: | Line 1: | ||
{{aac-encoders}} | {{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|Hydrogenaudio listening tests]]. | The encoder does consistently well in [[Hydrogenaudio Listening Tests|Hydrogenaudio listening tests]]. | ||
__TOC__ | |||
== Bitrate modes == | |||
Four rate settings are present in Apple AAC:<ref>https://hydrogenaud.io/index.php/topic,118203.0.html Testing by Pr0m3th3u5 in 2019; comment by JAZ</ref> | |||
; 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. | |||
{|class=wikitable | |||
|+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:<ref name=CABT>https://github.com/phracker/MacOSX-SDKs/blob/041600eda65c6a668f66cb7d56b7d1da3e8bcc93/MacOSX11.3.sdk/System/Library/Frameworks/CoreAudioTypes.framework/Versions/A/Headers/CoreAudioBaseTypes.h#LL391C2-L391C</ref> | |||
* 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.<ref name=CABT/> | |||
;-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 <code>afconvert --help</code> to see them all, or see [https://ss64.com/osx/afconvert.html SS64] for an unofficial list. | |||
== QAAC == | == QAAC == | ||
Line 11: | Line 84: | ||
| caption = | | caption = | ||
| maintainer = nu774 | | maintainer = nu774 | ||
| stable_release = | | stable_release = 2.82 | ||
| preview_release = | | preview_release = | ||
| operating_system = Windows | | operating_system = Windows | ||
| use = Encoder | | use = Encoder | ||
| license = Various | | license = Various | ||
| website = [https://github.com/nu774/qaac github | | website = [https://github.com/nu774/qaac github/qaac] | ||
}} | }} | ||
QAAC is an open-source wrapper for | |||
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. | |||
* [https://github.com/nu774/qaac/wiki QAAC documentation] | |||
Linux users [https://www.andrews-corner.org/qaac.html should be able to use wine]. The most fragile part apparently is [https://github.com/enzo1982/freac/issues/168 getting AppleApplicationSupport to install]. | |||
<br clear="right" /> | |||
== ffmpeg == | |||
On macOS, ffmpeg 4.4 and above can use the <code>aac_at</code> 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 <code>q = 127 - q * 9;</code>.<ref>https://github.com/FFmpeg/FFmpeg/blob/f009f849617ab0c2015d2a748892d55b37d378c0/libavcodec/audiotoolboxenc.c#L328</ref> | |||
On Windows, ffmpeg's build process can be tricked into linking to an CoreAudioToolbox.dll commonly distributed alongside iTunes, using [https://github.com/dantmnf/AudioToolboxWrapper AudioToolboxWrapper]. | |||
==External links== | ==External links== | ||
<references /> | |||
*[http://www.apple.com/quicktime Apple's Quicktime Website] | *[http://www.apple.com/quicktime Apple's Quicktime Website] |
Latest revision as of 03:30, 31 March 2024
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.
-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
Developer(s) | nu774 |
Release information | |
---|---|
Stable release | 2.82 |
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
- ↑ https://hydrogenaud.io/index.php/topic,118203.0.html Testing by Pr0m3th3u5 in 2019; comment by JAZ
- ↑ a b https://github.com/phracker/MacOSX-SDKs/blob/041600eda65c6a668f66cb7d56b7d1da3e8bcc93/MacOSX11.3.sdk/System/Library/Frameworks/CoreAudioTypes.framework/Versions/A/Headers/CoreAudioBaseTypes.h#LL391C2-L391C
- ↑ https://github.com/FFmpeg/FFmpeg/blob/f009f849617ab0c2015d2a748892d55b37d378c0/libavcodec/audiotoolboxenc.c#L328