Skip to content

Instantly share code, notes, and snippets.

@kalidasya
Created June 25, 2019 07:56
Show Gist options
  • Save kalidasya/ef5a7349aaf53073d2e0e16d3588f751 to your computer and use it in GitHub Desktop.
Save kalidasya/ef5a7349aaf53073d2e0e16d3588f751 to your computer and use it in GitHub Desktop.
mpegts kaitai struct file it demuxes any transport stream
meta:
id: mpegts
file-extension: ts
endian: le
seq:
- id: sync_byte
contents: [0x47]
- id: transport_error_indicator
type: b1
- id: payload_unit_start_indicator
type: b1
- id: transport_priority
type: b1
- id: pid
type: b13
- id: transport_scrambling_control
type: b2
- id: adaptation_field_present
type: b1
- id: payload_present
type: b1
- id: continuity_counter
type: b4
- id: adaptation_field
type: adaptation_field_type
if: adaptation_field_present
- id: payload
size-eos: true
if: payload_present
types:
adaptation_field_type:
seq:
- id: adaptation_field_length
type: u1
- id: adaptation_field_content
type: adaptation_field_content_type
size: adaptation_field_length
if: adaptation_field_length > 0
adaptation_field_content_type:
seq:
- id: discontinuity_indicator
type: b1
- id: random_access_indicator
type: b1
- id: elementary_stream_priority_indicator
type: b1
- id: pcr_flag
type: b1
- id: opcr_flag
type: b1
- id: splicing_point_flag
type: b1
- id: transport_private_data_flag
type: b1
- id: adaptation_field_extension_flag
type: b1
- id: pcr_data
type: pcr_data_type
if: pcr_flag
- id: rest
size-eos: true
pcr_data_type:
seq:
- id: program_clock_reference_base
type: b33
- id: reserved_bits
type: b6
- id: program_clock_reference_extension
type: b9
instances:
pcr:
value: program_clock_reference_base * 300 + program_clock_reference_extension
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment