### Install from Git repository Source: https://github.com/superkabuki/threefive/blob/main/README.md Clone the repository and install threefive using make. ```rebol git clone https://github.com/superkabuki/scte35.git cd threefive make install ``` -------------------------------- ### Install SRT support Source: https://github.com/superkabuki/threefive/blob/main/README.md Install the srtfu package to add SRT support to threefive. ```python python3 -m pip install srtfu ``` -------------------------------- ### Install Cython Source: https://github.com/superkabuki/threefive/blob/main/cython.md Install the Cython package using pip. This is a prerequisite for compiling Python code to C. ```bash pip install cython ``` ```bash python3 -mpip intall cython ``` -------------------------------- ### Browser Access Examples Source: https://github.com/superkabuki/threefive/blob/main/sassy.md Examples demonstrating how to access the Sassy API directly through a web browser, with and without URL-encoded JSON payloads. ```APIDOC ## Browser Access ### Description Examples of how to access the Sassy API using a web browser. This includes direct access with a pre-encoded hex value and access with a URL-encoded JSON payload. ### Examples 1. **Direct Access with Hex Value:** ``` https://iodisco.com/cb/sassy?scte35=0xfc302f00019164e7980000000506fe849f2fa80019021743554549ffffffff7fbf010866756d6174696361100100ae05fd2e ``` 2. **Access with URL-encoded JSON Payload:** ``` https://iodisco.com/cb/sassy?scte35={%22info_section%22:%20{%22table_id%22:%20%220xfc%22,%20%22section_syntax_indicator%22:%20false,%20%22private%22:%20false,%20%22sap_type%22:%20%220x01%22,%20%22sap_details%22:%20%22Type%202%20Closed%20GOP%20with%20leading%20pictures%22,%20%22section_length%22:%2037,%20%22protocol_version%22:%200,%20%22encrypted_packet%22:%20false,%20%22encryption_algorithm%22:%200,%20%22pts_adjustment%22:%2053.1,%20%22cw_index%22:%20%220x00%22,%20%22tier%22:%20%220x0fff%22,%20%22splice_command_length%22:%2020,%20%22splice_command_type%22:%205,%20%22descriptor_loop_length%22:%200,%20%22crc%22:%20%220x98d7e52c%22},%20%22command%22:%20{%22command_length%22:%2020,%20%22command_type%22:%205,%20%22name%22:%20%22Splice%20Insert%22,%20%22time_specified_flag%22:%20true,%20%22pts_time%22:%20100.0,%20%22break_auto_return%22:%20true,%20%22break_duration%22:%2060.0,%20%22splice_event_id%22:%201,%20%22splice_event_cancel_indicator%22:%20false,%20%22out_of_network_indicator%22:%20true,%20%22program_splice_flag%22:%20true,%20%22duration_flag%22:%20true,%20%22splice_immediate_flag%22:%20false,%20%22event_id_compliance_flag%22:%20true,%20%22unique_program_id%22:%201,%20%22avail_num%22:%200,%20%22avails_expected%22:%200},%20%22descriptors%22:%20[]} ``` ``` -------------------------------- ### Import Threefive Library Source: https://github.com/superkabuki/threefive/blob/main/encode.md Import the threefive library to start working with SCTE35 cues. ```python3 import threefive ``` -------------------------------- ### Add SCTE-35 parsing for MPEGTS streams to an application Source: https://github.com/superkabuki/threefive/blob/main/README.md Learn how to integrate SCTE-35 parsing for MPEGTS streams into your existing applications using the quickstream example. ```python from threefive.stream import Stream stream = Stream() with open('quickstream.py', 'rb') as f: data = f.read() stream.decode(data) ``` -------------------------------- ### Example XML Input Source: https://github.com/superkabuki/threefive/blob/main/xml.md This is an example of an SCTE-35 XML structure that can be parsed by the `threefive` tool. ```xml futronica ``` -------------------------------- ### Node Class Initialization Example Source: https://github.com/superkabuki/threefive/blob/main/node.md Demonstrates how to create an XML node using the Node class from threefive.xml. It shows initializing a 'TimeSignal' node and adding a 'SpliceTime' child node with attributes. ```python from threefive.xml import Node ts = Node('TimeSignal') st = Node('SpliceTime',attrs={'pts_time':3442857000}) ts.addchild(st) print(ts) ``` -------------------------------- ### SCTE-35 Injection with Specific Parameters Source: https://github.com/superkabuki/threefive/blob/main/scte35inject.md This example shows a typical usage scenario for scte35inject, specifying input, sidecar, SCTE-35 PID, and output files. It also lists the inserted SCTE-35 cues with their timestamps. ```bash a@fu:~/threefive$ scte35inject --input ~/mpegts2/mpegts/nmax.ts --sidecar ~/sidecar.txt --scte35_pid 777 --output injected-nmax.ts Output File: injected-nmax.ts Inserted Cue: @9187.566978, /DAgAAAAAAAAAP/wDwUAAAABf//+AA27oAABAAAAANwB3tE= Inserted Cue: @9189.201944, /DAgAAAAAAAAAP/wDwUAAAABf//+AKTLgAABAAAAANaNPVc= Inserted Cue: @9189.568978, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg= Inserted Cue: @9191.570978, /DAgAAAAAAAAAP/wDwUAAAABf//+AA27oAABAAAAANwB3tE= Inserted Cue: @9193.572978, /DAgAAAAAAAAAP/wDwUAAAABf//+AKTLgAABAAAAANaNPVc= Inserted Cue: @9195.574978, /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg= a@fu:~/threefive$ ``` -------------------------------- ### SCTE-35 Splice Insert example Source: https://github.com/superkabuki/threefive/blob/main/README.md A straightforward example demonstrating the structure and usage of an SCTE-35 Splice Insert message. ```python from threefive.splice_insert import SpliceInsert splice_insert = SpliceInsert() with open('spliceinsert.py', 'rb') as f: data = f.read() splice_insert.decode(data) ``` -------------------------------- ### Install from Git with specific Python version Source: https://github.com/superkabuki/threefive/blob/main/README.md Install threefive from the git repository using make, specifying the Python version (e.g., pypy3 or python3.14). ```rebol git clone https://github.com/superkabuki/scte35.git cd threefive make install py3=pypy3 # OR make install py3=python3.14 # works for any python in your path or use a full path if needed. ``` -------------------------------- ### Install threefive with Python 3 Source: https://github.com/superkabuki/threefive/blob/main/README.md Install the threefive package using pip for Python 3. ```rebol python3 -mpip install threefive ``` -------------------------------- ### Custom user-defined UPID handling example Source: https://github.com/superkabuki/threefive/blob/main/README.md Demonstrates how to implement custom handling logic for user-defined UPIDs within the threefive framework. ```python from threefive.upid import Upid class CustomUpid(Upid): def decode(self, data): # Custom decoding logic here pass custom_upid_handler = CustomUpid() with open('custom_upid_handling.py', 'rb') as f: data = f.read() custom_upid_handler.decode(data) ``` -------------------------------- ### Install threefive with PyPy 3 Source: https://github.com/superkabuki/threefive/blob/main/README.md Install the threefive package using pip for PyPy 3. ```rebol pypy3 -mpip install threefive ``` -------------------------------- ### Encode SCTE-35 Cue with TimeSignal from scratch Source: https://github.com/superkabuki/threefive/blob/main/README.md This example demonstrates how to construct and encode a SCTE-35 Cue object with a TimeSignal descriptor from the ground up. ```python from threefive.cue import Cue from threefive.time_signal import TimeSignal cue = Cue() time_signal = TimeSignal() # Example: Create a TimeSignal cue cue_data = cue.encode(time_signal.encode()) print(cue_data) ``` -------------------------------- ### Decode SCTE-35 using the library with less than ten lines of code Source: https://github.com/superkabuki/threefive/blob/main/README.md A concise example demonstrating how to decode SCTE-35 messages using the threefive library with minimal code. ```python from threefive.base import Base base = Base() scte35_input = "..." decoded_scte35 = base.decode(scte35_input) ``` -------------------------------- ### Use Stream.proxy() for SCTE-35 parsing and video piping Source: https://github.com/superkabuki/threefive/blob/main/README.md This example illustrates how to use the Stream.proxy() method for simultaneously parsing SCTE-35 messages and piping video streams. ```python from threefive.stream import Stream stream = Stream() with open('proxy.py', 'rb') as f: data = f.read() stream.proxy(data) ``` -------------------------------- ### Parse MPEGTS streams for SCTE-35 using Stream.decode_next() Source: https://github.com/superkabuki/threefive/blob/main/README.md This example shows how to parse MPEG Transport Streams (MPEGTS) for SCTE-35 messages using the Stream.decode_next() method. ```python from threefive.stream import Stream stream = Stream() with open('decodenext.py', 'rb') as f: data = f.read() stream.decode_next(data) ``` -------------------------------- ### Customizing Upid data output for various Upids Source: https://github.com/superkabuki/threefive/blob/main/README.md This example shows how to customize the output of Upid data for different types of Upids, providing flexibility in data handling. ```python from threefive.upid import Upid upid = Upid() with open('upid_custom_output.py', 'rb') as f: data = f.read() custom_output = upid.custom_output(data) ``` -------------------------------- ### Get Stream Start Time Source: https://github.com/superkabuki/threefive/blob/main/stream.md Retrieve the start time of the MPEG-TS stream in ticks and convert it to seconds using the as_90k method. ```python from threefive import Stream st=Stream('/home/a/video.ts') st.decode_start_time() 1182681959 # returns start time in ticks st.as_90k(st.decode_start_time()) 13141.5047 # returns start time in seconds. ``` -------------------------------- ### threefive.Cue Initialization and Usage Source: https://github.com/superkabuki/threefive/blob/main/cue-scratch.md Demonstrates how to initialize a Cue instance with Base64 data and access its attributes. ```APIDOC ## class threefive.Cue(data=None, packet_data=None) ### Description The threefive.Cue class handles parsing individual SCTE 35 Cues. A cue instance can be initialized with Base64, Bytes, Hex, Int, Json, or Xml+binary data. Instance variables can be accessed via dot notation. ### Parameters * **data** (str, bytes, dict, int, None) - The SCTE 35 data to initialize the cue with. * **packet_data** (bytes, None) - Raw packet data, if available. ### Example ```python import threefive Base64 = "/DAvAAAAAAAA///wBQb+dGKQoAAZAhdDVUVJSAAAjn+fCAgAAAAALKChijUCAKnMZ1g=" cue = threefive.Cue(Base64) cue.show() # Accessing command details print(cue.command) # Output: {'command_length': 5, 'name': 'Time Signal', 'time_specified_flag': True, 'pts_time': 21695.740089} # Accessing a specific attribute print(cue.command.pts_time) # Output: 21695.740089 ``` ``` -------------------------------- ### GET Request with URL Encoded SCTE-35 XML Source: https://github.com/superkabuki/threefive/blob/main/sassy.md This example shows how to pass SCTE-35 data formatted as XML, ensuring it is URL-encoded. Note the use of %0D%0A for newlines and other URL encoding for special characters. ```sh curl 'https://iodisco.com/cb/sassy?scte35=%0D%0A+++%0D%0A++++++%0D%0A+++<%2Fscte35%3ATimeSignal>%0D%0A+++%0D%0A+++%0D%0A++++++%0D%0A++++++fumatica<%2Fscte35%3ASegmentationUpid>%0D%0A+++<%2Fscte35%3ASegmentationDescriptor>%0D%0A<%2Fscte35%3ASpliceInfoSection>%0D%0A' ``` -------------------------------- ### Initialize and Add Cue Components Source: https://github.com/superkabuki/threefive/blob/main/lib.md Demonstrates initializing a Cue and TimeSignal, then assigning the TimeSignal to the Cue's command. The Splice Info Section is automatically added. ```python3 >>>> from threefive import Cue, TimeSignal >>>> cue=Cue() >>>> ts=TimeSignal() >>>> cue.command=ts >>>> cue {'command': {'command_length': 0, 'command_type': 6, 'name': 'Time Signal', 'bites': None, 'time_specified_flag': None, 'pts_time': None}, 'descriptors': [], 'info_section': {'table_id': None, 'section_syntax_indicator': None, 'private': None, 'sap_type': None, 'sap_details': None, 'section_length': None, 'protocol_version': None, 'encrypted_packet': None, 'encryption_algorithm': None, 'pts_adjustment': 0, 'cw_index': None, 'tier': None, 'splice_command_length': None, 'splice_command_type': None, 'descriptor_loop_length': 0, 'crc': None}, 'bites': None, 'packet_data': None, 'dash_data': None} ``` -------------------------------- ### Create and Encode AvailDescriptor Source: https://github.com/superkabuki/threefive/blob/main/xml.md Demonstrates creating an AvailDescriptor, setting its 'provider_avail_id', and encoding it. The `encode()` method provides validation and points out type errors. ```python >>>> from threefive import AvailDescriptor >>>> avd =AvailDescriptor() >>>> avd {'tag': 0, 'identifier': 'CUEI', 'name': 'Avail Descriptor', 'bites': None, 'private_data': None, 'provider_avail_id': None} >>>> avd.provider_avail_id="fumatica" ``` ```python >>>> avd.encode() provider_avail_id is fumatica, it should be type int, 32 bit(s) long. # <--- threefive points out your mistakes ``` ```python >>>> avd.provider_avail_id=1234 >>>> avd.encode() ``` -------------------------------- ### Initialize and Show a Cue Instance Source: https://github.com/superkabuki/threefive/blob/main/cue-scratch.md Demonstrates initializing a Cue instance with Base64 encoded data and displaying its contents. The Cue class can be initialized with Base64, Bytes, Hex, Int, Json, or Xml+binary data. ```rebol import threefive Base64 = "/DAvAAAAAAAA///wBQb+dGKQoAAZAhdDVUVJSAAAjn+fCAgAAAAALKChijUCAKnMZ1g=” cue = threefive.Cue(Base64) cue.show() ``` -------------------------------- ### scte35inject CLI Help Source: https://github.com/superkabuki/threefive/blob/main/scte35inject.md Displays the usage instructions and available options for the scte35inject command-line tool. ```bash a@fu:~/threefive$ scte35inject help usage: scte35inject [-h] [-i INPUT] [-o OUTPUT] [-s SIDECAR] [-p SCTE35_PID] [-t] [-v] optional arguments: -h, --help show this help message and exit -i INPUT, --input INPUT Input source, like "/home/a/vid.ts" or "udp://@235.35.3.5:3535" or "https://futzu.com/xaa.ts" [ default:sys.stdin.buffer ] -o OUTPUT, --output OUTPUT Output file [ default:sys.stdout.buffer ] -s SIDECAR, --sidecar SIDECAR Sidecar file for SCTE35 [ default:sidecar.txt ] -p SCTE35_PID, --scte35_pid SCTE35_PID Pid for SCTE-35 packets [ default:0x86 ] -t, --time_signals Flag to insert Time Signal cues at iframes. -v, --version Show version scte35inject is part of threefive ``` -------------------------------- ### Install Automatic AES decryption Source: https://github.com/superkabuki/threefive/blob/main/README.md Install the pyaes package to enable automatic AES decryption in threefive. ```python python3 -mpip install pyaes ``` -------------------------------- ### Initialize Cue and DTMF Descriptor Source: https://github.com/superkabuki/threefive/blob/main/encode.md Load an existing SCTE35 cue from Base64 and initialize an empty DTMF descriptor. The descriptor's initial state is shown. ```python import threefive Base64 = "/DAvAAAAAAAA///wFAVIAACPf+/+c2nALv4AUsz1AAAAAAAKAAhDVUVJAAABNWLbowo=" cue = threefive.Cue(Base64) dscrptr = threefive.DtmfDescriptor() dscrptr ``` -------------------------------- ### Stream.decode_start_time Source: https://github.com/superkabuki/threefive/blob/main/stream.md Retrieves the start time of the stream. Returns the start time in ticks and can be converted to seconds using the as_90k method. ```APIDOC ## Stream.decode_start_time ### Description Retrieves the start time of the stream in ticks. Can be converted to seconds using `as_90k`. ### Example ```py from threefive import Stream st=Stream('/home/a/video.ts') start_time_ticks = st.decode_start_time() start_time_seconds = st.as_90k(start_time_ticks) ``` ``` -------------------------------- ### Initialize Cue with Base64 Data Source: https://github.com/superkabuki/threefive/blob/main/cue.md Initialize a Cue instance with Base64 encoded SCTE-35 data. The class automatically detects the input format. ```python from threefive import Cue data='/DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=' cue=Cue(data) ``` -------------------------------- ### GET Request Source: https://github.com/superkabuki/threefive/blob/main/sassy.md Send SCTE-35 data via a GET request to the Sassy API and receive a JSON response. The SCTE-35 data should be URL-encoded as a query parameter. ```APIDOC ## GET /cb/sassy ### Description Accepts URL-encoded SCTE-35 data as a query parameter and returns a JSON object with parsed information. ### Method GET ### Endpoint https://iodisco.com/cb/sassy ### Parameters #### Query Parameters - **scte35** (string) - Required - The URL-encoded SCTE-35 data. ### Response #### Success Response (200) - **info_section** (object) - Contains metadata about the SCTE-35 section. - **command** (object) - Details about the splice command. - **descriptors** (array) - An array of descriptor objects. ### Response Example ```json { "info_section": { "table_id": "0xfc", "section_syntax_indicator": false, "private": false, "sap_type": "0x03", "sap_details": "No Sap Type", "section_length": 47, "protocol_version": 0, "encrypted_packet": false, "encryption_algorithm": 0, "pts_adjustment": 74825.294489, "cw_index": "0x00", "tier": "0x00", "splice_command_length": 5, "splice_command_type": 6, "descriptor_loop_length": 25, "crc": "0xae05fd2e" }, "command": { "command_length": 5, "command_type": 6, "name": "Time Signal", "time_specified_flag": true, "pts_time": 24722.499289 }, "descriptors": [ { "tag": 2, "identifier": "CUEI", "name": "Segmentation Descriptor", "descriptor_length": 23, "segmentation_event_cancel_indicator": false, "segmentation_event_id": "0xffffffff", "segmentation_event_id_compliance_indicator": true, "program_segmentation_flag": true, "segmentation_duration_flag": false, "delivery_not_restricted_flag": true, "segmentation_message": "Program Start", "segmentation_type_id": 16, "segmentation_upid_length": 8, "segmentation_upid_type": 1, "segmentation_upid_type_name": "Type 0x01 is deprecated, use MPU type 0x0C", "segmentation_upid": "fumatica", "segment_num": 1, "segments_expected": 0 } ] } ``` ``` -------------------------------- ### Initialize Cue with XML Data Source: https://github.com/superkabuki/threefive/blob/main/cue.md Initialize a Cue instance with SCTE-35 data provided as an XML string. The class automatically detects the input format. ```python from threefive import Cue data=''' ''' cue=Cue(data) ``` -------------------------------- ### Load SCTE-35 Data into Cue Instance Source: https://github.com/superkabuki/threefive/blob/main/README.md Instantiate a `Cue` object with the data read from the SCTE-35 XML file. This prepares the data for further manipulation. ```python cue = Cue(data) ``` -------------------------------- ### Initialize Cue with XML Binary Data Source: https://github.com/superkabuki/threefive/blob/main/cue.md Initialize a Cue instance with SCTE-35 data provided as an XML string containing a binary SCTE-35 payload. The class automatically detects the input format. ```python data=''' /DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg= ''' cue=Cue(data) ``` -------------------------------- ### GET /cb/sassy Source: https://github.com/superkabuki/threefive/blob/main/sassy.md Processes SCTE-35 data and returns a JSON object. The SCTE-35 data can be provided as a query parameter in different formats. ```APIDOC ## GET /cb/sassy ### Description This endpoint accepts SCTE-35 data as a query parameter and returns a JSON representation of the parsed data. It supports various encoding formats for the SCTE-35 input. ### Method GET ### Endpoint /cb/sassy ### Parameters #### Query Parameters - **scte35** (string) - Required - The SCTE-35 data. Can be provided in Hex, URL Encoded Base64, URL Encoded SCTE-35 XML, or as a large Integer string. ### Request Example (Hex encoded) ```sh curl 'https://iodisco.com/cb/sassy?scte35=0xfc302f00019164e7980000000506fe849f2fa80019021743554549ffffffff7fbf010866756d6174696361100100ae05fd2e' ``` ### Request Example (URL Encoded Base64) ```sh curl https://iodisco.com/cb/sassy?scte35=%2FDA0AAGRZOeYAAAABQb%2BhJ8vqAAeAhxDVUVJ%2F%2F%2F%2F%2F3%2F%2FAAZv8wABCGZ1bWF0aWNhEAEAiZ5ZMw%3D%3D ``` ### Request Example (URL Encoded SCTE-35 XML) ```sh curl 'https://iodisco.com/cb/sassy?scte35=%0D%0A+++%0D%0A++++++%0D%0A+++<%2Fscte35%3ATimeSignal>%0D%0A+++%0D%0A+++%0D%0A++++++%0D%0A++++++fumatica<%2Fscte35%3ASegmentationUpid>%0D%0A+++<%2Fscte35%3ASegmentationDescriptor>%0D%0A<%2Fscte35%3ASpliceInfoSection>%0D%0A' ``` ### Request Example (Integer) ```sh curl https://iodisco.com/cb/sassy?scte35=2796939353925477353583331785016283158157950476543952866345909366225726773747734084060868182760626453032945319846467331444852945475891 ``` ### Response #### Success Response (200) - **info_section** (object) - Contains information about the SCTE-35 section. - **command** (object) - Details about the splice command. - **descriptors** (array) - A list of segmentation descriptors. #### Response Example ```json { "info_section": { "table_id": "0xfc", "section_syntax_indicator": false, "private": false, "sap_type": "0x03", "sap_details": "No Sap Type", "section_length": 47, "protocol_version": 0, "encrypted_packet": false, "encryption_algorithm": 0, "pts_adjustment": 74825.294489, "cw_index": "0x00", "tier": "0x00", "splice_command_length": 5, "splice_command_type": 6, "descriptor_loop_length": 25, "crc": "0xae05fd2e" }, "command": { "command_length": 5, "command_type": 6, "name": "Time Signal", "time_specified_flag": true, "pts_time": 24722.499289 }, "descriptors": [ { "tag": 2, "identifier": "CUEI", "name": "Segmentation Descriptor", "descriptor_length": 23, "segmentation_event_cancel_indicator": false, "segmentation_event_id": "0xffffffff", "segmentation_event_id_compliance_indicator": true, "program_segmentation_flag": true, "segmentation_duration_flag": false, "delivery_not_restricted_flag": true, "segmentation_message": "Program Start", "segmentation_type_id": 16, "segmentation_upid_length": 8, "segmentation_upid_type": 1, "segmentation_upid_type_name": "Type 0x01 is deprecated, use MPU type 0x0C", "segmentation_upid": "fumatica", "segment_num": 1, "segments_expected": 0 } ] } ``` ``` -------------------------------- ### Initialize Cue with Hex Data Source: https://github.com/superkabuki/threefive/blob/main/cue.md Initialize a Cue instance with SCTE-35 data provided as a hexadecimal string. The class automatically detects the input format. ```python from threefive import Cue data='0xfc302000000000000000fff00f05000000017ffffe005265c0000100000000c38e9258' cue=Cue(data) ``` -------------------------------- ### GET Request with URL Encoded Base64 SCTE-35 Source: https://github.com/superkabuki/threefive/blob/main/sassy.md Use this format when your SCTE-35 data is URL-encoded and in Base64 format. The API will decode and process it. ```sh curl https://iodisco.com/cb/sassy?scte35=%2FDA0AAGRZOeYAAAABQb%2BhJ8vqAAeAhxDVUVJ%2F%2F%2F%2F%2F3%2F%2FAAZv8wABCGZ1bWF0aWNhEAEAiZ5ZMw%3D%3D ``` -------------------------------- ### Encode and XML representation of TimeSignal Source: https://github.com/superkabuki/threefive/blob/main/lib.md Shows how to encode a TimeSignal object directly and how to get its XML representation. This can be done independently of a Cue object. ```python3 >>>> from threefive import TimeSignal >>>> ts = TimeSignal() >>>> cue.command.time_specified_flag=True >>>> cue.command.pts_time=123.456789 >>>>ts.encode() b'\xfe\x00\xa9\x8a\xc7' >>>> ts.xml() ``` -------------------------------- ### Initializing a Cue instance Source: https://github.com/superkabuki/threefive/blob/main/lib.md A Cue instance can be initialized with SCTE-35 data in various formats including Base64, Bytes, Hex, Integer, JSON, XML, XML+bin, or a raw MPEGTS packet. ```APIDOC ## Initializing Cue with different data types ### Description Demonstrates initializing a `Cue` object with various SCTE-35 data formats. ### Method `Cue(data)` ### Parameters - **data**: The SCTE-35 data. Can be a Base64 string, bytes, hex string, integer, JSON string, XML string, XML+bin string, or raw MPEGTS packet. ### Examples #### Base64 ```python from threefive import Cue cue = Cue('/DAgAAAAAAAAAP/wDwUAAAABf//+AFJlwAABAAAAAMOOklg=') ``` #### Bytes ```python cue = Cue(b'\xfc0 \x00\x00\x00\x00\x00\x00\x00\xff\xf0\x0f\x05\x00\x00\x00\x01\x7f\xff\xfe\x00Re\xc0\x00\x01\x00\x00\x00\x00\xc3\x8e\x92X') ``` #### Int ```python cue = Cue(1913741249324105789713965315611872444571137197654250805822733947388252170837252018776) ``` #### XML ```python exemel = ''' ''' cue = Cue(exemel) ``` ``` -------------------------------- ### Convert SCTE-35 to Hex String Source: https://github.com/superkabuki/threefive/blob/main/cue.md Use `cue.hex()` to get the hexadecimal string representation of SCTE-35 data. This is useful for low-level analysis or transmission. ```python >>>> cue.hex() '0xfc302000000000000000fff00f05000000017ffffe005265c0000100000000c38e9258' ``` -------------------------------- ### Import Cue Class Source: https://github.com/superkabuki/threefive/blob/main/lib.md Import the Cue class from the threefive library to begin parsing SCTE-35 data. ```python from threefive import Cue ``` -------------------------------- ### Multicast Sender (Server) with CLI Source: https://github.com/superkabuki/threefive/blob/main/mpegts.md Use the threefive CLI to initiate a multicast sender for a video stream. ```bash threefive mcast video.ts ``` -------------------------------- ### Initialize Cue with Bytes Data Source: https://github.com/superkabuki/threefive/blob/main/cue.md Initialize a Cue instance with SCTE-35 data provided as bytes. The class automatically detects the input format. ```python from threefive import Cue data= b'\xfc0 \x00\x00\x00\x00\x00\x00\x00\xff\xf0\x0f\x05\x00\x00\x00\x01\x7f\xff\xfe\x00Re\xc0\x00\x01\x00\x00\x00\x0\ 0\xc3\x8e\x92X' cue=Cue(data) ``` -------------------------------- ### Create SCTE-35 Sidecar File with CLI Source: https://github.com/superkabuki/threefive/blob/main/mpegts.md Use the threefive CLI to generate a SCTE-35 sidecar file from an MPEGTS video. ```bash threefive sidecar video.ts ``` -------------------------------- ### Iterate MPEG-TS Packets Source: https://github.com/superkabuki/threefive/blob/main/stream.md Iterate through MPEG-TS packets quickly for custom parsing. This example shows how to parse each packet for SCTE-35 cues and write the packet to stdout. ```python # use Stream.iter_pkts if you want to iterate packets quickly and parse things your own way. from threefive import Stream for pkt in self.iter_pkts(): cue = self._parse(pkt) if cue: func(cue) sys.stdout.buffer.write(pkt) return False ``` -------------------------------- ### Initialize Cue with Integer Data Source: https://github.com/superkabuki/threefive/blob/main/cue.md Initialize a Cue instance with SCTE-35 data provided as a large integer. The class automatically detects the input format. ```python from threefive import Cue data=1913741249324105789713965315611872444571137197654250805822733947388252170837252018776 cue=Cue(data) ``` -------------------------------- ### Decode XML+Binary SCTE-35 with Python Library Source: https://github.com/superkabuki/threefive/blob/main/decode.md Instantiate a Cue object with an XML string containing a binary SCTE-35 payload. Requires importing the Cue class. ```python from threefive import Cue data = ''' /DAWAAAAAAAAAP/wBQb+AMBEoAAAALVriA== ''' cue=Cue(data) cue.show()) ``` -------------------------------- ### GET Request with Integer SCTE-35 Source: https://github.com/superkabuki/threefive/blob/main/sassy.md This method passes the SCTE-35 data as a large integer. Ensure the integer is correctly formatted and represents valid SCTE-35 data. ```sh curl https://iodisco.com/cb/sassy?scte35=2796939353925477353583331785016283158157950476543952866345909366225726773747734084060868182760626453032945319846467331444852945475891 ``` -------------------------------- ### Show MPEGTS Iframes with CLI Source: https://github.com/superkabuki/threefive/blob/main/mpegts.md Use the threefive CLI to display information about MPEGTS iframes in a video file. ```bash threefive iframes video.ts ``` -------------------------------- ### Initialize Cue with JSON Data Source: https://github.com/superkabuki/threefive/blob/main/cue.md Initialize a Cue instance with SCTE-35 data provided as a JSON string. The class automatically detects the input format. ```python from threefive import Cue data=''' { "info_section": { "table_id": "0xfc", "section_syntax_indicator": false, "private": false, "sap_type": "0x03", "sap_details": "No Sap Type", "section_length": 32, "protocol_version": 0, "encrypted_packet": false, "encryption_algorithm": 0, "pts_adjustment": 0.0, "cw_index": "0x00", "tier": "0x0fff", "splice_command_length": 15, "splice_command_type": 5, "descriptor_loop_length": 0, "crc": "0xc38e9258" }, "command": { "command_length": 15, "command_type": 5, "name": "Splice Insert", "break_auto_return": true, "break_duration": 60.0, "splice_event_id": 1, "splice_event_cancel_indicator": false, "out_of_network_indicator": true, "program_splice_flag": true, "duration_flag": true, "splice_immediate_flag": true, "event_id_compliance_flag": true, "unique_program_id": 1, "avail_num": 0, "avails_expected": 0 }, "descriptors": [] } ''' cue=Cue(data) ``` -------------------------------- ### Insert Time Signal Cues at Iframes Source: https://github.com/superkabuki/threefive/blob/main/scte35inject.md This example demonstrates how to use the -t flag to insert Time Signal cues at every iframe in the input MPEG-TS file. ```bash a@fu:~/threefive$ touch sidecar.txt @fu:~/threefive$ scte35inject -t -i ~/mpegts2/mpegts/nmax.ts -p 777 -o injected-nmax.ts Output File: injected-nmax.ts ``` -------------------------------- ### scte35bump CLI Help Source: https://github.com/superkabuki/threefive/blob/main/README.md Displays help information for the scte35bump command, which adjusts SCTE-35 PTS in an MPEGTS stream. Use this to understand available options for input, output, and time adjustments. ```bash $ scte35bump -h usage: scte35bump [-h] [-i INFILE] [-o OUTFILE] [-s SECS] options: -h, --help show this help message and exit -i INFILE, --infile INFILE Input source, stdin, file, http(s), udp, or multicast mpegts [default: sys.stdin.buffer] -o OUTFILE, --outfile OUTFILE Output file [default: sys.stdout.buffer] -s SECS, --secs SECS Adjustment to apply to SCTE-35 Cues. [default: 0.0] scte35bump is part of threefive. ``` -------------------------------- ### GET Request with Hex Encoded SCTE-35 Source: https://github.com/superkabuki/threefive/blob/main/sassy.md Pass a hex-encoded SCTE-35 string to the Sassy API to receive JSON output. Ensure your data is correctly formatted as hex. ```sh curl 'https://iodisco.com/cb/sassy?scte35=0xfc302f00019164e7980000000506fe849f2fa80019021743554549ffffffff7fbf010866756d6174696361100100ae05fd2e' ``` -------------------------------- ### Inject SCTE-35 MPEGTS Packets with CLI Source: https://github.com/superkabuki/threefive/blob/main/mpegts.md Access help information for the SuperKabuki SCTE-35 MPEGTS Packet Injection Engine via the threefive CLI. ```bash threefive inject help ``` -------------------------------- ### Create Stream instance and parse SRT stream for SCTE35 Source: https://github.com/superkabuki/threefive/blob/main/srt.md Instantiate a threefive.Stream object with an SRT URL and decode SCTE35 data from the stream. This requires the 'threefive' library to be installed. ```python from threefive import Stream strm =Stream('srt://206.125.170.41:9000') strm.decode() ``` -------------------------------- ### Decode SCTE-35 from Bytes Source: https://github.com/superkabuki/threefive/blob/main/lib.md Initialize a Cue instance by decoding SCTE-35 data provided as bytes. ```python cue =Cue(b'\xfc0 \x00\x00\x00\x00\x00\x00\x00\xff\xf0\x0f\x05\x00\x00\x00\x01\x7f\xff\xfe\x00Re\xc0\x00\x01\x00\x00\x00\x00\xc3\x8e\x92X') ``` -------------------------------- ### Sassy JSON Response Structure Source: https://github.com/superkabuki/threefive/blob/main/sassy.md This is an example of the JSON response received from the Sassy API after submitting SCTE-35 data. It details the parsed information, including command and descriptor data. ```json { "info_section": { "table_id": "0xfc", "section_syntax_indicator": false, "private": false, "sap_type": "0x03", "sap_details": "No Sap Type", "section_length": 47, "protocol_version": 0, "encrypted_packet": false, "encryption_algorithm": 0, "pts_adjustment": 74825.294489, "cw_index": "0x00", "tier": "0x00", "splice_command_length": 5, "splice_command_type": 6, "descriptor_loop_length": 25, "crc": "0xae05fd2e" }, "command": { "command_length": 5, "command_type": 6, "name": "Time Signal", "time_specified_flag": true, "pts_time": 24722.499289 }, "descriptors": [ { "tag": 2, "identifier": "CUEI", "name": "Segmentation Descriptor", "descriptor_length": 23, "segmentation_event_cancel_indicator": false, "segmentation_event_id": "0xffffffff", "segmentation_event_id_compliance_indicator": true, "program_segmentation_flag": true, "segmentation_duration_flag": false, "delivery_not_restricted_flag": true, "segmentation_message": "Program Start", "segmentation_type_id": 16, "segmentation_upid_length": 8, "segmentation_upid_type": 1, "segmentation_upid_type_name": "Type 0x01 is deprecated, use MPU type 0x0C", "segmentation_upid": "fumatica", "segment_num": 1, "segments_expected": 0 } ] } ```