Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to create SCTE messages? #7

Closed
ashiskumarsahu opened this issue Dec 14, 2022 · 2 comments
Closed

How to create SCTE messages? #7

ashiskumarsahu opened this issue Dec 14, 2022 · 2 comments

Comments

@ashiskumarsahu
Copy link

ashiskumarsahu commented Dec 14, 2022

I am new to SCTE and need help on creating SCTE messages like below. I need to understand what does these string means and how I can create and use with this package.

  • /DAxAAAAAAAAAP/wFAUAAABdf+/+zHRtOn4Ae6DOAAAAAAAMAQpDVUVJsZ8xMjEqLYemJQ==
  • /DC+AAAAAAAAAP/wBQb+W+M4YgCoAiBDVUVJCW3YD3+fARFEcmF3aW5nRlJJMTE1V0FCQzUBAQIZQ1VFSQlONI9/nwEKVEtSUjE2MDY3QREBAQIxQ1VFSQlw1HB/nwEiUENSMV8xMjEwMjExNDU2V0FCQ0dFTkVSQUxIT1NQSVRBTBABAQI2Q1VFSQlw1HF/3wAAFJlwASJQQ1IxXzEyMTAyMTE0NTZXQUJDR0VORVJBTEhPU1BJVEFMIAEBhgjtJQ==

Note: I have copied these messages from your examples.

I am able to insert them my livestream output using this package piping with ffmpeg.

Any help is highly appriciated.

Thank You

@futzu
Copy link
Owner

futzu commented Dec 14, 2022

You would think it would be straight forward, but like many things in computing,
making SCTE-35 Cues is ten times harder than it needs to be, and makes very little sense.

Complex cue messages

https://github.com/futzu/scte35-threefive/blob/master/Encoding.md

Simple Splice Insert

threefive.encode has some new encoding functions that I haven't announced yet,
but I use them a lot in my work.

a@debian:~/build/clean/scte35-threefive$ pypy3
Python 3.8.13 (7.3.9+dfsg-5, Oct 30 2022, 09:55:31)
[PyPy 7.3.9 with GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>>> from threefive import encode
>>>> help(encode)

Help on module threefive.encode in threefive:

NAME
    threefive.encode - encode.py

DESCRIPTION
    threefive.encode has helper functions for Cue encoding.

FUNCTIONS
    mk_splice_insert(event_id, pts, duration=None)
        mk_cue returns a Cue
        with a Splice Insert.
        
        splice_event_id = event_id
        
        If duration is NOT set,
            out_of_network_indicator   False
            time_specified_flag        False
            duration_flag              False
            splice_immediate_flag      True
        
        if duration IS set:
            out_of_network_indicator   True
            time_specified_flag        True
            duration_flag              True
            splice_immediate_flag      False
            break_auto_return          True
            break_duration             duration
            pts_time                   pts
 
    mk_splice_null()
        mk_splice_null returns a Cue
        with a Splice Null
    
    mk_time_signal(pts=None)
         mk_time_signal returns a Cue
         with a Time Signal
        
         if pts is NOT set:
             time_specified_flag   False
        
        if pts IS set:
             time_specified_flag   True
             pts_time              pts

FILE
    /home/a/build/clean/scte35-threefive/threefive/encode.py

   

Let's try one real quick.

a@debian:~/cuei$ pypy3
Python 3.8.13 (7.3.9+dfsg-5, Oct 30 2022, 09:55:31)
[PyPy 7.3.9 with GCC 12.2.0] on linux
Type "help", "copyright", "credits" or "license" for more information.

>>>> from threefive.encode import mk_splice_insert

>>>> evnt_id= 9

>>>> pts = 29053.123456

>>>> duration = 300

>>>> cue =mk_splice_insert(evnt_id,pts,duration)

mk_splice_insert returns an instance of threefive.Cue
which has the following methods

 |  
 |  encode(self)
 |      Cue.encode() converts SCTE35 data
 |      to a base64 encoded string.
 |  
 |  encode_as_hex(self)
 |      encode_as_hex returns self.bites as
 |      a hex string
 |  
 |  encode_as_int(self)
 |      encode_as_int returns self.bites as an int.
 |  

Use threefive.Cue's encoding methods to generate the cue messages

>>>> cue.encode()

'/DAlAAAAAAAAAP/wFAUAAAAJf+/+m9pkt/4Bm/zAAAkAAAAA5ftzmA=='

>>>> cue.encode_as_hex()

'0xfc302500000000000000fff01405000000097feffe9bda64b7fe019bfcc0000900000000e5fb7398'

>>>> cue.encode_as_int()
2104181392760166021170929920497819646350710275162000838308971042240028739408705486837725464851352

@ashiskumarsahu
Copy link
Author

Hi @futzu ,
Thanks for sharing this. It helped me a lot.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants