Using Python to extract the first 188-byte packet from MPEG Transport Stream but do not see the sync byte

橙三吉。 提交于 2020-01-16 11:12:11

问题


I have the following code in Python:

with open("my_transport_stream_file.ts", "rb") as f:
    data = f.read(188)
    print(data)

In my mind, I believe I am extracting the first 188 bytes from the file i.e the first transport stream packet. Here's what I get:

b'G@\x00\x10\x00\x00\xb0\r\x00\x01\xc1\x00\x00\x00\n\xe0e\x8d,\xa3\xec\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff\xff'

Whilst this is SUPER exciting because I can see some data, I don't see the 0x47 sync byte that I am expecting to see.

What am I missing?


回答1:


I can see it there, It’s the very first byte.

0x47 is the ASCII code for capital letter G.

Whatever you are using to print that string, prints ASCII characters as is, but converts non printable values (values less than 0x20 and greater than 0x7e) to hex, or another escape code, like \r is 0x0d and \n is 0x0a

http://www.asciitable.com/



来源:https://stackoverflow.com/questions/58895302/using-python-to-extract-the-first-188-byte-packet-from-mpeg-transport-stream-but

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!