Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/210.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
在Android中使用Opus编解码器进行录制和播放_Android_Encoder_Decoder_Recorder_Opus - Fatal编程技术网

在Android中使用Opus编解码器进行录制和播放

在Android中使用Opus编解码器进行录制和播放,android,encoder,decoder,recorder,opus,Android,Encoder,Decoder,Recorder,Opus,我正在做一个需要用Opus编解码器录制和播放的项目,我搜索了很多,但找不到任何使用该解决方案的演示/示例。我发现一个演示有编码器,但找不到解码器。我只能用C找到这个编解码器的源代码,你能帮我吗 试试这个。我编译了它,但它不播放录制的声音。您好,演示是一个很好的开始,他真的很快就解决了。但是,每个包必须从编码器单独发送到解码器。而不是将所有文件保存到一个文件中,然后在不考虑包启动的情况下将它们读回。 我修改了代码以写入编码的字节数,当我解码时,我首先读取每个数据包中的字节数,然后读取有效负载。

我正在做一个需要用Opus编解码器录制和播放的项目,我搜索了很多,但找不到任何使用该解决方案的演示/示例。我发现一个演示有编码器,但找不到解码器。我只能用C找到这个编解码器的源代码,你能帮我吗

试试这个。我编译了它,但它不播放录制的声音。

您好,演示是一个很好的开始,他真的很快就解决了。但是,每个包必须从编码器单独发送到解码器。而不是将所有文件保存到一个文件中,然后在不考虑包启动的情况下将它们读回。
我修改了代码以写入编码的字节数,当我解码时,我首先读取每个数据包中的字节数,然后读取有效负载。

下面是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 );
        }
    }
        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" );
        }

下面是OpusDecoder.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 );
        }
    }
        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" );
        }

嗨,我试过了,但没用。git的发行说明提到“什么不起作用:使用opus编解码器录制和播放”,你找到什么了吗?我正在寻找相同的…如果你只需要录制,这个应用程序声称可以做到:你说的“包”是指“包”吗?我尝试了你的补丁,但仍然没有让录音和回放工作。很多只是弹出和点击,直到玩这个,它似乎记录ok,但播放不起作用。opus报告一次仅解码3个字节。