Android-aac-enc
Extraction of Android Stagefright VO AAC encoder with a nice Java API.
In addition, includes a patched MP4Parser Java library for wrapping AAC files in an MP4 container to produce M4A audio files playable by Google Chrome and Apple QuickTime.
This project is set up as a single Eclipse project with a Main.java example activity. AAC encoding logic is found in jni/aac-enc.c, which needs to be built with the Android NDK. I used NDK r7c, but any version should work.
Why?
- smaller code footprint than FFmpeg (< 500k compared to > 2M)
- less native code to compile = less work to support new architectures
- easiest way to make an M4A file
Encoding AAC Audio in Android
File dir = getFilesDir();
String output = dir.toString() + "/audio.aac";
AACEncoder encoder = new AACEncoder();
// bitrate, channels, sample rate, bits per sample, output file name
encoder.init(64000, 1, 16000, 16, output);
// pass in some audio data
byte[] input = new byte[16000];
for(int i = 0; i < input.length; i++)
input[i] = (byte) Math.round(255 * Math.sin(i * 1.0 / 10));
// can be called as many times as you want
encoder.encode(input);
encoder.uninit();
License
This project is released under the Apache License, version 2
Download
-
Android-aac-enc-master.880ecacd2f.zip