ts文件解析

ts file information

Importance abbreviation

(iso18318-1.pdf  page4

Ts packet 1 - pat

ts header  4 bytes

0x47 0x40 0x00 0x30:

 

0x47 : sync_byte

0x40 & 0x40 : payload_unit_start_indicator    this means payload start

((0x40 & 0x1f) << 8) | 0x00 : PID             this means PAT(PID is 0x00)

0x30 : means  “ adaptation_field_control == ‘11’ ”  and  “ continuity_counter == 0”

 

(iso18318-1.pdf  page18

 

(iso18318-1.pdf  page19

 

adaptation_field()

 

0xA6 : means  “ adaptation_field_length ==  166 bytes“ ,  that is 0x00 0xff 0xff …. 0xff 0xff

 

0x00 : means  “  == 0 ”

0xff …… 0xff : stuffing_byte

(iso18318-1.pdf  page22

 

Program association table

0x00 0x00 0xb0 0x0d 0x00 0x00 0xc1 0x00 0x00 0x00 0x01 0xe2 0x01 0xc5 0x72 0xc0 0xd3

 

0x00 : program specific information pointer, means that next byte is psi table

0x00 : table_id

0xb0: means “  section_syntax_indicator == 1“

((0xb0 & 0x0f) << 8) | 0x0d : means  “section_length == 13”

0x00 0x00 : transport_stream_id

0xc1:

0x00: section_number

0x00: last_section_number

0x00 0x01: program number

(0xe2 & 0x1f) | 0x01 :  means  “ program_map_PID == 0x201

0xc5 0x72 0xc0 0xd3 : CRC_32

(iso18318-1.pdf  page43

 

Ts packet 2 - pmt

ts header

0x47 0x42 0x01 0x30

 

0x42 & 0x40 : payload_unit_start_indicator    this means payload start

((0x42 & 0x1f) << 8) | 0x01 : PID             this means PMT(PID is 0x201,  see PAT)

0x30 : means  “ adaptation_field_control == ‘11’ ”  and  “ continuity_counter == 0”

 

adaptation_field()

0x9c : means  “ adaptation_field_length ==  156 bytes“ ,  that is 0x00 0xff 0xff …. 0xff 0xff

0x00 : means  “  == 0 ”

0xff …… 0xff : stuffing_byte

 

Program map table

0x00 0x02 0xb0 0x17 0x00 0x01 0xc1 0x00 0x00 0x03 0x01 0x00 0x00 0x0f 0xe3 0x01 0xf0 0x00 0x1b 0xe3 0x02 0xf0 0x00 0x47 0x55 0x7c 0xa0

 

0x00 : program specific information pointer, means that next byte is psi table

0x02 : table_id

0xb0 : section_syntax_indicator == 1

((0xb0 & 0x0f) << 8) | 0x17 : means  “section_length == 23”

0x00 0x01 : program_number

0xc1 : reserved, version_number, current_next_indicator

0x00 : section_number

0x00 : last_section_number

0x03 0x01 : reserved, PCR_PID

0x00 0x00 : program_info_length

0x0f : stream_type == 15, means aac

0xe3 0x01 : elementary_PID == 0x301

0xf0 0x00 : reserved, ES_info_length

0x1b : stream_type == 27, means h264

0xe3 0x02 : elementary_PID == 0x302

0xf0 0x00 : reserved, ES_info_length

0x47 0x55 0x7c 0xa0 : CRC_32

 

 

(iso18318-1.pdf  page46

 

(iso18318-1.pdf  page47

 

Ts packet 3 – video pes header

ts header

0x47 0x43 0x02 0x30

 

0x43 & 0x40 : payload_unit_start_indicator    this means payload start

((0x43 & 0x1f) << 8) | 0x02 : PID             this means PES(PID is 0x302,  see PMT)

0x30 : means  “ adaptation_field_control == ‘11’ ”  and  “ continuity_counter == 0”

adaptation_field()

0x07 : means  “ adaptation_field_length ==  7 bytes“ ,  that is 0x10 0x00 0x00 0x00 0x00 0x7e 0x00

0x10 : means  “ PCR_flag ==1”

0x00 0x00 0x00 0x00 (0x7e&0x80) : program_clock_reference_base == 0

(0x7e&0x7e) : reserved

( ((0x7e&0x01)<<8) | 0x00 ): program_clock_reference_extension == 0

 

(iso18318-1.pdf  page22

 

PES(packetized elementary stream)

(iso18318-1.pdf  page4

 

0x00 0x00 0x01 : packet_start_code_prefix

0xe0 : stream_id , means video pes (video id is 0xe0-0xef, and audio id is 0xc0-0xdf)

0x09 0x6f : PES_packet_length == 2415 bytes

(iso18318-1.pdf  page31

0x80 : means == 0

0xc0 : “ PTS_DTS_flags == ‘11’ “

0x0a : PES_header_data_length  == 10

0x31 0x00 0x01 0x00 0x01 : PTS

0x11 0x00 0x01 0x00 0x01 : DTS

(iso18318-1.pdf  page31

(iso18318-1.pdf  page32

(iso18318-1.pdf  page34

 

payload

0x00 0x00 0x00 0x01 0x09 0xf0 … 0xf3 (157 bytes)

0x00 0x00 0x00 0x01 0x09 0xf0 : h264 aud

0x00 0x00 0x00 0x01 0x61 … : h264 p frame

 

2415 bytes = 13 bytes + 157 bytes + 2208 bytes + 37 bytes

2208 bytes = 184 bytes * 12

13 bytes means

Ts packet 4

ts header

0x47 0x03 0x02 0x11

 

0x03 & 0x40 : payload_unit_start_indicator == 0    this means not payload start

((0x03 & 0x1f) << 8) | 0x02 : PID             this means PES(PID is 0x302,  see PMT)

0x11 : means  “ adaptation_field_control == ‘01’  only  has data_byte ”  and  “ continuity_counter == 1”

 

payload

0x49 – 0xf5 : payload (184 bytes)

 

 

Ts packet 5 – video pes tail

ts header

0x47 0x03 0x02 0x3d

 

0x03 & 0x40 : payload_unit_start_indicator == 0    this means not payload start

((0x03 & 0x1f) << 8) | 0x02 : PID             this means PES(PID is 0x302,  see PMT)

0x3d : means  “ adaptation_field_control == ‘11’  has adaptation_field and data_byte ”  and  “ continuity_counter == 13”

adaptation_field()

0x92 : means  “ adaptation_field_length ==  146 bytes“ ,  that is 0x00 0xff 0xff …. 0xff 0xff

0x00 : means  “  == 0 ”

0xff …… 0xff : stuffing_byte

payload

0x08 – 0xbd : payload ( 37 bytes)

 

 

Ts packet 6 – audio pes header

ts header

0x47 0x43 0x01 0x30

 

0x43 & 0x40 : payload_unit_start_indicator == 1    this means payload start

((0x43 & 0x1f) << 8) | 0x01 : PID             this means PES(PID is 0x301,  see PMT)

0x30 : means  “ adaptation_field_control == ‘11’  has adaptation_field and data_byte ”  and  “ continuity_counter == 0”

adaptation_field()

0x07 : means  “ adaptation_field_length ==  7 bytes“ ,  that is 0x10 0x00 0x00 0x00 0x00 0x7e 0x00

0x10 : means  “ PCR_flag ==1”

0x00 0x00 0x00 0x00 (0x7e&0x80) : program_clock_reference_base == 0

(0x7e&0x7e) : reserved

( ((0x7e&0x01)<<8) | 0x00 ): program_clock_reference_extension == 0

 

(iso18318-1.pdf  page22

PES(packetized elementary stream)

(iso18318-1.pdf  page4

0x00 0x00 0x01 : packet_start_code_prefix

0xc0 : stream_id , means audio pes (video id is 0xe0-0xef, and audio id is 0xc0-0xdf)

0x01 0x69 : PES_packet_length == 361 bytes

(iso18318-1.pdf  page31

0x80 : means == 0

0xc0 : “ PTS_DTS_flags == ‘11’ “

0x0a : PES_header_data_length  == 10

0x31 0x00 0x01 0x00 0x01 : PTS

0x11 0x00 0x01 0x00 0x01 : DTS

 

payload

0xff – 0xe8 : payload (157 bytes)

 

361 bytes = 13 bytes + 157 bytes + 184 bytes + 7 bytes

13 bytes means

Ts packet 7

ts header

0x47 0x03 0x01 0x11

 

0x03 & 0x40 : payload_unit_start_indicator == 0    this means not payload start

((0x03 & 0x1f) << 8) | 0x01 : PID             this means PES(PID is 0x301,  see PMT)

0x11 : means  “ adaptation_field_control == ‘01’  only  has data_byte ”  and  “ continuity_counter == 1”

 

payload

0x76 – 0x00: payload (184 bytes)

 

 

Ts packet 8 – audio pes tail

ts header

0x47 0x03 0x01 0x32

 

0x03 & 0x40 : payload_unit_start_indicator == 0    this means not payload start

((0x03 & 0x1f) << 8) | 0x01 : PID             this means PES(PID is 0x301,  see PMT)

0x32 : means  “ adaptation_field_control == ‘11’  has adaptation_field and data_byte ”  and  “ continuity_counter == 2”

adaptation_field()

0xb0 : means  “ adaptation_field_length ==  176 bytes“ ,  that is 0x00 0xff 0xff …. 0xff 0xff

0x00 : means  “  == 0 ”

0xff …… 0xff : stuffing_byte

payload

0x00 – 0x38 (7 bytes)

 

参考 : 《TS解析.doc》-- hexj

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值