A SCTE 35 Decoder for Mpeg-ts and Hex or Base64 messages
Project description
threefive
I welcome all feedback and ideas.
SCTE35 Decoder
- Parse SCTE 35 messages from Mpeg Transport Streams and Binary files.
- Parse SCTE 35 messages encoded in Base64, Binary, or Hex.
Fast Start Directions.
2019 Specification
Splice Commands
- Splice Null
- Splice Schedule (lightly tested)
- Splice Insert
- Time Signal
- Bandwidth Reservation (lightly tested)
Splice Descriptors
- DTMF Descriptor
- Segmentation Descriptor
- Segmentation UPID (partially implemented)
- Segmentation Types and Messages
- Time Descriptor
- Audio Descriptor (lightly tested)
Dependencies
- Python 3
- bitn
Install
pip install threefive
Collecting threefive
Downloading threefive-2.0.69-py3-none-any.whl (12 kB)
Collecting bitn>=0.0.21
Downloading bitn-0.0.21-py3-none-any.whl (3.0 kB)
Installing collected packages: bitn, threefive
Successfully installed bitn-0.0.21 threefive-2.0.69
Using threefive
Call threefive.decode.
- mpegts files
- binary files
- base64 encoded strings
- hex encoded strings
- binary byte strings
Parse Mpegts Files
>>> import threefive
>>> threefive.decode('/path/to/mpegwithscte35.ts')
Parse Binary Encoded Messages From a File
>>> import threefive
>>> stuff=threefive.decode('/mnt/build/file.bin')
Parse Base64 Encoded Messages
>>> import threefive
>>> mesg='/DBhAAAAAAAA///wBQb+qM1E7QBLAhdDVUVJSAAArX+fCAgAAAAALLLXnTUCAAIXQ1VFSUg/nwgIAAAAACyy150RAAACF0NVRUlIAAAnf58ICAAAAAAsstezEAAAihiGnw=='
>>> t=threefive.decode(mesg)
Parse Hex Encoded Messages
>>> import threefive
>>> u=threefive.decode('0xFC302F000000000000FFFFF014054800008F7FEFFE7369C02EFE0052CCF500000000000A0008435545490000013562DBA30A')
Parse Binary Byte String Messages
>>> import threefive
>>> f=open('/mnt/build/file.bin','rb').read()
>>> scte35=threefive.decode(f)
Output for Base64 and Hex Strings
- SCTE 35 Info Section
- SCTE 35 Command
- SCTE 35 Descriptors
{ 'SCTE35': { 'Info_Section': { 'crc': '0x62dba30a',
'cw_index': '0xff',
'descriptor_loop_length': 10,
'encrypted_packet': False,
'encryption_algorithm': 0,
'private': False,
'protocol_version': 0,
'pts_adjustment': '0.000000',
'reserved': 3,
'section_length': 47,
'section_syntax_indicator': False,
'splice_command_length': 20,
'splice_command_type': 5,
'table_id': '0xfc',
'tier': '0xfff'},
'Splice_Command': { 'avail_expected': 0,
'avail_num': 0,
'break_auto_return': True,
'break_duration': '60.293567',
'duration_flag': True,
'name': 'Splice '
'Insert',
'out_of_network_indicator': True,
'program_splice_flag': True,
'pts_time': '21514.559089',
'splice_event_cancel_indicator': False,
'splice_event_id': 1207959695,
'splice_immediate_flag': False,
'time_specified_flag': True,
'unique_program_id': 0},
'Splice_Descriptors': [ { 'descriptor_length': 8,
'identifier': 'CUEI',
'name': 'Avail '
'Descriptor',
'provider_avail_id': 309,
'splice_descriptor_tag': 0}]}}
Output for Mpegts streams and Files
- Packet Pid
- Packet PTS
- SCTE 35 Info Section
- SCTE 35 Command
- SCTE 35 Descriptors
{ 'Packet': { 'pid': '0x135',
'pts': '89977.249522'},
'SCTE35': { 'Info_Section': { 'crc': '0x6e33321e',
'cw_index': '0x0',
'descriptor_loop_length': 10,
'encrypted_packet': False,
'encryption_algorithm': 0,
'private': False,
'protocol_version': 0,
'pts_adjustment': '0.000000',
'reserved': 3,
'section_length': 42,
'section_syntax_indicator': False,
'splice_command_length': 4095,
'splice_command_type': 5,
'table_id': '0xfc',
'tier': '0xfff'},
'Splice_Command': { 'avail_expected': 0,
'avail_num': 0,
'duration_flag': False,
'name': 'Splice '
'Insert',
'out_of_network_indicator': False,
'program_splice_flag': True,
'pts_time': '89984.161689',
'splice_event_cancel_indicator': False,
'splice_event_id': 662,
'splice_immediate_flag': False,
'time_specified_flag': True,
'unique_program_id': 1},
'Splice_Descriptors': [ { 'descriptor_length': 8,
'identifier': 'CUEI',
'name': 'Avail '
'Descriptor',
'provider_avail_id': 0,
'splice_descriptor_tag': 0}]}}
threefive.Splice.show()
Shows all data
>>> import threefive
>>> mesg='/DBIAAAAAAAA///wBQb+ky44CwAyAhdDVUVJSAAACn+fCAgAAAAALKCh4xgAAAIX
Q1VFSUgAAAl/nwgIAAAAACygoYoRAAC0IX6w')
>>> fu=threefive.Splice(mesg)
>>> fu.show()
Read individual values
>>> import threefive
>>> mesg='/DAvAAAAAAAA///wFAVIAACPf+/+c2nALv4AUsz1AAAAAAAKAAhDVUVJAAABNWLbowo='
>>> scte_data=threefive.Splice(mesg)
>>> scte_data.command.name
'Splice Insert'
>>> scte_data.command.splice_immediate_flag
False
>>> scte_data.command.pts_time
'21514.559089'
>>> scte_data.command.break_duration
'60.293567'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
threefive-2.0.73.tar.gz
(10.5 kB
view hashes)
Built Distribution
threefive-2.0.73-py3-none-any.whl
(11.4 kB
view hashes)
Close
Hashes for threefive-2.0.73-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | df97b21bcd9bda0ff706019f0a1327fa4610a8ae95b3e1b3961267bf36051706 |
|
MD5 | f91bcd1eba7557607233c778cde4e885 |
|
BLAKE2b-256 | 522942053bf845fe93dd258ad53f2fa2e3eb4ad339ed615060e060f8cd4b7cf0 |