mp4 文件 stco 解析

参考文档 14496-12

ISO_IEC_14496-12_2015

8.7.5
8.7.5.1
Chunk Offset Box
Definition
Box Type: ‘stco’, ‘co64’
Container: Sample Table Box (‘stbl’)
Mandatory: Yes
Quantity: Exactly one variant must be present
The chunk offset table gives the index of each chunk into the containing file. There are two variants,
permitting the use of 32‐bit or 64‐bit offsets. The latter is useful when managing very large
presentations. At most one of these variants will occur in any single instance of a sample table.
Offsets are file offsets, not the offset into any box within the file (e.g. Media Data Box). This permits
referring to media data in files without any box structure. It does also mean that care must be taken
when constructing a self‐contained ISO file with its metadata

8.7.5.2
Syntax
aligned(8) class ChunkOffsetBox
extends FullBox(‘stco’, version = 0, 0) {
    unsigned int(32) entry_count;
    for (i=1; i <= entry_count; i++) {
        unsigned int(32) chunk_offset;
    }
}
aligned(8) class ChunkLargeOffsetBox
extends FullBox(‘co64’, version = 0, 0) {
    unsigned int(32) entry_count;
    for (i=1; i <= entry_count; i++) {
        unsigned int(64) chunk_offset;
    }

0000ff_60s_1280x720

000138f0: 00 25 00 00 00 25 00 00 00 2d 00 00 00 14 73 74 .%…%…-….st
00013900: 63 6f 00 00 00 00 00 00 00 01 00 00 00 30 00 00 co………..0..
00013910: 00 62 75 64 74 61 00 00 00 5a 6d 65 74 61 00 00 .budta…Zmeta..

00 00 00 30 // unsigned int(64) chunk_offset;

00000010: 69 73 6f 6d 69 73 6f 32 61 76 63 31 6d 70 34 31 isomiso2avc1mp41
00000020: 00 00 00 08 66 72 65 65 00 00 ef d8 6d 64 61 74 ….free….mdat
00000030: 00 00 02 af 06 05 ff ff ab dc 45 e9 bd e6 d9 48 ……….E….H
00000040: b7 96 2c d8 20 d9 23 ee ef 78 32 36 34 20 2d 20 ..,. .#..x264 –
00000050: 63 6f 72 65 20 31 35 37 20 72 32 39 36 39 20 64 core 157 r2969 d
00000060: 34 30 39 39 64 64 20 2d 20 48 2e 32 36 34 2f 4d 4099dd – H.264/M
00000070: 50 45 47 2d 34 20 41 56 43 20 63 6f 64 65 63 20 PEG-4 AVC codec
00000080: 2d 20 43 6f 70 79 6c 65 66 74 20 32 30 30 33 2d – Copyleft 2003-
00000090: 32 30 31 39 20 2d 20 68 74 74 70 3a 2f 2f 77 77 2019 – http://ww
000000a0: 77 2e 76 69 64 65 6f 6c 61 6e 2e 6f 72 67 2f 78 w.videolan.org/x

从30 地址开始是chunk的开始,及ES数据开始。