Skip to main content

A SCTE 35 Decoder for Mpeg-TS video, and Base64 or Hex encoded messages

Project description

threefive

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.

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.

import threefive
  • mpegts files
threefive.decode('/path/to/mpegwithscte35.ts') 
  • binary files
threefive.decode('/mnt/build/file.bin')
  • base64 encoded strings
mesg='/DBhAAAAAAAA///wBQb+qM1E7QBLAhdDVUVJSAAArX+fCAgAAAAALLLXnTUCAAIXQ1VFSUg/nwgIAAAAACyy150RAAACF0NVRUlIAAAnf58ICAAAAAAsstezEAAAihiGnw=='
threefive.decode(mesg)
  • hex encoded strings
hexed='0xFC302F000000000000FFFFF014054800008F7FEFFE7369C02EFE0052CCF500000000000A0008435545490000013562DBA30A'
threefive.decode(hexed)

Output for Base64 and Hex Strings

  • SCTE 35 Info Section
  • SCTE 35 Command
  • SCTE 35 Descriptors
{ 'Info_Section': { 'crc': '0x9972e343',
                    'cw_index': '0xff',
                    'descriptor_loop_length': 50,
                    'encrypted_packet': False,
                    'encryption_algorithm': 0,
                    'private': False,
                    'protocol_version': 0,
                    'pts_adjustment': 0.0,
                    'reserved': 3,
                    'section_length': 72,
                    'section_syntax_indicator': False,
                    'splice_command_length': 5,
                    'splice_command_type': 6,
                    'table_id': '0xfc',
                    'tier': '0xfff'},
  'Splice_Command': { 'name': 'Time '
                              'Signal',
                      'pts_time': 22798.906911,
                      'time_specified_flag': True},
  'Splice_Descriptors': [ { 'archive_allowed_flag': True,
                            'delivery_not_restricted_flag': False,
                            'descriptor_length': 23,
                            'device_restrictions': '0x3',
                            'identifier': 'CUEI',
                            'name': 'Segmentation '
                                    'Descriptor',
                            'no_regional_blackout_flag': True,
                            'program_segmentation_flag': True,
                            'segment_num': 0,
                            'segmentation_duration_flag': False,
                            'segmentation_event_cancel_indicator': False,
                            'segmentation_event_id': '0x48000018',
                            'segmentation_message': 'Program '
                                                    'End',
                            'segmentation_type_id': 17,
                            'segmentation_upid_length': 8,
                            'segmentation_upid_type': 8,
                            'segments_expected': 0,
                            'splice_descriptor_tag': 2,
                            'turner_identifier': '0x2ccbc344',
                            'web_delivery_allowed_flag': True},
                          { 'archive_allowed_flag': True,
                            'delivery_not_restricted_flag': False,
                            'descriptor_length': 23,
                            'device_restrictions': '0x3',
                            'identifier': 'CUEI',
                            'name': 'Segmentation '
                                    'Descriptor',
                            'no_regional_blackout_flag': True,
                            'program_segmentation_flag': True,
                            'segment_num': 0,
                            'segmentation_duration_flag': False,
                            'segmentation_event_cancel_indicator': False,
                            'segmentation_event_id': '0x48000019',
                            'segmentation_message': 'Program '
                                                    'Start',
                            'segmentation_type_id': 16,
                            'segmentation_upid_length': 8,
                            'segmentation_upid_type': 8,
                            'segments_expected': 0,
                            'splice_descriptor_tag': 2,
                            'turner_identifier': '0x2ca4dba0',
                            'web_delivery_allowed_flag': True}]}

Output for Mpegts streams and Files

  • Packet Pid
  • Packet PTS
  • SCTE 35 Info Section
  • SCTE 35 Command
  • SCTE 35 Descriptors
{ '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.0,
                    'reserved': 3,
                    'section_length': 42,
                    'section_syntax_indicator': False,
                    'splice_command_length': 4095,
                    'splice_command_type': 5,
                    'table_id': '0xfc',
                    'tier': '0xfff'},
  'Packet': { 'pid': '0x135',
              'pts': 89977.249522},
  '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}]}

Using threefive.Splice

The threefive.Splice class can be used to decode a SCTE35 message.

threefive.Splice provides several methods to access the parsed data.

from threefive import Splice

b64 = "/DBIAAAAAAAA///wBQb+ek2ItgAyAhdDVUVJSAAAGH+fCAgAAAAALMvDRBEAAAIXQ1VFSUgAABl/nwgIAAAAACyk26AQAACZcuND"

scte35 = Splice(b64)
  • Pretty print the SCTE 35 message data.
scte35.show()
  • Return all message data in a dict.
scte35.get()
  • Pretty print SCTE 35 splice info section.
scte35.show_info_section()
  • Return SCTE 35 splice info section as a dict.
scte35.get_info_section()
  • Pretty print SCTE 35 splice command.
scte35.show_command()

{ 'name': 'Time Signal',
  'pts_time': 22798.906911,
  'time_specified_flag': True}
  • Return the SCTE 35 splice command data as a dict.
scte35.get_command()
  • Pretty print SCTE 35 splice descriptors.
scte35.show_descriptors()
  • Return a list of SCTE 35 splice descriptors as dicts.
scte35.get_descriptors()

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.97.tar.gz (11.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

threefive-2.0.97-py3-none-any.whl (12.7 kB view details)

Uploaded Python 3

File details

Details for the file threefive-2.0.97.tar.gz.

File metadata

  • Download URL: threefive-2.0.97.tar.gz
  • Upload date:
  • Size: 11.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.8.0 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for threefive-2.0.97.tar.gz
Algorithm Hash digest
SHA256 ef3e89ebc29de4547d92cea4d3ff40db9a4bbe5517a208b26930b24f0a903522
MD5 287dc6ba8eb2325d244f09927f084e73
BLAKE2b-256 3d6efc476898bec92b34e6c27cee3db34a1f10d85ac5c3c186fca84852be9542

See more details on using hashes here.

File details

Details for the file threefive-2.0.97-py3-none-any.whl.

File metadata

  • Download URL: threefive-2.0.97-py3-none-any.whl
  • Upload date:
  • Size: 12.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.4.2 requests/2.23.0 setuptools/44.0.0 requests-toolbelt/0.8.0 tqdm/4.43.0 CPython/3.8.2

File hashes

Hashes for threefive-2.0.97-py3-none-any.whl
Algorithm Hash digest
SHA256 d1aaf7dcc1aa747e9242087656345b40f5c643f556c83b148f22f632f9fcafdb
MD5 76b2cfc78ac4a43cb6aa774e14fe971a
BLAKE2b-256 3f2f9f7ae4bdead3e609f7817f0c2e37d2f50312c2f84c1b76a66581fc61d930

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page