|
MediaCodec解码偶尔会异常导致视频流卡死问题
发表于 2016-10-9 16:55:04
浏览:17896
|
回复:19
打印
只看该作者
[复制链接]
楼主
使用Rk3288 pro的板子对取得的rtsp流使用MediaCodec硬解码偶尔会异常导致视频流卡死问题,求大神解决。。。
init如下:
MediaFormat mediaFormat = MediaFormat.createVideoFormat(mMime,mWidth,mHeight);
mMediaCodec = MediaCodec.createDecoderByType(mMime);
if (mMediaCodec == null) {
return false;
}
mMediaCodec.configure(mediaFormat, mSurface, null, 0);
mMediaCodec.start();
decode如下:
ByteBuffer[] inputBuffers = mMediaCodec.getInputBuffers();
// int inputBufferIndex = mMediaCodec.dequeueInputBuffer(-1);
int inputBufferIndex = mMediaCodec.dequeueInputBuffer(0);
if (inputBufferIndex >= 0) {
ByteBuffer inputBuffer = inputBuffers[inputBufferIndex];
inputBuffer.clear();
inputBuffer.put(input,0,length);
mMediaCodec.queueInputBuffer(inputBufferIndex, 0, length, 0, 0);
}
MediaCodec.BufferInfo bufferInfo = new MediaCodec.BufferInfo();
int outputBufferIndex = mMediaCodec.dequeueOutputBuffer(bufferInfo,0);
while (outputBufferIndex >= 0) {
mMediaCodec.releaseOutputBuffer(outputBufferIndex, true);
outputBufferIndex = mMediaCodec.dequeueOutputBuffer(bufferInfo, 0);
}
望大家一起讨论解决! |
|