Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Opus audio encoding on Android

Tags:

android

opus

I want to stream voice from an Android app to a server and the requirement is to use Opus encoding. For some weird reason Android seems to only support decoding, but not encoding out of the box. All I could find with some researching are some git repos using the official native opus C/C++ code and adding it to an android project through jni. I was wondering if this is still the latest state of affairs or if there is an easier way to use it by now as all those repos are 2+ years old. Any links or tips are appreciated.

like image 773
SimonSays Avatar asked Feb 06 '26 10:02

SimonSays


1 Answers

Well, first of all, Opus library is free and open source, so you can write your own app for Andriod that will capture audio from mic, encode it with Opus codec, and send to your server.

But are you sure you want to cook it all yourself?

The solution that already exists for you is WebRTC. Chrome browser on Android fully supports WebRTC. So it can capture voice, encode it with Opus codec, and send to whatever peer you want - to another web browser (in this case you don't need anything else, except maybe some public STUN/TURN servers), or to your own server software, which you can cook using native WebRTC c++ library.

Off-the-shelf servers exist, free and commercial, that support this for you, so you don't need to cook it yourself: Red5, Unreal Media Server, Wowza. So what happens is: You publish live audio from Chrome browser on Android to that media server software; then the media server can send this stream to one/many players for playing, or to recorders for recording, or even to transcoders for transcoding, if needed.

like image 74
user1390208 Avatar answered Feb 09 '26 07:02

user1390208



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!