mp4 文件 stsc 解析

参考文档 14496-12

8.7.4.1
Sample To Chunk Box
Definition
Box Type: ‘stsc’
Container: Sample Table Box (‘stbl’)
Mandatory: Yes
Quantity: Exactly one
Samples within the media data are grouped into chunks. Chunks can be of different sizes, and the
samples within a chunk can have different sizes. This table can be used to find the chunk that contains a
sample, its position, and the associated sample description.
The table is compactly coded. Each entry gives the index of the first chunk of a run of chunks with the
same characteristics. By subtracting one entry here from the previous one, you can compute how many
chunks are in this run. You can convert this to a sample count by multiplying by the appropriate
samples‐per‐chunk.

aligned(8) class SampleToChunkBox
extends FullBox(‘stsc’, version = 0, 0) {
    unsigned int(32) entry_count;
    for (i=1; i <= entry_count; i++) {
        unsigned int(32) first_chunk;
        unsigned int(32) samples_per_chunk;
        unsigned int(32) sample_description_index;
    }
}

8.7.4.3
Semantics
version is an integer that specifies the version of this box
entry_count is an integer that gives the number of entries in the following table
first_chunk is an integer that gives the index of the first chunk in this run of chunks that share
the same samples‐per‐chunk and sample‐description‐index; the index of the first chunk in a
track has the value 1 (the first_chunk field in the first record of this box has the value 1,
identifying that the first sample maps to the first chunk).
samples_per_chunk is an integer that gives the number of samples in each of these chunks
sample_description_index is an integer that gives the index of the sample entry that
describes the samples in this ch

00012150: 02 00 00 00 00 01 00 00 04 00 00 00 00 1c 73 74 …………..st
00012160: 73 63 00 00 00 00 00 00 00 01 00 00 00 01 00 00 sc…………..
00012170: 05 dc 00 00 00 01 00 00 17 84 73 74 73 7a 00 00 ……….stsz..
00012180: 00 00 00 00 00 00 00 00 05 dc 00 00 03 90 00 00 …………….

00 00 00 01 //unsigned int(32) entry_count;

00 00 00 01 //unsigned int(32) first_chunk;

00 00 05 dc //unsigned int(32) samples_per_chunk;

00 00 00 01 //unsigned int(32) sample_description_index;