sync sample atom确定media中的关键帧。对于压缩的媒体,关键帧是一系列压缩序列的开始帧,它的解压缩是不依赖于以前的帧。后续帧的解压缩依赖于这个关键帧。
sync sample atom可以非常紧凑的标记媒体内的随机存取点。它包含一个sample序号表,表内的每一项严格按照sample的序号排列,说明了媒体中的哪一个sample是关键帧。如果此表不存在,说明每一个sample都是一个关键帧,是一个随机存取点。
分析文件地址:
http://wikil.lwwhome.cn:28080/wp-content/uploads/2020/04/0000ff_30s_11280x720.mp4
8.6.2.1
Sync Sample Box
Definition
Box Type: ‘stss’
Container: Sample Table Box (‘stbl’)
Mandatory: No
Quantity: Zero or one
This box provides a compact marking of the sync samples within the stream. The table is arranged in
strictly increasing order of sample number.
If the sync sample box is not present, every sample is a sync sample.
参考文档 ISO/IEC 14496-12
4.2 Object Structure
aligned(8) class Box (unsigned int(32) boxtype, optional unsigned int(8)[16] extended_type) { unsigned int(32) size; unsigned int(32) type = boxtype; if (size==1) { unsigned int(64) largesize; } else if (size==0) { // box extends to end of file } if (boxtype=='uuid') { unsigned int(8)[16] usertype = extended_type; } }
aligned(8) class FullBox(unsigned int(32) boxtype, unsigned int(8) v, bit(24) f) extends Box(boxtype) { unsigned int(8) version = v; bit(24) flags = f; }
aligned(8) class SyncSampleBox extends FullBox(‘stss’, version = 0, 0) { unsigned int(32) entry_count; int i; for (i=0; i < entry_count; i++) { unsigned int(32) sample_number; } }
0000f240: f8 00 00 00 00 10 70 61 73 70 00 00 00 01 00 00 ……pasp……
0000f250: 00 01 00 00 00 18 73 74 74 73 00 00 00 00 00 00 ……stts……
0000f260: 00 01 00 00 05 dc 00 00 02 00 00 00 00 28 73 74 ………….(st
0000f270: 73 73 00 00 00 00 00 00 00 06 00 00 00 01 00 00 ss…………..
0000f280: 00 fb 00 00 01 f5 00 00 02 ef 00 00 03 e9 00 00 …………….
0000f290: 04 e3 00 00 2e c8 63 74 74 73 00 00 00 00 00 00 ……ctts……
00 00 00 28 // box size
73 74 73 73 // box type stss
00 // box version 8bit
00 00 00 // box flags 24 bit
00 00 00 01 // SyncSampleBox unsigned int(32) entry_count; = 1
00 00 00 01
00 00 00 fb
00 00 01 f5
00 00 02 ef
00 00 03 e9
00 00 04 e3
// unsigned int(32) sample_number; 总即6个关键帧,可以看出来视频60s视频每隔10s一个关键帧