I have H264 encoded video files received from an Android Android camera and I want to receive frames and store them as files one at a time. The problem is, how can I distinguish between frames, is there a special tag to separate frames? Now I have this function, which can get the frame length by bytes, maybe this helps to understand my questions, thanks :)
public static int h263Parse(byte[]buf, int offset, int nLen)
{
int vop_found, i;
vop_found = 0;
i=0;
if(vop_found == 0)
{
for(i=(offset + 3); i<(offset+nLen); i++)
{
if(buf[i-3] == 0x00)
if(buf[i-2] == 0x00)
if((buf[i-1]&0xff) < 0x84)
if((buf[i-1]&0xff) >= 0x80)
{
i++;
vop_found=1;
break;
}
}
}
if(vop_found == 1)
{
for(; i<(offset+nLen); i++)
{
if(buf[i-3] == 0x00)
if(buf[i-2] == 0x00)
if((buf[i-1]&0xff) < 0x84)
if((buf[i-1]&0xff) >= 0x80)
{
return i-3-offset;
}
}
}
return -1;
}
Dalen source
share