关于MP4 uuid box
uuid box是MP4中用户可以自定义的一种box,由header和body组成。
对于uuid header而言,包括了size、type、usertype组成,其中usertype仅在uuid box存在。size、type、usertype的大小分别为4、4、16字节。usertype来存放第三方自行定义的该uuid的类型。也就是说uuid header的大小为24个字节
public class Mp4Box {
public int headSize = 8;
public int size;
public String type;
public long largeSize;
public boolean hasSubBox = true;
public int index;
public long end;
public Mp4Box(byte[] byteBuffer, int start) {
this.index = start;
size = getSize(byteBuffer);
end = start + size;
type = getType(byteBuffer);
if (type.equals("uuid")) {
headSize += 16;
}
if (size == 1) {
largeSize = getLongFromBuffer(byteBuffer);
end = start + largeSize;
headSize += 8;
} else if (size == 0) {
//box extends to the end of file
}
}
下面是写的一个uuid的box,其中usertype为1,data中存放的数据为11。
avio_wb32(os->out, 28);//size
ffio_wfourcc(pb, "uuid");//type
avio_wb32(pb, 0x00);//usertype
avio_wb32(pb, 0x00);
avio_wb32(pb, 0x00);
avio_wb32(pb, 0x01);
avio_wb32(pb, 0x11);//data
解析出来的MP4中的uuid为下图所示