Giter VIP home page Giter VIP logo

Comments (20)

futzu avatar futzu commented on August 15, 2024

It's not turned on, because a lot of stuff doesn't respect auto-return in SCTE-35 Cues, I need to look at the code and then I tell you where it should be called.

x9k3 will also read cues from a sidecar file, you don't have to inject them.
threefive can generate cues

    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
 
   
a@debian:~/cuei$ pypy3

>>>> from threefive.encode import mk_splice_insert

>>>> evnt_id= 9

>>>> pts = 29053.123456

>>>> duration = 300

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

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

>>>> cue.encode_as_hex()

'0xfc302500000000000000fff01405000000097feffe9bda64b7fe019bfcc0000900000000e5fb7398'

>>>> cue.encode_as_int()
2104181392760166021170929920497819646350710275162000838308971042240028739408705486837725464851352

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024
python3 -m pip install --upgrade x9k3 threefive new_reader

and auto return should work.

from scte-35_hls_x9k3.

fraroas avatar fraroas commented on August 15, 2024

Thanks a lot for this quick fix! Great!

However, there is a new issue with "immediate" splice requests, when no pts is given:
File "x9k3/x9k3.py", line 534, in _auto_return
pts = cmd.pts_time + cmd.break_duration
TypeError: unsupported operand type(s) for +: 'NoneType' and 'float'

I guess the pts_default should be set to current pts (or of the next packet) instead to None if there is no pts_time given in the section.

tsduck splice xml looks like above, which is
<splice_insert splice_event_id="0x00000001" out_of_network="true" splice_immediate="true" unique_program_id="0x0001">
<break_duration auto_return="true" duration="2,150,000"/>
</splice_insert>

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

in line 534 change cmd.pts_time to self.scte35.cue_time

pts = self.scte35.cue_time + cmd.break_duration

see if that works

from scte-35_hls_x9k3.

fraroas avatar fraroas commented on August 15, 2024

no, the self.scte35.cue_time is still empty (None). I'll do more debugging tomorrow.
In encode.py, line 98 I had to cast the pts to string. This correctly prints out the pts when the slice event was received.

/tmp/seg0.ts start: 32514.760000 duration: 3.600000 stream diff: 0.069976
/tmp/seg1.ts start: 32518.360000 duration: 3.840000 stream diff: 0.067004

  • spliceinject: received message, 465 bytes, from 127.0.0.1:51974
  • spliceinject: enqueuing SpliceInsert out @0xFFFFFFFFFFFFFFFF, immediate
  • spliceinject: injecting SpliceInsert out @0xFFFFFFFFFFFFFFFF, immediate, current PTS: 0x0AE77DF90
    mk splice insert with pts: 32546.088889000002

(*spliceinject is from tsduck, piping to | python3 x9k3.py -d -o /tmp -t 2 -T x_cue
The complete command line is
tsp -v --add-input-stuffing 1/20 -I ip 224.0.0.1:6600 -P pmt --service 0x1 --add-programinfo-id 0x43554549 --add-pid 600/0x86 -P spliceinject --udp 4444 --service 0x1 -P filter --negate --pid 0x1FFF | python3 x9k3.py -d -o /tmp -t 2 -T x_cue
And receiving a regular TS via multicast. Inject the XML by cat splice.xml > /dev/udp/127.0.0.1/4444

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

That command is complex and not needed.

x9k3 has multicast support.

x9k3 can read cues from a sidecar file.

grab the latest threefive and x9k3

pypy3 -mpip install --upgrade threefive x9k3

Generate a Spice Insert with splice_immediate_flag and break auto return

from threefive.encode import mk_splice_insert

evnt_id= 9
pts =None         # None for Splice Immediate
duration = 300
insert_pts = 1234.567890  

cue =mk_splice_insert(evnt_id,pts,duration)
with open("sidecar.txt, "a") as scf:
     scf.write(f"{insert_pts},{cue.encode()} ")
  • Run x9k3
x9k3 -i udp://@224.0.0.1:6600 -s sidecar.txt -T x_cue -o  /tmp

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

Did it work for you?

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024
  • I created a cue using threefive.encode with a break auto return and splice immediate .
  • I wrote the cue and the insert time (113.456789) to sidecar.txt.
~/build/clean/x9k3$ 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

>>>> evt_id, pts, dur = 9, None, 13.4

>>>> cue = mk_splice_insert(evt_id,pts,dur).encode()

>>>> with open("sidecar.txt","w") as sidecar:
....     sidecar.write(f'113.456789,{cue}')
....     
59
>>>>

I ran this x9k3 command

a@debian:~/build/clean/x9k3$ x9k3 -i la-slim.ts  -s sidecar.txt

Loading from Sidecar File
 113.456789  /DAhAAAAAAAAAP/wEAUAAAAJf78A/gASZvAACQAAAACokv3z
./seg0.ts	start: 102.506478	duration: 2.126855
./seg1.ts	start: 104.633333	duration: 2.000000
./seg2.ts	start: 106.633333	duration: 2.000000
./seg3.ts	start: 108.633333	duration: 2.000000
./seg4.ts	start: 110.633333	duration: 2.000000

Loading from Sidecar File
 113.456789  /DAhAAAAAAAAAP/wEAUAAAAJf78A/gASZvAACQAAAACokv3z

Loading from Sidecar File
 113.456789  /DAhAAAAAAAAAP/wEAUAAAAJf78A/gASZvAACQAAAACokv3z
#EXT-X-CUE-OUT:13.4
./seg5.ts	start: 112.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:2.000/13.4
./seg6.ts	start: 114.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:4.000/13.4
./seg7.ts	start: 116.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:6.000/13.4
./seg8.ts	start: 118.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:8.000/13.4
./seg9.ts	start: 120.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:10.000/13.4
./seg10.ts	start: 122.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:12.000/13.4
./seg11.ts	start: 124.633333	duration: 2.000000
#EXT-X-CUE-IN
./seg12.ts	start: 126.633333	duration: 2.000000
./seg13.ts	start: 128.633333	duration: 2.000000
./seg14.ts	start: 130.633333	duration: 2.000000
./seg15.ts	start: 132.633333	duration: 2.033334
./seg16.ts	start: 134.666667	duration: 2.000000
./seg17.ts	start: 136.666667	duration: 2.000000
./seg18.ts	start: 138.666667	duration: 2.000000
./seg19.ts	start: 140.666667	duration: 2.000000
./seg20.ts	start: 142.666667	duration: 2.000000
./seg21.ts	start: 144.666667	duration: 2.000000
./seg22.ts	start: 146.666667	duration: 2.000000
./seg23.ts	start: 148.666667	duration: 2.000000
./seg24.ts	start: 150.666667	duration: 2.000000

from scte-35_hls_x9k3.

fraroas avatar fraroas commented on August 15, 2024

I can confirm that auto_return works for "immediate" cues, injected by sidecar created by threefive.encode.
Having no sidecar but using a recorded ts with markers leads to
File "/home/frank/src/x9k3/x9k3.py", line 540, in _auto_return
if [pts, cue] not in self.sidecar:

I'll open another issue regarding the alignment of HLS ad markers to GOP boundaries.

from scte-35_hls_x9k3.

fraroas avatar fraroas commented on August 15, 2024

changing x9k3.py line 540 to
if self.sidecar and [pts, cue] not in self.sidecar:
fixes the error above, but then the auto_return still doesn't work:

/tmp/seg155.ts start: 19309.086222 duration: 4.040000
pts for cue in: 19407.326222
/tmp/seg156.ts start: 19313.126222 duration: 4.000000
#EXT-X-CUE-OUT:86.2
/tmp/seg157.ts start: 19317.126222 duration: 4.000000
#EXT-X-CUE-OUT-CONT:4.000/86.2
/tmp/seg158.ts start: 19321.126222 duration: 4.080000
#EXT-X-CUE-OUT-CONT:8.080/86.2
/tmp/seg159.ts start: 19325.206222 duration: 4.080000
...
#EXT-X-CUE-OUT-CONT:84.520/86.2
/tmp/seg178.ts start: 19401.646222 duration: 4.000000
#EXT-X-CUE-OUT-CONT:88.520/86.2
/tmp/seg179.ts start: 19405.646222 duration: 4.040000
#EXT-X-CUE-OUT-CONT:92.560/86.2
/tmp/seg180.ts start: 19409.686222 duration: 4.000000
#EXT-X-CUE-OUT-CONT:96.560/86.2

from scte-35_hls_x9k3.

fraroas avatar fraroas commented on August 15, 2024

ah, I see. You're adding the automatically created cue-in to the sidecar data. But if there is no sidecar, the auto-return won't work. We should store the cue-in locally as the next cue msg.

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

You are confusing the sidecar file with the sidecar object, two different things.
The sidecar file is read and loaded into the sidecar object.

I am going to pull out the auto return stuff, it is causing too many problems.
I am just cant support auto return right now.
I am way too busy to spend any more time on this right now.
If you get how you want it , send me a patch and I will apply it.

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

I am in the middle of re-writing x9k3, and I need to finish that first, and then add auto-return

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

Its not line 540, its line 539 that needs to be changed to

               if [pts, b64] not in self.sidecar:     # line 539
                    self.sidecar.append([pts, b64])  # line 540

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

pip up

pypy3 -mpip install --upgrade x9k3


work perfectly for me:

a@debian:~/build/clean/x9k3$ x9k3 -i ../la-slim.ts  -s sidecar.txt
./seg0.ts	start: 102.506478	duration: 2.126855
./seg1.ts	start: 104.633333	duration: 2.000000
./seg2.ts	start: 106.633333	duration: 2.000000
./seg3.ts	start: 108.633333	duration: 2.000000
./seg4.ts	start: 110.633333	duration: 2.000000
./seg5.ts	start: 112.633333	duration: 2.000000
#EXT-X-CUE-OUT:13.4
./seg6.ts	start: 114.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:2.000/13.4
./seg7.ts	start: 116.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:4.000/13.4
./seg8.ts	start: 118.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:6.000/13.4
./seg9.ts	start: 120.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:8.000/13.4
./seg10.ts	start: 122.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:10.000/13.4
./seg11.ts	start: 124.633333	duration: 2.000000
#EXT-X-CUE-OUT-CONT:12.000/13.4
./seg12.ts	start: 126.633333	duration: 2.000000
#EXT-X-CUE-IN
./seg13.ts	start: 128.633333	duration: 2.000000
./seg14.ts	start: 130.633333	duration: 2.000000
./seg15.ts	start: 132.633333	duration: 2.033334
./seg16.ts	start: 134.666667	duration: 2.000000
./seg17.ts	start: 136.666667	duration: 2.000000
./seg18.ts	start: 138.666667	duration: 2.000000
./seg19.ts	start: 140.666667	duration: 2.000000
./seg20.ts	start: 142.666667	duration: 2.000000
./seg21.ts	start: 144.666667	duration: 2.000000
./seg22.ts	start: 146.666667	duration: 2.000000
./seg23.ts	start: 148.666667	duration: 2.000000
./seg24.ts	start: 150.666667	duration: 2.000000
a@debian:~/build/clean/x9k3$ 

If it doesnt work for you, it will have to wait until I finish my big update.

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

make sure your cues are on iframes.

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

I have a tool for that as well called iframes

a@debian:~/build/clean/x9k3$ iframes ../la-slim.ts 
102.966667
103.3
103.633333
103.966667
104.3
104.633333
104.966667
105.3
105.633333
105.966667
106.3
106.633333
106.966667
107.3
107.633333
107.966667
108.3
108.633333
108.966667
109.3
109.633333
109.966667
110.3
110.633333
110.966667
111.3
111.633333
111.966667
112.3
112.633333
112.966667
113.3
113.633333
113.966667
114.3
114.633333
114.966667
115.3
115.633333
115.966667
116.3
116.633333
116.966667
117.3
117.633333
117.966667
118.3
118.633333
118.966667
119.3
119.633333
119.966667
120.3
120.633333
120.966667
121.3
121.633333
121.966667
122.3
122.633333
122.966667
123.3
123.633333
123.966667
124.3
124.633333
124.966667
125.3
125.633333
125.966667
126.3
126.633333
126.966667
127.3
127.633333
127.966667
128.3
128.633333
128.966667
129.3
129.633333
129.966667
130.3
130.633333
130.966667
131.3
131.633333
131.966667
132.3
132.633333
133.0
133.333333
133.666667
134.0
134.333333
134.666667
135.0
135.333333
135.666667
136.0
136.333333
136.666667
137.0
137.333333
137.666667
138.0
138.333333
138.666667
139.0
139.333333
139.666667
140.0
140.333333
140.666667
141.0
141.333333
141.666667
142.0
142.333333
142.666667
143.0
143.333333
143.666667
144.0
144.333333
144.666667
145.0
145.333333
145.666667
146.0
146.333333
146.666667
147.0
147.333333
147.666667
148.0
148.333333
148.666667
149.0
149.333333
149.666667
150.0
150.333333
150.666667
151.0
151.333333
151.666667
152.0
152.333333
152.666667

iframes matches up with ffprobe,

102.966667 ,
103.300000 ,
103.633333 ,
103.966667 ,
104.300000 ,
104.633333 ,
104.966667 ,
105.300000 ,
105.633333 ,
105.966667 ,
106.300000 ,
106.633333 ,
106.966667 ,
107.300000 ,
107.633333 ,
107.966667 ,
108.300000 ,
108.633333 ,
108.966667 ,
109.300000 ,
109.633333 ,
109.966667 ,
110.300000 ,
110.633333 ,
110.966667 ,
111.300000 ,
111.633333 ,
111.966667 ,
112.300000 ,
112.633333 ,
112.966667 ,
113.300000 ,
113.633333 ,
113.966667 ,
114.300000 ,
114.633333 ,
114.966667 ,
115.300000 ,
115.633333 ,
115.966667 ,
116.300000 ,
116.633333 ,
116.966667 ,
117.300000 ,
117.633333 ,
117.966667 ,
118.300000 ,
118.633333 ,
118.966667 ,
119.300000 ,
119.633333 ,
119.966667 ,
120.300000 ,
120.633333 ,
120.966667 ,
121.300000 ,
121.633333 ,
121.966667 ,
122.300000 ,
122.633333 ,
122.966667 ,
123.300000 ,
123.633333 ,
123.966667 ,
124.300000 ,
124.633333 ,
124.966667 ,
125.300000 ,
125.633333 ,
125.966667 ,
126.300000 ,
126.633333 ,
126.966667 ,
127.300000 ,
127.633333 ,
127.966667 ,
128.300000 ,
128.633333 ,
128.966667 ,
129.300000 ,
129.633333 ,
129.966667 ,
130.300000 ,
130.633333 ,
130.966667 ,
131.300000 ,
131.633333 ,
131.966667 ,
132.300000 ,
132.633333 ,
133.000000 ,
133.333333 ,
133.666667 ,
134.000000 ,
134.333333 ,
134.666667 ,
135.000000 ,
135.333333 ,
135.666667 ,
136.000000 ,
136.333333 ,
136.666667 ,
137.000000 ,
137.333333 ,
137.666667 ,
138.000000 ,
138.333333 ,
138.666667 ,
139.000000 ,
139.333333 ,
139.666667 ,
140.000000 ,
140.333333 ,
140.666667 ,
141.000000 ,
141.333333 ,
141.666667 ,
142.000000 ,
142.333333 ,
142.666667 ,
143.000000 ,
143.333333 ,
143.666667 ,
144.000000 ,
144.333333 ,
144.666667 ,
145.000000 ,
145.333333 ,
145.666667 ,
146.000000 ,
146.333333 ,
146.666667 ,
147.000000 ,
147.333333 ,
147.666667 ,
148.000000 ,
148.333333 ,
148.666667 ,
149.000000 ,
149.333333 ,
149.666667 ,
150.000000 ,
150.333333 ,
150.666667 ,
151.000000 ,
151.333333 ,
151.666667 ,
152.000000 ,
152.333333 ,
152.666667 ,

the is nothing wrong with the iframe detection in x9k3.

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

I have auto-return working very well in the rewrite, probably be finished with it this week.
If you having problems with iframe detection, try using shulga mode, especially if youre using mpeg2 codecs,
it uses random access indicator flags.

from scte-35_hls_x9k3.

futzu avatar futzu commented on August 15, 2024

Check out v.0.1.77 auto-return is working well.

from scte-35_hls_x9k3.

fraroas avatar fraroas commented on August 15, 2024

Thanks! Will have a look tomorrow.

from scte-35_hls_x9k3.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.