网页抓取解密(EasyPlayer-RTSP-Android如何获取解码后的视频帧? )
优采云 发布时间: 2021-10-06 06:28网页抓取解密(EasyPlayer-RTSP-Android如何获取解码后的视频帧?
)
应用场景
EasyPlayer-RTSP 多年来在与 VLC 进行基准测试的过程中积累了广泛的应用场景。EasyPlayer-RTSP底层和上层均为自主研发,具有自主知识产权,可实战测试。
EasyPlayer-RTSP 播放器
EasyPlayer-RTSP播放器是一套RTSP专用播放器,包括:Windows(支持IE插件、npapi插件)、Android、iOS三个平台。它是由清溪TSINGSEE开放平台开发和维护的,与市场上的不同。作为通用播放器的一部分,EasyPlayer-RTSP系列自2014年初开发以来,已广泛应用于各行各业(尤其是安防行业)。 主要原因是EasyPlayer-RTSP更精致,更专注,并且具有非常低的延迟。非常高的RTSP协议兼容性、编码数据分析等方面,都有非常大的优势。
EasyPlayer-RTSP-Android 解码获取视频帧问问题
EasyPlayer-RTSP-Android 如何获取解码后的视频帧?
分析问题
部分客户需要获取解码后的视频帧才能实现人脸识别。
解决这个问题
视频播放的实现在PlayFragment.java中,它有一个YUVExportFragment.java的子类,实现了接口EasyPlayerClient.I420DataCallback。您可以在 onI420Data 方法中获取解码后的视频帧:
深入阅读代码,你会发现在EasyPlayerClient.java中,硬解码和软解码两种方式都将解码后的视频帧传入onI420Data:
ByteBuffer buf = mDecoder.decodeFrameYUV(frameInfo, size);
if (i420callback != null && buf != null)
i420callback.onI420Data(buf);
if (buf != null)
mDecoder.releaseBuffer(buf);
ByteBuffer outputBuffer;
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
outputBuffer = mCodec.getOutputBuffer(index);
} else {
outputBuffer = mCodec.getOutputBuffers()[index];
}
if (i420callback != null && outputBuffer != null) {
if (sliceHeight != realHeight) {
ByteBuffer tmp = ByteBuffer.allocateDirect(realWidth*realHeight*3/2);
outputBuffer.clear();
outputBuffer.limit(realWidth*realHeight);
tmp.put(outputBuffer);
outputBuffer.clear();
outputBuffer.position(realWidth * sliceHeight);
outputBuffer.limit((realWidth * sliceHeight + realWidth*realHeight /4));
tmp.put(outputBuffer);
outputBuffer.clear();
outputBuffer.position(realWidth * sliceHeight + realWidth*realHeight/4);
outputBuffer.limit((realWidth * sliceHeight + realWidth*realHeight/4 + realWidth*realHeight /4));
tmp.put(outputBuffer);
tmp.clear();
outputBuffer = tmp;
}
if (mColorFormat == COLOR_FormatYUV420SemiPlanar
|| mColorFormat == COLOR_FormatYUV420PackedSemiPlanar
|| mColorFormat == COLOR_TI_FormatYUV420PackedSemiPlanar) {
JNIUtil.yuvConvert2(outputBuffer, realWidth, realHeight, 4);
}
i420callback.onI420Data(outputBuffer);
}