This library provides AAC encoding capabilities for the JVM. It utilizes the FDK AAC library via JNA in order to do so.
Important! While this library uses LGPL-3, please see the FDK AAC license for additional information regarding re/distribution and licensing limitations.
Enjoying my work? A show of support would be much obliged 😁
![](/sheinbergon/jna-aac-encoder/raw/main/assets/liberapay-donate.png)
![](/sheinbergon/jna-aac-encoder/raw/main/assets/buymeacoffee-donate.png)
Artifacts are available on maven central:
Maven
<dependency>
<groupId>org.sheinbergon</groupId>
<artifactId>jna-aac-encoder</artifactId>
<version>2.1.0</version>
</dependency>
Gradle
compile 'org.sheinbergon:jna-aac-encoder:2.1.0'
- Single artifact containing libfdk-aac shared libraries cross-compiled for:
- Linux (64-bit)
- Windows (64-bit)
- OSX (Intel 64-bit / Apple Silicon, compiled with Xcode 13.3 SDK)
- Tested with FDK-AAC version is 2.0.2
- Earlier
2.0.x
versions of FDK-AAC might work, but haven't been tested. - For JDK 8 compatibility, please use version
2.0.0
of this library - For
0.1.6
/0.1.5
FDK-AAC support and Windows 32 bit support, please use version0.1.9
of this library
AudioInputStream input = AudioSystem.getAudioInputStream(...);
File output = new File(...);
AudioSystem.write(input, AACFileTypes.AAC_LC, output);
Performance benchmarks comparing JNA to a BINARY application(aac-enc
) are available using JMH and JMH Visualizer:
To run the benchmarks locally:
- Clone this repository onto a Linux host
- Ensure that you have
libfdk-aac.so
2.0.2 library installed (either from an external repository or manually compiled) - Ensure that you have the
aac-enc
binary installed (either from an external repository or manually compiled) - Run the following command (from within the cloned repository)
./gradlew -b benchmark.gradle jmh jmhReport
- If the aac-enc binary is not installed in /usr/bin/aac-enc, you can a custom path path by adding this gradle property:
-PaacEncBin=/CUSTOM/PATH/TO/AAC-ENC
- The JMH reports can be viewed by opening
build/reports/benchmark/index.html
in your browser.
Currently, libfdk-aac itself supports only the pcm_s16le WAV input format, meaning:
- Sample size - 16 bit(signed)
- WAV format - (L)PCM
- Byte order - Little Endian
While this form of input formatting seems to be the common raw-audio formatting, it's important to note that providing input audio with different formatting will cause the encoding process to fail.
Additional restrictions:
- A maximum of 6 audio input/output channels
- Only the AAC-LC/HE-AAC/HE-AACv2 encoding profiles are supported
- Improved lower-level interface (with examples).
- Support for 24 bit WAV input (via conversion).
- M4A encoding.
- AAC decoding ???