I'm working on a project that need to record and playback with Opus Codec, I search a lot but I can't find any demo/example using that solution. I find a demo having encoder but can't find the decoder. I only find the source code of this codec using C, can you help me?
Record and playback with Opus Codec in Android
Did you find anything? I'm looking for the same... –
Adiell
If you just need to record, this app claims to do it: play.google.com/store/apps/… –
Meimeibers
Hello that demo is a good place to start, he was realy close to solving it. However each package must be sent separetly from the encoder to the decoder. Instead of saving all to a file and then read them back without any regard of package start.
I modified the code to also write the number of encoded bytes and when I decode, I read first the number of bytes in each packet and then the payload.
Here is the modified code in OpusEncoder.java
public void write( short[] buffer ) throws IOException
{
byte[] encodedBuffer = new byte[buffer.length];
int lenEncodedBytes = this.nativeEncodeBytes( buffer , encodedBuffer);
Log.i(TAG,"encoded "+lenEncodedBytes+" bytes");
if (lenEncodedBytes > 0)
{
this.out.write(lenEncodedBytes);
this.out.write( encodedBuffer, 0, lenEncodedBytes );
}
else
{
Log.e( TAG, "Error during Encoding. Error Code: " + lenEncodedBytes);
throw new IOException( "Error during Encoding. Error Code: " + lenEncodedBytes );
}
}
Here is the modified code in OpusDecoder.java
byte[] encodedBuffer;
int bytesEncoded=this.in.read();
int bytesDecoded=0;
Log.d( TAG, bytesEncoded + " bytes read from input stream" );
if ( bytesEncoded >= 0 )
{
encodedBuffer=new byte[bytesEncoded];
int bytesRead = this.in.read( encodedBuffer );
bytesDecoded = nativeDecodeBytes( encodedBuffer , buffer);
Log.d( TAG, bytesEncoded + " bytes decoded" );
}
by "package" do you mean "packet"? i tried your patch but still didn't get the record and playback to work. lots of just pops and clicks –
Episiotomy
still playing around with this, it appears to record ok, but the playback doesn't work. opus is reporting only decoding 3 bytes at a time. –
Episiotomy
Try this GitHub demo. I compiled it but, it doesn't play the recorded sound.
Hi, I tried it, but it not worked.and the release note in that git mentioned "What does not work: Recording and playing using the opus codec" –
Anselma
© 2022 - 2024 — McMap. All rights reserved.