Coder Social home page Coder Social logo

sheinbergon / jna-aac-encoder Goto Github PK

View Code? Open in Web Editor NEW
27.0 4.0 5.0 50.37 MB

AAC encoding capabilities for the JVM

License: GNU Lesser General Public License v3.0

Java 100.00%
java jna aac aac-audio fdk-aac encoding java11 libfdk-aac aac-encoding-capabilities pcm

jna-aac-encoder's Introduction

jna-aac-encoder

GitHub GitHub Workflow Status GitHub release (latest by date) Maven Central Coveralls Codacy grade Liberapay

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.

Sponsorship

Enjoying my work? A show of support would be much obliged ๐Ÿ˜

ย ย 

Usage

Dependencies

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'

Additional information

  • 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 version 0.1.9 of this library

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:

alt text

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.

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

  • Improved lower-level interface (with examples).
  • Support for 24 bit WAV input (via conversion).
  • M4A encoding.
  • AAC decoding ???

jna-aac-encoder's People

Contributors

sheinbergon avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

jna-aac-encoder's Issues

An error occur on Linux playform

Execuse me, an error occured when I ran the code on Linux. Here is the information, can you help me? Thank you very much~
Ps: In fact, the code is running normally on Windows.

java.lang.IllegalArgumentException:` Structure exceeds provided memory bounds
        at com.sun.jna.Structure.ensureAllocated(Structure.java:399)
        at com.sun.jna.Structure.ensureAllocated(Structure.java:379)
        at com.sun.jna.Structure.read(Structure.java:594)
        at com.xxx.videoplayer.audio.jna.structure.AACEncoder.<init>(AACEncoder.java:44)
        at com.xxx.videoplayer.audio.jna.structure.AACEncoder.of(AACEncoder.java:38)
        at com.xxx.videoplayer.audio.jna.FdkAACLibFacade.openEncoder(FdkAACLibFacade.java:76)

Input via mic or line in through AudioSystem?

Is the input format that you get when reading input from the mic or line-in supported? I'd test myself, but I haven't gotten around to upgrade to Java 10, and this library seems to be built with Java 10 as the target. :)

What I want to do is basically read input audio and push it directly to an output stream over HTTP, but I need to convert it to a better format, such as AAC.

Support JDK1.8

Hopes to support JDK1.8. Currently, the mainstream version is still 1.8. Thank you very much

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.