An opencore amr codec JNI wrapper with explanation, And one solution for packaging amr audio files.
- opencore is the multimedia framework of android, which is a originallly contributed by PacketVideo.
- AMR is abbreviation for Adaptive Multi-Rate audio codec, which is an audio compression format optimized for speech coding.
- opencore-AMR is extracted from opencore as an codec for amr<->pcm encode/decode
- opencore-AMR-Android is a wrapper for handy usage. You can usage wrapped api in Android Application without any troubles of writing c++ wrapper or ndk mk file.
- demo project offer a solution for packaging amr audio files, in elegant code structure.
- Down load the library.
- Put jni/libs/src folder to your Android Studio or ADT application project.
- Call api like this:
AmrEncoder.init(0);
int mode = AmrEncoder.Mode.MR122.ordinal();
short[] in;//short array read from AudioRecorder, recommend length 160
byte[] out = new byte[in.length];
int byteEncoded = AmrEncoder.encode(mode, in, out);
AmrEncoder.exit();
there you go.
record->encode->package amr file->upload(not implemented)
Audio steam is packaged to file in slices, the slice last a few seconds(customizable). This policy is suitable for this scenario: client is under unstable mobile network, client records amr file, sends slice by slice, server re-assembles the slices.
If you are interested in this solution, please refer to demo
- The second parameter of AmrEncoder.encode accept an array, it's recommended to 160 in short, or 320 in byte.