Android怎么实现边采集边上传
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<length;i+=2)
{
str[strIndex++] = data[i];
}
return str;
}
该接口为获取视频预览帧的接口,传递进来的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<length;i+=2)
{
str[strIndex++] = data[i];
}
return str;
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询