TS流解析

来源:互联网 发布:淘宝16年处罚规定 编辑:程序博客网 时间:2024/05/21 18:31

TS流解析

TS包结构:

1.每个section数据中都有tidsectionnumlast section numpartnumlast part num这几个信息

2.如果数据较小,256section就可以放下,那么partnumlast part num 都为0

3.如果数据较大,lastpart num就不为0,可能为1,为2。。。



如果为lastpart num1,则section中的section信息就为

tid part num last part num section num last section num

xx 0 1 0 255

xx 0 1 1 255

xx 0 1 2 255

xx 0 1 3 255

xx 0 1 4 255

xx 0 1 5 255

xx 0 1 6 255

。。。。。

。。。。。

。。。。。

xx 0 1 254 255

xx 0 1 255 255


这时候第一个part的数据就全部得到了



然后下面就是第二个part的数据了

tid part num last part num section num last section num

xx 1 1 0 200

xx 1 1 1 200

xx 1 1 2 200

xx 1 1 3 200

xx 1 1 4 200

xx 1 1 5 200

xx 1 1 6 200

。。。。。

。。。。。

。。。。。

xx 1 1 199 200

xx 1 1 200 200


这样两个part的数据都收齐了,其中第二个part还没有满,如果满的话就需要第三个part

所以,我们共需要受到的section个数为256(part1)+201(part2)


所以section的总数可以通过lastpartlast partlastsection算出来

每个section的位置是通过partnumsection num来定位的


示例:


通过filter后去掉每个section的前5个字节,即从第6个字节0x80


0个字节:TID=0x80

1-2个字节:section_length=0x07FD& 0x0FFF

4个字节:part_num=0x12

5个字节:last_part_num=0x17

6个字节:section_num=0xA4

7个字节:last_section_num=0xFF