[ Quick Start ]

June 8, 2026 ยท View on GitHub

[ Requirements ]

  • python >= 3.9 or PyPy >= 7.3.11
  • A network connection

[ Install ]

python3 -mpip install threefive
  • and / or
pypy3 -mpip install threefive
  • To add SRT support install SRTfu
python3 -m pip install srtfu
  • To add AES decryption support install pyaes
python3 -mpip install pyaes
  • Installation Complete.

[ Smoke Test ]

cli

a@fu:~$ threefive '/DAWAAAAAAAAAP/wBQb+AN3qCgAABErv4A=='
  • expected output
{
    "info_section": {
        "table_id": "0xfc",
        "section_syntax_indicator": false,
        "private": false,
        "sap_type": "0x03",
        "sap_details": "No Sap Type",
        "section_length": 22,
        "protocol_version": 0,
        "encrypted_packet": false,
        "encryption_algorithm": 0,
        "pts_adjustment": 0.0,
        "cw_index": "0x00",
        "tier": "0x0fff",
        "splice_command_length": 5,
        "splice_command_type": 6,
        "descriptor_loop_length": 0,
        "crc": "0x44aefe0"
    },
    "command": {
        "command_length": 5,
        "command_type": 6,
        "name": "Time Signal",
        "time_specified_flag": true,
        "pts_time": 161.593
    },
    "descriptors": []
}

library


from threefive import Cue
b64='/DAWAAAAAAAAAP/wBQb+AN3qCgAABErv4A=='
cue=Cue(b64)
cue.show()
  • expected output
{
    "info_section": {
        "table_id": "0xfc",
        "section_syntax_indicator": false,
        "private": false,
        "sap_type": "0x03",
        "sap_details": "No Sap Type",
        "section_length": 22,
        "protocol_version": 0,
        "encrypted_packet": false,
        "encryption_algorithm": 0,
        "pts_adjustment": 0.0,
        "cw_index": "0x00",
        "tier": "0x0fff",
        "splice_command_length": 5,
        "splice_command_type": 6,
        "descriptor_loop_length": 0,
        "crc": "0x44aefe0"
    },
    "command": {
        "command_length": 5,
        "command_type": 6,
        "name": "Time Signal",
        "time_specified_flag": true,
        "pts_time": 161.593
    },
    "descriptors": []
}

[ Everything Else ]

How to parse the various SCTE-35 data formats. This covers using both the threefive cli tool and the threefive library.

MPEGTS
  • MPEGTS streams can be Files, Http(s), Multicast,SRT, UDP Unicast, or stdin.
  • cli
threefive https://example.com/video.ts
  • wildcards work too.
threefive /mpegts/*.ts
  • lib

from threefive import Stream
stream = Stream('https://example.com/video.ts')
stream.decode()

Base64
  • cli
threefive '/DAsAAAAAyiYAP/wCgUAAAABf1+ZmQEBABECD0NVRUkAAAAAf4ABADUAAC2XQZU='
  • lib

from threefive import Cue
data = '/DAsAAAAAyiYAP/wCgUAAAABf1+ZmQEBABECD0NVRUkAAAAAf4ABADUAAC2XQZU='
cue=Cue(data)
cue.show()
Bytes
  • cli

    • Bytes don't work on the cli
  • lib


from threefive import Cue
data =  b'\xfc0\x16\x00\x00\x00\x00\x00\x00\x00\xff\xf0\x05\x06\xfe\x00\xc0D\xa0\x00\x00\x00\xb5k\x88'
cue=Cue(data)
cue.show()
Hex
  • Can be a hex literal or hex string or bytes.

  • cli

threefive  0xfc301600000000000000fff00506fed605225b0000b0b65f3b
  • lib

from threefive import Cue
data =  0xfc301600000000000000fff00506fed605225b0000b0b65f3b
cue=Cue(data)
cue.show()
Int
  • Can be a literal integer or string or bytes.

  • cli

threefive  1583008701074197245727019716796221243043855984942057168199483
  • lib

from threefive import Cue
data =  1583008701074197245727019716796221243043855984942057168199483
cue=Cue(data)
cue.show()
JSON
  • cli
    • put JSON SCTE-35 in a file and redirect it into threefive
    • cat files to threefive works too.
    • echo JSON or type JSON on the command line.
threefive  < json.json
  • lib

 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": 22,
        "protocol_version": 0,
        "encrypted_packet": false,
        "encryption_algorithm": 0,
        "pts_adjustment": 0.0,
        "cw_index": "0x00",
        "tier": "0x0fff",
        "splice_command_length": 5,
        "splice_command_type": 6,
        "descriptor_loop_length": 0,
        "crc": "0xb56b88"
    },
    "command": {
        "command_length": 5,
        "command_type": 6,
        "name": "Time Signal",
        "time_specified_flag": true,
        "pts_time": 140.005333
    },
    "descriptors": []
}
'''
cue=Cue(data)
cue.show()
Xml
  • cli

    • put xml SCTE-35 in a file and redirect it into threefive
    • cat files to threefive works too.
    • echo xml or type xml on the command line.
    threefive < xml.xml
    
  • lib

from threefive import Cue
data =  '''
<scte35:SpliceInfoSection xmlns:scte35="https://scte.org/schemas/35" 
        ptsAdjustment="0" protocolVersion="0" sapType="3" tier="4095">
   <scte35:TimeSignal>
      <scte35:SpliceTime ptsTime="12600480"/>
   </scte35:TimeSignal>
</scte35:SpliceInfoSection>
'''
cue=Cue(data)

cue.show()
Xml+binary
  • cli
    • write xml+binary to a file and redirect it to threefive
    • cat files to threefive works too.
    • echo xml+binary or type xml+binary on the command line.
threefive < xmlbin.xml
  • lib

from threefive import Cue
data = '''<scte35:Signal xmlns:scte35="https://scte.org/schemas/35">
    <scte35:Binary>/DAWAAAAAAAAAP/wBQb+AMBEoAAAALVriA==</scte35:Binary>
</scte35:Signal>
'''
cue=Cue(data)
cue.show()