jna-aac-encoder
This library provides AAC encoding capabilities for the JVM. It utilizes the FDK AAC library via JNA in order to do so.
License
Important! While this library uses LGPL-3, please see the FDK AAC license for additional information regarding re/distribution and licensing limitations.
Usage
Dependencies
Artifacts are available on maven central:
Maven
<dependency>
<groupId>org.sheinbergon</groupId>
<artifactId>jna-aac-encoder</artifactId>
<version>0.1.6</version>
</dependency>
Gradle
compile 'org.sheinbergon:jna-aac-encoder:0.1.6'
Additional information
- Single artifact containing libfdk-aac shared libraries cross-compiled for:
- Linux (64-bit)
- Windows (32-bit and 64-bit)
- OSX (64-bit, compiled with Xcode 9.4.1 SDK)
- Provided fdk-aac version is 0.1.6
- Both versions 0.1.6 and 0.1.6 were tested and found to comply with this bridge.
Encoding using the JVM AudioSystem
AudioInputStream input = AudioSystem.getAudioInputStream(...);
File output = new File(...);
AudioSystem.write(input, AACFileTypes.AAC_LC, output);
Performance
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
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.
Limitations
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
Roadmap
- Upgrade to fdk-aac 2.0.x
- Improved lower-level interface (with examples).
- Support for 24 bit WAV input (via conversion).
- M4A encoding.
- AAC decoding ???