futzu / SCTE-35_HLS_x9k3

HLS and SCTE-35 x9k3 is a HLS Segmenter with SCTE 35, and Live Streaming from Non-Live Soures and Looping.
67 stars 17 forks source link

x9k3 not show CUE-OUT=YES/CUE-IN=YES messages. #2

Closed sergeyshulga closed 2 years ago

sergeyshulga commented 2 years ago

Hello. x9k3 not show CUE-OUT=YES/CUE-IN=YES messages, only binary decoded SCTE messages. In version 1.21 we get string like that -

EXT-X-SCTE35:CUE="/DAgAAAAAAAAAP/wDwUAAAAAf/9+AAAAAAAAAAAAAD4xJP8=",CUE-OUT=YES

In version 1.23 and latest string always show as

EXT-X-SCTE35:CUE="/DAgAAAAAAAAAP/wDwUAAAAAf/9+AAAAAAAAAAAAAD4xJP8="

I think its related to discontinuity control in your script.

futzu commented 2 years ago

index.m3u8.txt I just made that 10 seconds ago. Maybe its because you're doing a splice immediate. Send me a link to a video I can try it out and see whats happening.

futzu commented 2 years ago

I think I got it. Run pip.

python3 -mpip install --upgrade x9k3

version is 0.1.37

sergeyshulga commented 2 years ago

Yes, i use splice immediate commands. Now x9k3 v0.1.37 working fine. Thank you!

futzu commented 2 years ago

Hey man did you see the fake live loop stuff?

ffplay https://slo.me/index.m3u8
khoand58 commented 1 year ago

@futzu hey man, How to add ,CUE-OUT=YES/ CUE-IN=YES, from -s sidecart.txt ?

futzu commented 1 year ago

Is it a splice insert ?

futzu commented 1 year ago

I don't know if you saw this https://github.com/futzu/x9k3#faq

futzu commented 1 year ago

you can use anything to trigger a CUE-OUT or CUE-IN, just override the static methods with functions that return a boolean

I called this file x9.py

x9.py

import x9k3

def mk_hex_cue_tag(cue):
    """
    mk_cue_tag
    """
    if cue:
        # make the cue a hex string
        return f'#EXT-X-SCTE35:CUE="{cue.encode_as_hex()}"'
    return "# No Cue"

def my_cue_out(cue):
    """

    Returns True for a cue_out event.
    """
    # if time signal
    if cue.command.command_type == 6:
        #  if first descriptor is a  segmentation descriptor
        if cue.descriptors[0].tag ==2:
            # if  segmentation_message is "Break Start"
            if cue.descriptors[0].segmentation_message== "Break Start": 
                return True
    return False

def my_cue_in(cue):
    """
    is_cue_in checks a Cue instance
    to see if it is a cue_in event.
    Returns True for a cue_in event.
    """
    # if time signal
    if cue.command.command_type == 6:
    #  if first descriptor is a  segmentation descriptor
        if cue.descriptors[0].tag ==2:
                # if  segmentation_message is "Break End"
            if cue.descriptors[0].segmentation_message=="Break End":
                return True
    return False

if __name__ == '__main__':
    x9 = x9k3.X9K3()
    x9.scte35.is_cue_out = my_cue_out
    x9.scte35.is_cue_in = my_cue_in
    x9.mk_cue_tag = mk_hex_cue_tag
    x9.decode()

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" -o OUTPUT_DIR, --output_dir OUTPUT_DIR Directory for segments and index.m3u8 ( created if it does not exist ) -s SIDECAR, --sidecar SIDECAR Sidecar file of scte35 cues. each line contains PTS, Cue -t TIME, --time TIME Segment time in seconds ( default is 2) -l, --live Flag for a live event ( enables sliding window m3u8 ) -d, --delete delete segments ( enables --live ) -r, --replay Flag for replay (looping) ( enables --live and --delete ) -v, --version Show version

futzu commented 1 year ago

here's an easier way,


import x9k3

def mk_cue_tag(cue):
    """
    mk_cue_tag with CUE-IN / CUE-OUT
    using the  out_of_network_indicator from Splice Inserts.
    """
    if cue:
        if cue.command.out_of_network_indicator:
            return f'#EXT-X-SCTE35:CUE="{cue.encode()}" ,CUE-OUT=YES'
        return f'#EXT-X-SCTE35:CUE="{cue.encode()}" ,CUE-IN=YES'

    return "# No Cue"

if __name__ == '__main__':
    x9 = x9k3.X9K3()
    x9.mk_cue_tag = mk_hex_cue_tag
    x9.decode()
futzu commented 1 year ago

When I take the time to help you, I expect a reply. Don't be a dick.

sergeyshulga commented 1 year ago

Sorry for silence. I'm traveling last 2 weeks and cannot check your x9.py example. Its working Ok for me. I can customize messages in x9k3 or x9.py files. Reason why i need it - make M3U compatible with Amazon MediaTailor - https://docs.aws.amazon.com/mediatailor/latest/ug/hls-ad-markers.html Currently its seems working ok when i store only hex-coded mesages in m3u.

EXT-X-SPLICEPOINT-SCTE35:/DA9AAAAAAAAAP/wBQb+uYbZqwAnAiVDVUVJAAAKqX//AAEjW4AMEU1EU05CMDAxMTMyMjE5M19ONAAAmXz5JA==

...

EXT-X-SPLICEPOINT-SCTE35:/DA4AAAAAAAAAP/wBQb+tTeaawAiAiBDVUVJAAAKqH+/DBFNRFNOQjAwMTEzMjIxOTJfTjUAAIiGK1s=

But before i try to make it working with only EXT-X-CUE-OUT and EXT-X-CUE-IN commands, without hex or anything else..

Also Amazon need manifest (master) playlist, not only media playlist (( https://docs.aws.amazon.com/mediatailor/latest/ug/manifest-hls-example.html