buffer is inaccessible
Opened this issue · 4 comments
直接报错 具体日志
08-01 15:43:23.530 2832-2947/zb.mediacodectest E/AndroidRuntime: FATAL EXCEPTION: LFEncode
Process: zb.mediacodectest, PID: 2832
java.lang.IllegalStateException: buffer is inaccessible
at java.nio.DirectByteBuffer.checkIsAccessible(DirectByteBuffer.java:551)
at java.nio.DirectByteBuffer.get(DirectByteBuffer.java:170)
at com.laifeng.sopcastsdk.stream.packer.AnnexbHelper.avcStartWithAnnexb(AnnexbHelper.java:191)
at com.laifeng.sopcastsdk.stream.packer.AnnexbHelper.annexbDemux(AnnexbHelper.java:147)
at com.laifeng.sopcastsdk.stream.packer.AnnexbHelper.analyseVideoData(AnnexbHelper.java:83)
at com.laifeng.sopcastsdk.stream.packer.rtmp.RtmpPacker.onVideoData(RtmpPacker.java:58)
at com.laifeng.sopcastsdk.controller.StreamController.onVideoEncode(StreamController.java:134)
at com.laifeng.sopcastsdk.screen.ScreenRecordEncoder.drainEncoder(ScreenRecordEncoder.java:119)
at com.laifeng.sopcastsdk.screen.ScreenRecordEncoder.access$000(ScreenRecordEncoder.java:32)
at com.laifeng.sopcastsdk.screen.ScreenRecordEncoder$1.run(ScreenRecordEncoder.java:77)
at android.os.Handler.handleCallback(Handler.java:739)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:135)
at android.os.HandlerThread.run(HandlerThread.java:61)
测试机型ASUS K010E 平板 系统5.0
这个是因为MediaCodec INFO_OUTPUT_BUFFERS_CHANGED 改变了,但是还是使用了以前的Buffers,之后再改吧~
嗯 确实是的 我一层一层网上找发现
int outBufferIndex = mMediaCodec.dequeueOutputBuffer(mBufferInfo, 12000);
if (outBufferIndex >= 0) {
ByteBuffer bb = mMediaCodec.getOutputBuffer(outBufferIndex);
// ByteBuffer bb = outBuffers[outBufferIndex];
if (mListener != null && !mPause) {
mListener.onVideoEncode(bb, mBufferInfo);
}
mMediaCodec.releaseOutputBuffer(outBufferIndex, false);
}。。。
这部分这么写才对 还有就是我在使用的时候发现有些延迟 有什么好的方式可以减少吗
延迟跟服务端和网络有关吧,具体如何降低需要自己想办法
rtmp sender 也就是连接服务器那部分有设置buffer之类的参数吗 我找了一下好像没找到。。