LaiFeng-Android/SopCastComponent

点击开始,出现推流崩溃现象,部分机型

PiterPeng opened this issue · 0 comments

09-09 12:26:34.725 5169-5988/com.vp.push_rtmp E/AndroidRuntime: FATAL EXCEPTION: SopCastEncode
Process: com.vp.push_rtmp, PID: 5169
java.lang.IllegalStateException
at android.media.MediaCodec.dequeueOutputBuffer(Native Method)
at com.laifeng.sopcastsdk.video.MyRecorder.drainEncoder(MyRecorder.java:134)
at com.laifeng.sopcastsdk.video.MyRecorder.access$000(MyRecorder.java:19)
at com.laifeng.sopcastsdk.video.MyRecorder$1.run(MyRecorder.java:88)
at android.os.Handler.handleCallback(Handler.java:733)
at android.os.Handler.dispatchMessage(Handler.java:95)
at android.os.Looper.loop(Looper.java:136)
at android.os.HandlerThread.run(HandlerThread.java:61)

版本:Android 4.4.4
分辨率:720*1280
设置:cameraBuilder.setOrientation(CameraConfiguration.Orientation.PORTRAIT)
.setFacing(CameraConfiguration.Facing.BACK)
.setPreview(720, 1280)
.setFps(20);
VideoConfiguration.Builder videoBuilder = new VideoConfiguration.Builder();
videoBuilder.setSize(360, 640);
videoBuilder.setFps(20);
报错代码:
private void drainEncoder() {
ByteBuffer[] outBuffers = mMediaCodec.getOutputBuffers();
while (isStarted) {
encodeLock.lock();
if (mMediaCodec != null) {
//报错代码位置:
int outBufferIndex = mMediaCodec.dequeueOutputBuffer(mBufferInfo, 0);
if (outBufferIndex >= 0) {
ByteBuffer bb = outBuffers[outBufferIndex];
if (mListener != null) {
mListener.onVideoEncode(bb, mBufferInfo);
}
mMediaCodec.releaseOutputBuffer(outBufferIndex, false);
} else {
try {
// wait 10ms
Thread.sleep(10);
} catch (InterruptedException e) {
e.printStackTrace();
}
}
encodeLock.unlock();
} else {
encodeLock.unlock();
break;
}
}
}