All Projects → theeasiestway → android-opus-codec

theeasiestway / android-opus-codec

Licence: other
Implementation of Opus encoder and decoder in C++ for android with JNI

Programming Languages

c
50402 projects - #5 most used programming language
Makefile
30231 projects
shell
77523 projects
M4
1887 projects
assembly
5116 projects
CMake
9771 projects

Projects that are alternatives of or similar to android-opus-codec

urlpack
Pure JavaScript toolkit for data URLs (MessagePack, Base58 and Base62)
Stars: ✭ 51 (+15.91%)
Mutual labels:  encoder, decoder, codec
schifra
C++ Reed Solomon Error Correcting Library https://www.schifra.com
Stars: ✭ 28 (-36.36%)
Mutual labels:  encoder, decoder, codec
Ks265codec
ks cloud hevc(h265) encoder decoder test and description
Stars: ✭ 192 (+336.36%)
Mutual labels:  encoder, decoder, codec
keystore-go
A Go (golang) implementation of Java KeyStore encoder/decoder
Stars: ✭ 119 (+170.45%)
Mutual labels:  encoder, decoder
bytecodec
A tiny Rust framework for implementing encoders/decoders of byte-oriented protocols
Stars: ✭ 21 (-52.27%)
Mutual labels:  encoder, decoder
png pong
A pure Rust PNG image decoder and encoder based on lodepng.
Stars: ✭ 21 (-52.27%)
Mutual labels:  encoder, decoder
sms
A Go library for encoding and decoding SMSs
Stars: ✭ 37 (-15.91%)
Mutual labels:  encoder, decoder
otfed
An OpenType font format encoder & decoder written in OCaml
Stars: ✭ 15 (-65.91%)
Mutual labels:  encoder, decoder
online-ethereum-abi-encoder-decoder
A quick online tool to abi-encode and abi-decode constructor arguments used in ethereum's solidity. https://adibas03.github.io/online-ethereum-abi-encoder-decoder/
Stars: ✭ 37 (-15.91%)
Mutual labels:  encoder, decoder
Image deionising auto encoder
Noise removal from images using Convolutional autoencoder
Stars: ✭ 34 (-22.73%)
Mutual labels:  encoder, decoder
traceroute-for-android
traceroute for android
Stars: ✭ 60 (+36.36%)
Mutual labels:  jni, jni-android
fadec
A fast and lightweight decoder for x86 and x86-64 and encoder for x86-64.
Stars: ✭ 44 (+0%)
Mutual labels:  encoder, decoder
logfmt
Package logfmt marshals and unmarshals logfmt messages.
Stars: ✭ 156 (+254.55%)
Mutual labels:  encoder, decoder
png
🖼A full-featured PNG decoder and encoder.
Stars: ✭ 64 (+45.45%)
Mutual labels:  encoder, decoder
jni-bind
JNI Bind is a set of advanced syntactic sugar for writing efficient correct JNI Code in C++17 (and up).
Stars: ✭ 42 (-4.55%)
Mutual labels:  jni, jni-android
aiff
Battle tested aiff decoder/encoder
Stars: ✭ 20 (-54.55%)
Mutual labels:  encoder, decoder
ffcvt
ffmpeg convert wrapper tool
Stars: ✭ 32 (-27.27%)
Mutual labels:  encoder, codec
android-webrtc-aecm
An acoustic echo cancellation for android, based on webrtc aecm algorithms
Stars: ✭ 24 (-45.45%)
Mutual labels:  jni, jni-android
BatchEncoder
BatchEncoder is an audio files conversion software.
Stars: ✭ 145 (+229.55%)
Mutual labels:  encoder, decoder
rmarsh
Ruby Marshal 4.8 encoder/decoder in Golang. Why? Who knows.
Stars: ✭ 15 (-65.91%)
Mutual labels:  encoder, decoder

android-opus-codec

An android wrapper around libopus 1.3.1 written on C++ and Kotlin.

Supported features:

  1. Encoding PCM audio into Opus.
  2. Decoding Opus audio into PCM.
  3. Sample rate of input audio from 8000Hz to 48000Hz.
  4. Different frame sizes.
  5. Mono or stereo input audio.
  6. Input in bytes or shorts.
  7. Output in bytes or shorts.
  8. Convert from bytes to shorts and vice versa.
  9. Bitrate setting.
  10. Complexity setting.

Supported ABIs:

armeabi-v7a, arm64-v8a, x86, x86_64

How to use

Init encoder and decoder:

val SAMPLE_RATE = Constants.SampleRate._48000()       // samlpe rate of the input audio
val CHANNELS = Constants.Channels.stereo()            // type of the input audio mono or stereo 
val APPLICATION = Constants.Application.audio()       // coding mode of the encoder
var FRAME_SIZE = Constants.FrameSize._120()           // default frame size for 48000Hz

val codec = Opus()                                    // getting an instance of Codec
codec.encoderInit(SAMPLE_RATE, CHANNELS, APPLICATION) // init encoder
codec.decoderInit(SAMPLE_RATE, CHANNELS)              // init decoder

Setup the encoder:

/* this step is optional because the encoder can use default values */
val COMPLEXITY = Constants.Complexity.instance(10)    // encoder's algorithmic complexity 
val BITRATE = Constants.Bitrate.max()                 // encoder's bitrate
codec.encoderSetComplexity(COMPLEXITY)                // set the complexity
codec.encoderSetBitrate(BITRATE)                      // set the bitrate

Encoding:

val frame = ...                                       // gets a chunk of audio from some source as an array of bytes or shorts
val encoded = codec.encode(frame, FRAME_SIZE)         // encode a chunk of audio into Opus
if (encoded != null) Log.d("Opus", "encoded chunk size: ${encoded.size}")

Decoding:

val decoded = codec.decode(encoded, FRAME_SIZE)       // decode a chunk of audio into PCM
if (decoded != null) Log.d("Opus", "decoded chunk size: ${decoded.size}")

Freeing resources when closing the app:

codec.encoderRelease()
codec.decoderRelease()

Project structure

The project consists of two modules:

  • app - here you can find a sample app that demonsrates ecoding, decoding and converting procedures by capturing an audio from device's mic and play it from a loud speaker. I recommend to check this app using a headphones, otherwise there may be echo in a hight levels of volume.
  • opus - here you can find a C++ class that interacts with libopus 1.3.1 and a JNI wrapper for interacting with it from Java/Kotlin layer.

Compiled library:

  • opus.aar - it's a compiled library of opus module that mentioned above, it placed in a root directory of the project, you can easily add it to your project using gradle dependencies. First you should place opus.aar in the libs folder of your project and then add to your build.gradle:
dependencies {
    api fileTree(dir: 'libs', include: '*.jar')       // this line is necessary in order to gradle took opus.aar from "libs" dir
    api files('libs/opus.aar')                        // dependency for opus.aar library
    ...                                               // other dependencies
}
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].