futzu / SCTE-35-HLS-Sideways

no parse HLS SCTE-35 Injection via sidecar file
BSD 3-Clause "New" or "Revised" License
4 stars 1 forks source link

There has got to be a better way.

This is the better way.

Sideways is SCTE-35 Injection for live ABR HLS

Latest Version is 0.0.23 released 02/13/2024

* The new master.m3u8 is written to your server
* Each rendition has an index.m3u8 and just the split segments in sub directories on your server.
* Each sub-directory looks like this
```smalltalk

 ls 0/
  a-seg542.ts    b-seg542.ts 
  a-seg544.ts   b-seg544.ts  
  index.m3u8 sidecar.txt

How to Use

Install

python3 -mpip install sideways

Heads up! upgrade threefive to 2.4.55

python3 -mpip install --upgrade threefive

Cli tool

a@fu:~$ sideways -h
usage: sideways [-h] [-i INPUT] [-s SIDECAR_FILE] [-o OUTPUT_DIR] [-t HLS_TAG]
                [-v]

options:
  -h, --help            show this help message and exit
  -i INPUT, --input INPUT
                        Input source, is a master.m3u8(local or http(s) with
                        MPEGTS segments default: None
  -s SIDECAR_FILE, --sidecar_file SIDECAR_FILE
                        SCTE-35 Sidecar file default: None
  -o OUTPUT_DIR, --output_dir OUTPUT_DIR
                        output directory default:None
  -T HLS_TAG, --hls_tag HLS_TAG
                        x_scte35, x_cue, x_daterange, or x_splicepoint
                        default: x_cue
  -v, --version         Show version

Running:

a@fu:~/testme$ sideways -i /home/a/foam4/master.m3u8 -s ../sidecar.txt

./0: a-seg544.ts a-seg547.ts b-seg544.ts b-seg547.ts index.m3u8 sidecar.txt

./1: a-seg544.ts a-seg547.ts b-seg544.ts b-seg547.ts index.m3u8 sidecar.txt

* 0 and 1 are renditon sub-directories.
* When a segment is split for SCTE-35 the name is prepended with a- and b-
* sideways  writes a copy of the sidecar to each rendition directory
* you can play the master.m3u8.
* the SCTE-35 Cues come out like this:
```js
# start: 3268.266667 
#EXTINF:5.733333
./0/a-seg544.ts     <-- seg544.ts is split into a-seg544.ts and b-seg544.ts.
# start: 3274.0 
#EXT-X-CUE-OUT:17.0
#EXT-X-DISCONTINUITY
#EXTINF:0.266667
./0/b-seg544.ts <-- The splice point is always at the start of b- segment.
# start: 3274.266667 
#EXT-X-CUE-OUT-CONT:0.266667/17.0
#EXTINF:6.0
/home/a/foam4/0/seg545.ts  
# start: 3280.266667 
#EXT-X-CUE-OUT-CONT:6.266667/17.0
#EXTINF:6.0
/home/a/foam4/0/seg546.ts
# start: 3286.266667 
#EXT-X-CUE-OUT-CONT:12.266667/17.0
#EXTINF:4.733333
./0/a-seg547.ts
# start: 3291.0 
#EXT-X-CUE-IN
#EXT-X-DISCONTINUITY
#EXTINF:1.266667
./0/b-seg547.ts
# start: 3292.266667 

Sidecar files

38103.868589, /DAxAAAAAAAAAP/wFAUAAABdf+/+zHRtOn4Ae6DOAAAAAAAMAQpDVUVJsZ8xMjEqLYemJQ== 38199.918911, /DAsAAAAAAAAAP/wDwUAAABef0/+zPACTQAAAAAADAEKQ1VFSbGfMTIxIxGolm0=

* you can do dynamic cue injection with a Sidecar file
```lua
touch sidecar.txt

sideways -i master.m3u8 -s sidecar.txt -o bob