Android怎么实现边采集边上传

2026年09月26日 21:24
有1个网友回答
网友(1):

获取采集的实时图片数据

该接口为获取视频预览帧的接口,传递进来的data,默认是YUV420SP的,H264编码的源默认是YUV420的,转换一下再编码图像即可;

转换函数:

private byte[] changeYUV420SP2P(byte[]data,int length){

int width = 176;

int height = 144;

byte[] str = new byte[length];

System.arraycopy(data, 0, str, 0,width*height);

int strIndex = width*height;

for(int i = width*height+1; i < length ;i+=2)

{

str[strIndex++] = data[i];

}

for(int i = width*height;i
{

str[strIndex++] = data[i];

}

return str;

}