据说TS包长度是188个字节,真的是这样?实验一下(原理:0x47是TS包头的第一个字节,作为同步字段):
file = open('test.ts', 'rb')
offset = 0
start = 0
section = file.read(188)
while len(section) == 188:
for c in section:
if ord(c) == 0x47:
print '(%03d,%03d)' %(start, offset),
offset = offset + 1
section = file.read(188)
offset = 0
start = start + 1
file.close()
输出的部分结果如下:
(000,000) (001,000) (002,000) (002,025) (003,000) (004,000) (005,000) (006,000) (007,000) (008,000) (008,072) (008,175) (009,000) (010,000) (010,089) (010,120) (011,000) (012,000) (013,000) (014,000) (015,000) (015,025) (016,000) (017,000) (018,000) (019,000) (020,000) (021,000) (021,011) (022,000) (023,000) (023,024) (024,000) (025,000) (026,000) (027,000) (028,0