private long current_pts = 0;
private long last_pts = 0;
private long start_time =0;
private long end_time = 0;
private long round_interval = 0;
private long sum_interval = 0;
private long over_count = 0;
public void decodeFrame(byte[] buf, int frameSize, long pts,int dataSize) {
synchronized (mDecoder) {
current_pts = pts;
if (start_time == 0) {
start_time = new Date().getTime();
last_pts = current_pts - 33;
}
int inputIndex = mDecoder.dequeueInputBuffer(0);
if (inputIndex >= 0) {
ByteBuffer inputBuffer;
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
inputBuffer = mInputBuffers[inputIndex];
} else {
inputBuffer = mDecoder.getInputBuffer(inputIndex);
}
《android 视频帧帧速控制》
最新推荐文章于 2023-04-14 19:55:31 发布
本文介绍了在Android中使用MediaCodec和SurfaceView处理网络视频流时,如何进行帧速控制以确保视频流畅性和及时性。算法基于固定间隔的视频帧PTS,通过调整帧解码和渲染的时机,有效控制延迟在约200ms,同时兼顾了流畅性和及时性。
摘要由CSDN通过智能技术生成