threefive3 3.0.41__tar.gz → 3.0.43__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {threefive3-3.0.41 → threefive3-3.0.43}/PKG-INFO +34 -12
- {threefive3-3.0.41 → threefive3-3.0.43}/README.md +33 -11
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/bitn.py +1 -2
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/commands.py +1 -1
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/crc.py +6 -6
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/cue.py +19 -7
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/gums.py +7 -5
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/hls.py +1 -1
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/hlstags.py +14 -2
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/pmt.py +19 -27
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/section.py +1 -1
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/sixfix.py +21 -30
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/stream.py +9 -34
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/stuff.py +24 -14
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/superkabuki.py +6 -22
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/uxp.py +1 -1
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/version.py +1 -1
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/xml.py +9 -5
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3.egg-info/PKG-INFO +34 -12
- {threefive3-3.0.41 → threefive3-3.0.43}/LICENSE +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/bin/threefive3 +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/setup.cfg +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/setup.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/__init__.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/aac.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/base.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/descriptors.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/encode.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/iframes.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/new_reader.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/packetdata.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/segment.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/segmentation.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/streamtypes.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/upids.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3/words.py +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3.egg-info/SOURCES.txt +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3.egg-info/dependency_links.txt +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3.egg-info/requires.txt +0 -0
- {threefive3-3.0.41 → threefive3-3.0.43}/threefive3.egg-info/top_level.txt +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: threefive3
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.43
|
|
4
4
|
Summary: SCTE-35 decoder and encoder with MPEGTS and HLS and XML support.
|
|
5
5
|
Home-page: https://github.com/superkabuki/threefive3
|
|
6
6
|
Author: Adrian of Doom
|
|
@@ -20,9 +20,11 @@ Description-Content-Type: text/markdown
|
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
|
|
22
22
|
[__Install__](#install) |[__SCTE-35 Cli__](#the-cli-tool) | [__SCTE-35 HLS__](https://github.com/superkabuki/threefive3/blob/main/hls.md) | [__Cue__ Class](https://github.com/superkabuki/threefive3/blob/main/cue.md) | [__Stream__ Class](https://github.com/superkabuki/threefive3/blob/main/stream.md) | [__Online SCTE-35 Parser__](https://iodisco.com/scte35) | [__Encode SCTE-35__](https://github.com/superkabuki/threefive3/blob/main/encode.md) | [__SCTE-35 Examples__](https://github.com/superkabuki/threefive3/tree/main/examples)
|
|
23
|
-
| [__SCTE-35 XML__](https://github.com/superkabuki/SCTE-35/blob/main/xml.md)
|
|
23
|
+
| [__SCTE-35 XML__](https://github.com/superkabuki/SCTE-35/blob/main/xml.md)
|
|
24
|
+
|
|
25
|
+
|
|
24
26
|
|
|
25
|
-
# threefive3 is
|
|
27
|
+
# threefive3 is ready.
|
|
26
28
|
✅ SCTE-35 __Parser__ ✅ SCTE-35 __Encoder__ ✅ SCTE-35 __HLS__ ✅ SCTE-35 __Xml+binary__ ✅ SCTE-35 __Cli__ ✅ SCTE-35 __library__
|
|
27
29
|
|
|
28
30
|
|
|
@@ -32,20 +34,40 @@ License-File: LICENSE
|
|
|
32
34
|
* Automatic AES decryption for HLS.
|
|
33
35
|
* All HLS __SCTE-35__ Tags are Supported.
|
|
34
36
|
|
|
35
|
-
# Heads up.
|
|
37
|
+
# Heads up, I'm about to push v3.0.43
|
|
36
38
|
<pre>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
Q.
|
|
40
|
+
Why the release?
|
|
41
|
+
|
|
42
|
+
A.
|
|
43
|
+
I made a mistake with the xml method in the Cue class. I intended it to return a node instance,
|
|
44
|
+
but instead I had it return just the xml output of a Node instance, not a big deal really,
|
|
45
|
+
but everything else returns a node instance from their xml() method, Cue should too..
|
|
46
|
+
I don't want people getting used to it not return a Node instance.
|
|
47
|
+
v3.0.43 fixes Cue.xml() to return a Node instance.
|
|
48
|
+
I also added more autodetection of SCTE-35 Formats to the Cue class,
|
|
49
|
+
no other SCTE-35 software can do even half of these.
|
|
50
|
+
Base64,
|
|
51
|
+
Bytes,
|
|
52
|
+
Dicts,
|
|
53
|
+
MPEGTS SCTE-35 packets,
|
|
54
|
+
Hex (literal and string),
|
|
55
|
+
Integers (literal, bytestring,and string),
|
|
56
|
+
JSON(strings and bytestrings),
|
|
57
|
+
XML(string and bytestring)
|
|
58
|
+
XML+Binary(string and bytestring)
|
|
59
|
+
|
|
60
|
+
I brought in the PMT module,that really cleans SixFix and SuperKabuki up a lot.
|
|
61
|
+
SuperKabuki is now a subclass of SixFix instead of the Stream class, that gets rid of a lot
|
|
62
|
+
of redundant code.
|
|
42
63
|
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
The Super Kabuki MPEGTS SCTE-35 Packet Injection Engine is working really really well.
|
|
65
|
+
I've tested the SuperKabuki output with ffmpeg and tsduck and everything works.
|
|
66
|
+
It's workinng perfectly for me, so I want to get it out there and see if y'all break it. :)
|
|
45
67
|
</pre>
|
|
46
68
|
|
|
47
69
|
|
|
48
|
-
# Latest release is v3.0.
|
|
70
|
+
# Latest release is v3.0.43
|
|
49
71
|
_Released Thursday April 18th, 2025
|
|
50
72
|
* just 4300 lines of code.
|
|
51
73
|
* cyclomatic complexity __2.05__
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
[__Install__](#install) |[__SCTE-35 Cli__](#the-cli-tool) | [__SCTE-35 HLS__](https://github.com/superkabuki/threefive3/blob/main/hls.md) | [__Cue__ Class](https://github.com/superkabuki/threefive3/blob/main/cue.md) | [__Stream__ Class](https://github.com/superkabuki/threefive3/blob/main/stream.md) | [__Online SCTE-35 Parser__](https://iodisco.com/scte35) | [__Encode SCTE-35__](https://github.com/superkabuki/threefive3/blob/main/encode.md) | [__SCTE-35 Examples__](https://github.com/superkabuki/threefive3/tree/main/examples)
|
|
2
|
-
| [__SCTE-35 XML__](https://github.com/superkabuki/SCTE-35/blob/main/xml.md)
|
|
2
|
+
| [__SCTE-35 XML__](https://github.com/superkabuki/SCTE-35/blob/main/xml.md)
|
|
3
|
+
|
|
4
|
+
|
|
3
5
|
|
|
4
|
-
# threefive3 is
|
|
6
|
+
# threefive3 is ready.
|
|
5
7
|
✅ SCTE-35 __Parser__ ✅ SCTE-35 __Encoder__ ✅ SCTE-35 __HLS__ ✅ SCTE-35 __Xml+binary__ ✅ SCTE-35 __Cli__ ✅ SCTE-35 __library__
|
|
6
8
|
|
|
7
9
|
|
|
@@ -11,20 +13,40 @@
|
|
|
11
13
|
* Automatic AES decryption for HLS.
|
|
12
14
|
* All HLS __SCTE-35__ Tags are Supported.
|
|
13
15
|
|
|
14
|
-
# Heads up.
|
|
16
|
+
# Heads up, I'm about to push v3.0.43
|
|
15
17
|
<pre>
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
Q.
|
|
19
|
+
Why the release?
|
|
20
|
+
|
|
21
|
+
A.
|
|
22
|
+
I made a mistake with the xml method in the Cue class. I intended it to return a node instance,
|
|
23
|
+
but instead I had it return just the xml output of a Node instance, not a big deal really,
|
|
24
|
+
but everything else returns a node instance from their xml() method, Cue should too..
|
|
25
|
+
I don't want people getting used to it not return a Node instance.
|
|
26
|
+
v3.0.43 fixes Cue.xml() to return a Node instance.
|
|
27
|
+
I also added more autodetection of SCTE-35 Formats to the Cue class,
|
|
28
|
+
no other SCTE-35 software can do even half of these.
|
|
29
|
+
Base64,
|
|
30
|
+
Bytes,
|
|
31
|
+
Dicts,
|
|
32
|
+
MPEGTS SCTE-35 packets,
|
|
33
|
+
Hex (literal and string),
|
|
34
|
+
Integers (literal, bytestring,and string),
|
|
35
|
+
JSON(strings and bytestrings),
|
|
36
|
+
XML(string and bytestring)
|
|
37
|
+
XML+Binary(string and bytestring)
|
|
38
|
+
|
|
39
|
+
I brought in the PMT module,that really cleans SixFix and SuperKabuki up a lot.
|
|
40
|
+
SuperKabuki is now a subclass of SixFix instead of the Stream class, that gets rid of a lot
|
|
41
|
+
of redundant code.
|
|
21
42
|
|
|
22
|
-
|
|
23
|
-
|
|
43
|
+
The Super Kabuki MPEGTS SCTE-35 Packet Injection Engine is working really really well.
|
|
44
|
+
I've tested the SuperKabuki output with ffmpeg and tsduck and everything works.
|
|
45
|
+
It's workinng perfectly for me, so I want to get it out there and see if y'all break it. :)
|
|
24
46
|
</pre>
|
|
25
47
|
|
|
26
48
|
|
|
27
|
-
# Latest release is v3.0.
|
|
49
|
+
# Latest release is v3.0.43
|
|
28
50
|
_Released Thursday April 18th, 2025
|
|
29
51
|
* just 4300 lines of code.
|
|
30
52
|
* cyclomatic complexity __2.05__
|
|
@@ -17,7 +17,6 @@ class Bitn:
|
|
|
17
17
|
self.bitsize = self.idx = len(bites) << 3
|
|
18
18
|
self.bits = int.from_bytes(bites, byteorder="big")
|
|
19
19
|
|
|
20
|
-
|
|
21
20
|
def __repr__(self):
|
|
22
21
|
return str(vars(self))
|
|
23
22
|
|
|
@@ -160,7 +159,7 @@ class NBin:
|
|
|
160
159
|
else:
|
|
161
160
|
dehexed = hex_str
|
|
162
161
|
self.add_int(dehexed, bit_len)
|
|
163
|
-
|
|
162
|
+
|
|
164
163
|
def add_flag(self, flg, bit_len=1):
|
|
165
164
|
"""
|
|
166
165
|
add_flag takes a boolean
|
|
@@ -164,7 +164,7 @@ class TimeSignal(SpliceCommand):
|
|
|
164
164
|
nbin.reserve(6)
|
|
165
165
|
if not isinstance(self.pts_time, float):
|
|
166
166
|
blue("converting pts_time from ticks")
|
|
167
|
-
self.pts_time= self.as_90k(self.pts_time)
|
|
167
|
+
self.pts_time = self.as_90k(self.pts_time)
|
|
168
168
|
self.pts_time = round(self.pts_time, 6)
|
|
169
169
|
nbin.add_int(int(self.as_ticks(self.pts_time)), 33)
|
|
170
170
|
else:
|
|
@@ -2,24 +2,24 @@
|
|
|
2
2
|
crc.py crc32 function for encoding.
|
|
3
3
|
"""
|
|
4
4
|
|
|
5
|
-
from .words import zero, one, eight, twentyfour,
|
|
5
|
+
from .words import zero, one, eight, twentyfour, twofiftyfive, twofiftysix
|
|
6
6
|
|
|
7
|
+
BC_MASK = 0x80000000
|
|
7
8
|
POLY = 0x104C11DB7
|
|
8
9
|
INIT_VALUE = 0xFFFFFFFF
|
|
10
|
+
GONZO = INIT_VALUE - 0xFF
|
|
9
11
|
|
|
10
12
|
|
|
11
13
|
def _bytecrc(crc, poly):
|
|
12
|
-
mask = one << (thirtytwo - one)
|
|
13
14
|
i = eight
|
|
14
15
|
while i:
|
|
15
|
-
crc = (crc << one, crc << one ^ poly)[crc &
|
|
16
|
+
crc = (crc << one, crc << one ^ poly)[crc & BC_MASK != zero]
|
|
16
17
|
i -= one
|
|
17
18
|
return crc & INIT_VALUE
|
|
18
19
|
|
|
19
20
|
|
|
20
21
|
def _mk_table():
|
|
21
|
-
|
|
22
|
-
poly = POLY & mask
|
|
22
|
+
poly = POLY & INIT_VALUE
|
|
23
23
|
return [_bytecrc((i << twentyfour), poly) for i in range(twofiftysix)]
|
|
24
24
|
|
|
25
25
|
|
|
@@ -32,7 +32,7 @@ def crc32(data):
|
|
|
32
32
|
crc = INIT_VALUE
|
|
33
33
|
for bite in data:
|
|
34
34
|
crc = table[bite ^ ((crc >> twentyfour) & twofiftyfive)] ^ (
|
|
35
|
-
(crc << eight) & (
|
|
35
|
+
(crc << eight) & (GONZO)
|
|
36
36
|
)
|
|
37
37
|
return crc
|
|
38
38
|
|
|
@@ -12,7 +12,19 @@ from .commands import command_map
|
|
|
12
12
|
from .descriptors import splice_descriptor, descriptor_map
|
|
13
13
|
from .crc import crc32
|
|
14
14
|
from .segmentation import table22
|
|
15
|
-
from .words import
|
|
15
|
+
from .words import (
|
|
16
|
+
minusone,
|
|
17
|
+
zero,
|
|
18
|
+
one,
|
|
19
|
+
two,
|
|
20
|
+
three,
|
|
21
|
+
four,
|
|
22
|
+
eight,
|
|
23
|
+
eleven,
|
|
24
|
+
fourteen,
|
|
25
|
+
sixteen,
|
|
26
|
+
equalsign,
|
|
27
|
+
)
|
|
16
28
|
from .uxp import xml2cue
|
|
17
29
|
|
|
18
30
|
|
|
@@ -64,7 +76,7 @@ class Cue(SCTE35Base):
|
|
|
64
76
|
"""
|
|
65
77
|
Cue.decode() parses for SCTE35 data
|
|
66
78
|
|
|
67
|
-
*
|
|
79
|
+
*decode doesn't need to be called directly
|
|
68
80
|
unless you initialize a Cue without data.
|
|
69
81
|
"""
|
|
70
82
|
bites = self.bites
|
|
@@ -162,7 +174,7 @@ class Cue(SCTE35Base):
|
|
|
162
174
|
if isxml(data) or isjson(data):
|
|
163
175
|
self.load(data)
|
|
164
176
|
return self.bites
|
|
165
|
-
data=data.strip()
|
|
177
|
+
data = data.strip()
|
|
166
178
|
if data.isdigit():
|
|
167
179
|
return self._int_bits(int(data))
|
|
168
180
|
return self._b64_bits(data)
|
|
@@ -175,7 +187,7 @@ class Cue(SCTE35Base):
|
|
|
175
187
|
return data.split(b"\x00\x00\x01\xfc", one)[minusone]
|
|
176
188
|
return data
|
|
177
189
|
|
|
178
|
-
def _byte_bits(self,data):
|
|
190
|
+
def _byte_bits(self, data):
|
|
179
191
|
data = self._pkt_bits(data)
|
|
180
192
|
self.bites = self.idxsplit(data, b"\xfc")
|
|
181
193
|
return self.bites
|
|
@@ -390,7 +402,7 @@ class Cue(SCTE35Base):
|
|
|
390
402
|
if isinstance(gonzo, bytes):
|
|
391
403
|
gonzo = clean(gonzo)
|
|
392
404
|
if isinstance(gonzo, str):
|
|
393
|
-
if isxml(gonzo)
|
|
405
|
+
if isxml(gonzo):
|
|
394
406
|
self._from_xml(gonzo)
|
|
395
407
|
return self.bites
|
|
396
408
|
gonzo = json.loads(gonzo)
|
|
@@ -405,7 +417,7 @@ class Cue(SCTE35Base):
|
|
|
405
417
|
_from_xml converts xml to data that can
|
|
406
418
|
be loaded by a Cue instance.
|
|
407
419
|
"""
|
|
408
|
-
gonzo=clean(gonzo)
|
|
420
|
+
gonzo = clean(gonzo)
|
|
409
421
|
if "<scte35:Binary>" in gonzo:
|
|
410
422
|
dat = gonzo.split("<scte35:Binary>")[1].split("</scte35:Binary>")[0]
|
|
411
423
|
self.bites = self._mk_bits(dat)
|
|
@@ -445,7 +457,7 @@ class Cue(SCTE35Base):
|
|
|
445
457
|
cmd = self.command.xml(ns=ns)
|
|
446
458
|
sis.add_child(cmd)
|
|
447
459
|
sis = self._xml_mk_descriptor(sis, ns)
|
|
448
|
-
return sis
|
|
460
|
+
return sis # xml retuns a Node instance. now
|
|
449
461
|
|
|
450
462
|
def xmlbin(self, ns="scte35"):
|
|
451
463
|
"""
|
|
@@ -13,7 +13,7 @@ import sys
|
|
|
13
13
|
import time
|
|
14
14
|
from functools import partial
|
|
15
15
|
from .new_reader import reader
|
|
16
|
-
from .stuff import blue, reblue,print2
|
|
16
|
+
from .stuff import blue, reblue, print2
|
|
17
17
|
|
|
18
18
|
|
|
19
19
|
DGRAM_SIZE = 1316
|
|
@@ -58,7 +58,7 @@ class GumS:
|
|
|
58
58
|
sock = socket.socket(socket.AF_INET, socket.SOCK_DGRAM, socket.IPPROTO_UDP)
|
|
59
59
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1)
|
|
60
60
|
if hasattr(socket, "SO_REUSEPORT"):
|
|
61
|
-
blue(
|
|
61
|
+
blue("setting SO_REUSEPORT")
|
|
62
62
|
sock.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEPORT, 1)
|
|
63
63
|
return sock
|
|
64
64
|
|
|
@@ -78,8 +78,10 @@ class GumS:
|
|
|
78
78
|
total_bytes += len(dgram)
|
|
79
79
|
elapsed = now() - start_time
|
|
80
80
|
rate = (total_bytes / million) / elapsed
|
|
81
|
-
mb=total_bytes/million
|
|
82
|
-
reblue(
|
|
81
|
+
mb = total_bytes / million
|
|
82
|
+
reblue(
|
|
83
|
+
f"\t{mb:0.2f} MB sent in {elapsed:5.2f} seconds. {rate:3.2f} MB/Sec"
|
|
84
|
+
)
|
|
83
85
|
print("\n", file=sys.stderr)
|
|
84
86
|
|
|
85
87
|
def send_stream(self, vid):
|
|
@@ -183,7 +185,7 @@ def cli():
|
|
|
183
185
|
"""
|
|
184
186
|
|
|
185
187
|
args = parse_args()
|
|
186
|
-
#daemonize()
|
|
188
|
+
# daemonize()
|
|
187
189
|
ttl = int(args.ttl).to_bytes(1, byteorder="big")
|
|
188
190
|
dest_addr = args.addr
|
|
189
191
|
gummie = GumS(dest_addr, ttl, args.bind_addr)
|
|
@@ -639,7 +639,7 @@ class HlsParser:
|
|
|
639
639
|
if pts and new_line:
|
|
640
640
|
if abs(pts - self.pts) > 5: # Handle Cues out of sync with video PTS
|
|
641
641
|
pts = self.pts
|
|
642
|
-
|
|
642
|
+
return self.set_cue_state(tags["#EXT-OATCLS-SCTE35"], new_line)
|
|
643
643
|
# return self.invalid(line)
|
|
644
644
|
return line
|
|
645
645
|
|
|
@@ -4,7 +4,19 @@ hlstags.py
|
|
|
4
4
|
"""
|
|
5
5
|
|
|
6
6
|
from .stuff import atohif, ERR
|
|
7
|
-
from .words import
|
|
7
|
+
from .words import (
|
|
8
|
+
minusone,
|
|
9
|
+
zero,
|
|
10
|
+
one,
|
|
11
|
+
two,
|
|
12
|
+
colon,
|
|
13
|
+
comma,
|
|
14
|
+
equalsign,
|
|
15
|
+
dblquote,
|
|
16
|
+
octothorpe,
|
|
17
|
+
space,
|
|
18
|
+
nothing,
|
|
19
|
+
)
|
|
8
20
|
|
|
9
21
|
BASIC_TAGS = (
|
|
10
22
|
"#EXTM3U",
|
|
@@ -86,7 +98,7 @@ class TagParser:
|
|
|
86
98
|
def _colon_in_line(line):
|
|
87
99
|
return colon in line
|
|
88
100
|
|
|
89
|
-
def precheck(self,line):
|
|
101
|
+
def precheck(self, line):
|
|
90
102
|
"""
|
|
91
103
|
precheck precheck that a line has tags
|
|
92
104
|
"""
|
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
from .bitn import Bitn, NBin
|
|
2
2
|
from .crc import crc32
|
|
3
|
-
import pprint
|
|
4
|
-
from .stuff import blue
|
|
5
3
|
|
|
6
4
|
|
|
7
5
|
class Dscptr:
|
|
@@ -30,8 +28,8 @@ class PmtStream:
|
|
|
30
28
|
def __init__(self, bitn=None, conv_pids=None):
|
|
31
29
|
|
|
32
30
|
self.descriptors = []
|
|
33
|
-
self.stream_type =None
|
|
34
|
-
self.elementary_PID
|
|
31
|
+
self.stream_type = None
|
|
32
|
+
self.elementary_PID = None
|
|
35
33
|
self.ES_info_length = 0
|
|
36
34
|
if bitn:
|
|
37
35
|
self.stream_type = bitn.as_int(8)
|
|
@@ -44,9 +42,9 @@ class PmtStream:
|
|
|
44
42
|
dscptr = Dscptr(bitn)
|
|
45
43
|
eil -= dscptr.total_size << 3
|
|
46
44
|
self.descriptors.append(dscptr)
|
|
47
|
-
#if conv_pids:
|
|
48
|
-
|
|
49
|
-
|
|
45
|
+
# if conv_pids:
|
|
46
|
+
# if self.elementary_PID in conv_pids:
|
|
47
|
+
# self.add_CUEI()
|
|
50
48
|
self.total_size = 5 + self.ES_info_length
|
|
51
49
|
|
|
52
50
|
def add_CUEI(self):
|
|
@@ -58,7 +56,7 @@ class PmtStream:
|
|
|
58
56
|
cuei.total_size = 6
|
|
59
57
|
self.descriptors = [cuei] + self.descriptors
|
|
60
58
|
self.ES_info_length += cuei.total_size
|
|
61
|
-
|
|
59
|
+
|
|
62
60
|
def __repr__(self):
|
|
63
61
|
return str(vars(self))
|
|
64
62
|
|
|
@@ -74,7 +72,7 @@ class PmtStream:
|
|
|
74
72
|
|
|
75
73
|
class PMT:
|
|
76
74
|
|
|
77
|
-
def __init__(self, payload, conv_pids):
|
|
75
|
+
def __init__(self, payload, conv_pids=None):
|
|
78
76
|
self.conv_pids = conv_pids
|
|
79
77
|
bitn = Bitn(payload)
|
|
80
78
|
self.table_id = bitn.as_int(8)
|
|
@@ -118,29 +116,28 @@ class PMT:
|
|
|
118
116
|
while self.bitn.idx > 32:
|
|
119
117
|
pms = PmtStream(self.bitn, self.conv_pids)
|
|
120
118
|
streams.append(pms)
|
|
121
|
-
# pprint.pprint(streams)
|
|
122
119
|
return streams
|
|
123
120
|
|
|
124
|
-
def add_SCTE35stream(self,pid):
|
|
121
|
+
def add_SCTE35stream(self, pid):
|
|
125
122
|
pms = PmtStream()
|
|
126
|
-
pms.elementary_PID=pid
|
|
127
|
-
pms.stream_type=0x86
|
|
128
|
-
#pms.add_CUEI()
|
|
129
|
-
pms.total_size=5
|
|
123
|
+
pms.elementary_PID = pid
|
|
124
|
+
pms.stream_type = 0x86
|
|
125
|
+
# pms.add_CUEI()
|
|
126
|
+
pms.total_size = 5
|
|
130
127
|
self.streams.append(pms)
|
|
131
|
-
|
|
128
|
+
|
|
132
129
|
def mk(self):
|
|
133
130
|
vals = [dscptr.value for dscptr in self.descriptors]
|
|
134
131
|
if b"CUEI" not in vals:
|
|
135
|
-
|
|
132
|
+
# blue("Adding SCTE-35 Descriptor")
|
|
136
133
|
cuei = Dscptr()
|
|
137
134
|
cuei.type = 5
|
|
138
135
|
cuei.length = 4
|
|
139
136
|
cuei.value = b"CUEI"
|
|
140
137
|
cuei.total_size = 6
|
|
141
138
|
self.descriptors.append(cuei)
|
|
142
|
-
|
|
143
|
-
|
|
139
|
+
# else:
|
|
140
|
+
# blue("SCTE-35 Descriptor already present.")
|
|
144
141
|
self.program_info_length = sum(
|
|
145
142
|
[dscptr.total_size for dscptr in self.descriptors]
|
|
146
143
|
)
|
|
@@ -149,7 +146,7 @@ class PMT:
|
|
|
149
146
|
nbin.add_int(self.table_id, 8) # 0x02
|
|
150
147
|
nbin.add_int(self.section_syntax_indicator, 1) # 9
|
|
151
148
|
nbin.add_int(self.zero, 1) # 10
|
|
152
|
-
nbin.add_int(3,2) # 12
|
|
149
|
+
nbin.add_int(3, 2) # 12
|
|
153
150
|
self.section_length = 13 + self.program_info_length + stream_len
|
|
154
151
|
nbin.add_int(self.section_length, 12) # 24
|
|
155
152
|
nbin.add_int(self.program_number, 16) # 40
|
|
@@ -168,10 +165,5 @@ class PMT:
|
|
|
168
165
|
stream.add(nbin)
|
|
169
166
|
self.crc32 = crc32(nbin.bites)
|
|
170
167
|
nbin.add_int(self.crc32, 32)
|
|
171
|
-
|
|
172
|
-
return b
|
|
173
|
-
|
|
174
|
-
self.program_info_length = None
|
|
175
|
-
self.descriptors = []
|
|
176
|
-
self.streams = []
|
|
177
|
-
self.crc32 = None
|
|
168
|
+
# nbin.add_int(0, 8)
|
|
169
|
+
return b"\x00" + nbin.bites
|
|
@@ -188,7 +188,7 @@ class SpliceInfoSection(SCTE35Base):
|
|
|
188
188
|
"pts_adjustment": self.as_ticks(self.pts_adjustment),
|
|
189
189
|
"protocol_version": self.protocol_version,
|
|
190
190
|
"sap_type": self.sap_type,
|
|
191
|
-
"tier": int(self.tier,base=16),
|
|
191
|
+
"tier": int(self.tier, base=16),
|
|
192
192
|
}
|
|
193
193
|
sis = Node("SpliceInfoSection", attrs=sis_attrs, ns=ns)
|
|
194
194
|
return sis
|
|
@@ -6,8 +6,6 @@ import io
|
|
|
6
6
|
import sys
|
|
7
7
|
from collections import deque
|
|
8
8
|
from functools import partial
|
|
9
|
-
from .crc import crc32
|
|
10
|
-
from .bitn import NBin
|
|
11
9
|
from .stuff import print2, ERR
|
|
12
10
|
from .stream import Stream, ProgramInfo
|
|
13
11
|
from .pmt import PMT
|
|
@@ -49,7 +47,7 @@ class SixFix(Stream):
|
|
|
49
47
|
def __init__(self, tsdata=None):
|
|
50
48
|
super().__init__(tsdata)
|
|
51
49
|
self.pmt_payloads = {}
|
|
52
|
-
self.pmt_headers = deque()
|
|
50
|
+
self.pmt_headers = deque() # popleft()
|
|
53
51
|
self.pmt_inputs = []
|
|
54
52
|
self.pid_prog = {}
|
|
55
53
|
self.con_pids = set()
|
|
@@ -80,7 +78,7 @@ class SixFix(Stream):
|
|
|
80
78
|
def _parse_pkts(self, out_file):
|
|
81
79
|
active = io.BytesIO()
|
|
82
80
|
pkt_count = 0
|
|
83
|
-
chunk_size =
|
|
81
|
+
chunk_size = 2884
|
|
84
82
|
for pkt in self.iter_pkts():
|
|
85
83
|
pid = self._parse_pid(pkt[1], pkt[2])
|
|
86
84
|
pkt = self._parse_by_pid(pkt, pid)
|
|
@@ -113,27 +111,24 @@ class SixFix(Stream):
|
|
|
113
111
|
"""
|
|
114
112
|
pmt2packets split the new pmt table into 188 byte packets
|
|
115
113
|
"""
|
|
114
|
+
pmt_parts = []
|
|
116
115
|
pmt = self.pmt_headers.popleft() + pmt.mk()
|
|
117
116
|
if len(pmt) < 188:
|
|
118
117
|
pad = (188 - len(pmt)) * b"\xff"
|
|
119
|
-
|
|
118
|
+
pmt_parts.append(pmt + pad)
|
|
120
119
|
else:
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
elif len(two) < 188:
|
|
134
|
-
pad2 = (188 - len(two)) * b"\xff"
|
|
135
|
-
|
|
136
|
-
self.pmt_payloads[program_number] = one + two + pad2 + three + pad3
|
|
120
|
+
pmt_parts.append(pmt[:188])
|
|
121
|
+
pmt = pmt[188:]
|
|
122
|
+
while pmt:
|
|
123
|
+
pmtpkt = self.pmt_headers.popleft() + pmt
|
|
124
|
+
if len(pmtpkt) < 188:
|
|
125
|
+
pad = 188 - len(pmtpkt) * b"\xff"
|
|
126
|
+
pmtpkt = pmtpkt + pad
|
|
127
|
+
else:
|
|
128
|
+
pmt = pmtpkt[188:]
|
|
129
|
+
pmtpkt = pmtpkt[:188]
|
|
130
|
+
pmt_parts.append(pmtpkt)
|
|
131
|
+
self.pmt_payloads[program_number] = b"".join(pmt_parts)
|
|
137
132
|
return True
|
|
138
133
|
|
|
139
134
|
def _pmt_precheck(self, pay, pid):
|
|
@@ -141,12 +136,12 @@ class SixFix(Stream):
|
|
|
141
136
|
pay = self._chk_payload(pay, pid)
|
|
142
137
|
if not pay:
|
|
143
138
|
return False
|
|
144
|
-
## if pay in self.pmt_inputs: <<---- this breaks continuity counters
|
|
145
|
-
## return False
|
|
139
|
+
## if pay in self.pmt_inputs: <<---- this breaks continuity counters
|
|
140
|
+
## return False
|
|
146
141
|
self.pmt_inputs.append(pay)
|
|
147
142
|
return pay
|
|
148
143
|
|
|
149
|
-
def mk_pmt(self,pay):
|
|
144
|
+
def mk_pmt(self, pay):
|
|
150
145
|
pmt = PMT(pay, self.con_pids)
|
|
151
146
|
return pmt
|
|
152
147
|
|
|
@@ -159,7 +154,6 @@ class SixFix(Stream):
|
|
|
159
154
|
return False
|
|
160
155
|
pmt = self.mk_pmt(pay)
|
|
161
156
|
seclen = self._parse_length(pay[1], pay[2])
|
|
162
|
-
n_seclen = seclen + 6
|
|
163
157
|
if self._section_incomplete(pay, pid, seclen):
|
|
164
158
|
return False
|
|
165
159
|
program_number = self._parse_program(pay[3], pay[4])
|
|
@@ -176,14 +170,10 @@ class SixFix(Stream):
|
|
|
176
170
|
self.maps.pid_prgm[pid] = program_number
|
|
177
171
|
proginfolen = self._parse_length(pay[10], pay[11])
|
|
178
172
|
idx = 12
|
|
179
|
-
n_proginfolen = proginfolen + len(self.CUEI_DESCRIPTOR)
|
|
180
173
|
end = idx + proginfolen
|
|
181
174
|
info_bites = pay[idx:end]
|
|
182
|
-
n_info_bites = self.CUEI_DESCRIPTOR + info_bites
|
|
183
175
|
idx = 12 + proginfolen
|
|
184
176
|
si_len = seclen - (9 + proginfolen) # ???
|
|
185
|
-
n_streams = self._parse_program_streams(si_len, pay, idx, program_number)
|
|
186
|
-
# self._regen_pmt(program_number,n_seclen, pcr_pid, n_proginfolen, n_info_bites, n_streams)
|
|
187
177
|
return self.pmt2packets(pmt, program_number)
|
|
188
178
|
|
|
189
179
|
def _parse_program_streams(self, si_len, pay, idx, program_number):
|
|
@@ -238,9 +228,10 @@ def sixfix(arg):
|
|
|
238
228
|
print2(f'Wrote: sixfixed-{arg.rsplit("/")[-1]}\n')
|
|
239
229
|
return
|
|
240
230
|
|
|
231
|
+
|
|
241
232
|
def cli():
|
|
242
233
|
args = sys.argv[1:]
|
|
243
|
-
_= [
|
|
234
|
+
_ = [sixfix(arg) for arg in args]
|
|
244
235
|
|
|
245
236
|
|
|
246
237
|
if __name__ == "__main__":
|
|
@@ -6,7 +6,7 @@ import sys
|
|
|
6
6
|
|
|
7
7
|
from functools import partial
|
|
8
8
|
from .new_reader import reader
|
|
9
|
-
from .stuff import print2,blue,ERR
|
|
9
|
+
from .stuff import print2, blue, ERR
|
|
10
10
|
from .cue import Cue
|
|
11
11
|
from .packetdata import PacketData
|
|
12
12
|
from .streamtypes import streamtype_map
|
|
@@ -160,9 +160,9 @@ class Stream:
|
|
|
160
160
|
self.the_scte35_pids = []
|
|
161
161
|
self.pids = Pids()
|
|
162
162
|
self.maps = Maps()
|
|
163
|
-
|
|
164
|
-
self.pmt_payloads=
|
|
165
|
-
self.pmt_count=0
|
|
163
|
+
# self.iframer = IFramer(shush=True)
|
|
164
|
+
self.pmt_payloads = {}
|
|
165
|
+
self.pmt_count = 0
|
|
166
166
|
|
|
167
167
|
def __repr__(self):
|
|
168
168
|
return str(self.__dict__)
|
|
@@ -318,7 +318,7 @@ class Stream:
|
|
|
318
318
|
self.info = True
|
|
319
319
|
for pkt in self.iter_pkts():
|
|
320
320
|
self._parse(pkt)
|
|
321
|
-
if self.pmt_count > len(self.pmt_payloads) <<1:
|
|
321
|
+
if self.pmt_count > len(self.pmt_payloads) << 1:
|
|
322
322
|
blue(f"PMT Count: {self.pmt_count}")
|
|
323
323
|
break
|
|
324
324
|
if self.maps.prgm.keys():
|
|
@@ -380,27 +380,12 @@ class Stream:
|
|
|
380
380
|
return False
|
|
381
381
|
|
|
382
382
|
def _unpad_afc(self, pkt):
|
|
383
|
-
|
|
384
|
-
return
|
|
383
|
+
# if self._afc_flag(pkt[3]):
|
|
384
|
+
return pkt[:4] + self._unpad(pkt[4:])
|
|
385
385
|
|
|
386
386
|
def _unpad(self, bites=b""):
|
|
387
387
|
return bites.strip(b"\xff")
|
|
388
388
|
|
|
389
|
-
## def _unpad(self, bites):
|
|
390
|
-
## pad = 255
|
|
391
|
-
## one = 1
|
|
392
|
-
## if not bites:
|
|
393
|
-
## return b""
|
|
394
|
-
## while bites[0] == pad:
|
|
395
|
-
## bites = bites[1:]
|
|
396
|
-
## return self._unpad2(bites)
|
|
397
|
-
##
|
|
398
|
-
## def _unpad2(self, bites):
|
|
399
|
-
## pad = 255
|
|
400
|
-
## while bites[-1] == pad:
|
|
401
|
-
## bites = bites[:-1]
|
|
402
|
-
## return bites
|
|
403
|
-
|
|
404
389
|
def _mk_packet_data(self, pid):
|
|
405
390
|
prgm = self.maps.pid_prgm[pid]
|
|
406
391
|
pdata = PacketData(pid, prgm)
|
|
@@ -450,7 +435,6 @@ class Stream:
|
|
|
450
435
|
def _afc_flag(pkt):
|
|
451
436
|
return pkt[3] & 32
|
|
452
437
|
|
|
453
|
-
|
|
454
438
|
def _parse_payload(self, pkt):
|
|
455
439
|
"""
|
|
456
440
|
_parse_payload returns the packet payload
|
|
@@ -462,28 +446,19 @@ class Stream:
|
|
|
462
446
|
head_size += afl + 1 # +one for afl byte
|
|
463
447
|
return pkt[head_size:]
|
|
464
448
|
|
|
465
|
-
## def _pmt_pid(self, pay, pid):
|
|
466
|
-
## if pid in self.pids.pmt:
|
|
467
|
-
## self.pmt_count+=1
|
|
468
|
-
## if self.pmt_count > 10:
|
|
469
|
-
## if pay in self.pmt_payloads:
|
|
470
|
-
## return
|
|
471
|
-
## self.pmt_payloads.add(pay)
|
|
472
|
-
## self._parse_pmt(pay, pid)
|
|
473
|
-
|
|
474
449
|
def _pmt_pid(self, pay, pid):
|
|
475
450
|
self.pmt_count += 1
|
|
476
451
|
if pay in self.pmt_payloads:
|
|
477
452
|
if self.pmt_count > len(self.pmt_payloads) << 1:
|
|
478
453
|
return
|
|
479
|
-
self.pmt_payloads.
|
|
454
|
+
self.pmt_payloads[self.pid2prgm(pid)] = pay
|
|
480
455
|
self._parse_pmt(pay, pid)
|
|
481
456
|
|
|
482
457
|
def _pat_pid(self, pay, pid):
|
|
483
458
|
if pid == self.pids.PAT_PID:
|
|
484
459
|
self._parse_pat(pay)
|
|
485
460
|
|
|
486
|
-
def _sdt_pid(self,pay,pid):
|
|
461
|
+
def _sdt_pid(self, pay, pid):
|
|
487
462
|
if pid == self.pids.SDT_PID:
|
|
488
463
|
self._parse_sdt(pay)
|
|
489
464
|
|
|
@@ -7,8 +7,16 @@ print2, atohif, iso8601, red, blue
|
|
|
7
7
|
import datetime
|
|
8
8
|
from sys import stderr
|
|
9
9
|
|
|
10
|
-
ERR = (
|
|
11
|
-
|
|
10
|
+
ERR = (
|
|
11
|
+
LookupError,
|
|
12
|
+
ValueError,
|
|
13
|
+
OSError,
|
|
14
|
+
TypeError,
|
|
15
|
+
IndexError,
|
|
16
|
+
NameError,
|
|
17
|
+
AttributeError,
|
|
18
|
+
KeyError,
|
|
19
|
+
)
|
|
12
20
|
|
|
13
21
|
write2 = True
|
|
14
22
|
|
|
@@ -48,22 +56,22 @@ def clean(data):
|
|
|
48
56
|
clean strip and if it's a byte string
|
|
49
57
|
convert to a string
|
|
50
58
|
"""
|
|
51
|
-
if not isinstance(data,(str,bytes)):
|
|
59
|
+
if not isinstance(data, (str, bytes)):
|
|
52
60
|
return data
|
|
53
|
-
data=data.strip()
|
|
54
|
-
if isinstance(data,bytes):
|
|
61
|
+
data = data.strip()
|
|
62
|
+
if isinstance(data, bytes):
|
|
55
63
|
try:
|
|
56
|
-
data=data.decode()
|
|
64
|
+
data = data.decode()
|
|
57
65
|
except ERR:
|
|
58
66
|
pass
|
|
59
|
-
return
|
|
67
|
+
return data
|
|
60
68
|
|
|
61
69
|
|
|
62
70
|
def ishex(data):
|
|
63
71
|
"""
|
|
64
72
|
ishex determine if a string is a hex value.
|
|
65
73
|
"""
|
|
66
|
-
if isinstance(data,str):
|
|
74
|
+
if isinstance(data, str):
|
|
67
75
|
hexed = "0123456789abcdef"
|
|
68
76
|
data = data.lower().strip("0x")
|
|
69
77
|
return all([c in hexed for c in data])
|
|
@@ -76,10 +84,11 @@ def isjson(data):
|
|
|
76
84
|
is json.
|
|
77
85
|
"""
|
|
78
86
|
data = clean(data)
|
|
79
|
-
if data[0] in [
|
|
80
|
-
if data[-1] in [
|
|
87
|
+
if data[0] in ["{", b"{"]:
|
|
88
|
+
if data[-1] in ["}", b"}"]:
|
|
81
89
|
return True
|
|
82
|
-
return
|
|
90
|
+
return False
|
|
91
|
+
|
|
83
92
|
|
|
84
93
|
def isxml(data):
|
|
85
94
|
"""
|
|
@@ -87,10 +96,11 @@ def isxml(data):
|
|
|
87
96
|
is xml.
|
|
88
97
|
"""
|
|
89
98
|
data = clean(data)
|
|
90
|
-
if data[0] in [
|
|
91
|
-
if data[-1] in [
|
|
99
|
+
if data[0] in ["<", b"<"]:
|
|
100
|
+
if data[-1] in [">", b">"]:
|
|
92
101
|
return True
|
|
93
|
-
return
|
|
102
|
+
return False
|
|
103
|
+
|
|
94
104
|
|
|
95
105
|
def iso8601():
|
|
96
106
|
"""
|
|
@@ -10,10 +10,8 @@ from collections import deque
|
|
|
10
10
|
from operator import itemgetter
|
|
11
11
|
from .new_reader import reader
|
|
12
12
|
from .iframes import IFramer
|
|
13
|
-
from .stream import Stream
|
|
14
13
|
from .cue import Cue
|
|
15
14
|
from .stuff import print2, ERR
|
|
16
|
-
from .crc import crc32
|
|
17
15
|
from .bitn import NBin
|
|
18
16
|
from .commands import TimeSignal
|
|
19
17
|
from .sixfix import SixFix
|
|
@@ -142,18 +140,6 @@ class SuperKabuki(SixFix):
|
|
|
142
140
|
if isinstance(self.outfile, str):
|
|
143
141
|
self.outfile = open(self.outfile, "wb")
|
|
144
142
|
|
|
145
|
-
def pad_pkt(self, pkt):
|
|
146
|
-
"""
|
|
147
|
-
pad_pkt add padding to packets
|
|
148
|
-
"""
|
|
149
|
-
pad = b"\xff"
|
|
150
|
-
self._parse_pmt_header(pkt)
|
|
151
|
-
if self.pmt_payload is not None:
|
|
152
|
-
pkt = self.pmt_header + self.pmt_payload
|
|
153
|
-
pad_size = 188 - len(pkt)
|
|
154
|
-
pkt = pkt + (pad * pad_size)
|
|
155
|
-
return pkt
|
|
156
|
-
|
|
157
143
|
def auto_time_signals(self, pts, outfile):
|
|
158
144
|
"""
|
|
159
145
|
auto_time_signals auto add
|
|
@@ -177,11 +163,9 @@ class SuperKabuki(SixFix):
|
|
|
177
163
|
pid = self._parse_info(pkt)
|
|
178
164
|
if self._pusi_flag(pkt):
|
|
179
165
|
self._parse_pts(pkt, pid)
|
|
180
|
-
if pid in self.pids.pmt:
|
|
181
|
-
pkt = self.pad_pkt(pkt)
|
|
182
166
|
return pkt
|
|
183
167
|
|
|
184
|
-
def iframe_action(self,pkt,active):
|
|
168
|
+
def iframe_action(self, pkt, active):
|
|
185
169
|
"""
|
|
186
170
|
iframe_action this is what we do when we find an iframe.
|
|
187
171
|
"""
|
|
@@ -191,15 +175,14 @@ class SuperKabuki(SixFix):
|
|
|
191
175
|
self.load_sidecar(pts)
|
|
192
176
|
self.add_scte35_pkt(pts, active)
|
|
193
177
|
|
|
194
|
-
def mk_pmt(self,pay):
|
|
178
|
+
def mk_pmt(self, pay):
|
|
195
179
|
"""
|
|
196
180
|
mk_pmt generate PMT with the new SCTE-35 stream.
|
|
197
181
|
"""
|
|
198
|
-
pmt = PMT(pay
|
|
182
|
+
pmt = PMT(pay)
|
|
199
183
|
pmt.add_SCTE35stream(self.scte35_pid)
|
|
200
184
|
return pmt
|
|
201
185
|
|
|
202
|
-
|
|
203
186
|
def encode(self):
|
|
204
187
|
"""
|
|
205
188
|
encode parses the video input,
|
|
@@ -211,13 +194,13 @@ class SuperKabuki(SixFix):
|
|
|
211
194
|
self.open_output()
|
|
212
195
|
active = io.BytesIO()
|
|
213
196
|
pkt_count = 0
|
|
214
|
-
chunk_size =
|
|
197
|
+
chunk_size = 131
|
|
215
198
|
with self.outfile as outfile:
|
|
216
199
|
for pkt in self.iter_pkts():
|
|
217
200
|
pid = self._parse_pid(pkt[1], pkt[2])
|
|
218
201
|
pkt = self._parse_by_pid(pkt, pid)
|
|
219
202
|
if pkt:
|
|
220
|
-
self.iframe_action(pkt,active)
|
|
203
|
+
self.iframe_action(pkt, active)
|
|
221
204
|
active.write(pkt)
|
|
222
205
|
pkt_count = (pkt_count + 1) % chunk_size
|
|
223
206
|
if not pkt_count:
|
|
@@ -310,6 +293,7 @@ class SuperKabuki(SixFix):
|
|
|
310
293
|
self._bump_cc()
|
|
311
294
|
return nbin.bites
|
|
312
295
|
|
|
296
|
+
|
|
313
297
|
def cli():
|
|
314
298
|
"""
|
|
315
299
|
cli handles all the command line args
|
|
@@ -50,7 +50,7 @@ def mk_node(tag, line, exemel):
|
|
|
50
50
|
attrs = mk_attrs(line)
|
|
51
51
|
if ":" in tag:
|
|
52
52
|
ns, tag = tag.split(":", 1)
|
|
53
|
-
tag=tag.strip(
|
|
53
|
+
tag = tag.strip(">")
|
|
54
54
|
node = Node(tag, attrs=attrs, ns=ns)
|
|
55
55
|
if not exemel.startswith("<"):
|
|
56
56
|
node.value = exemel.split("<", 1)[0]
|
|
@@ -5,10 +5,11 @@ xml.py The Node class for converting to xml,
|
|
|
5
5
|
"""
|
|
6
6
|
|
|
7
7
|
from xml.sax.saxutils import escape, unescape
|
|
8
|
-
from .stuff import red
|
|
8
|
+
from .stuff import red
|
|
9
|
+
|
|
10
|
+
MAXCHILDREN = 128
|
|
11
|
+
MAXDEPTH = 64
|
|
9
12
|
|
|
10
|
-
MAXCHILDREN=128
|
|
11
|
-
MAXDEPTH= 64
|
|
12
13
|
|
|
13
14
|
def t2s(v):
|
|
14
15
|
"""
|
|
@@ -112,6 +113,9 @@ class NameSpace:
|
|
|
112
113
|
self.uri = uri
|
|
113
114
|
self.all = False
|
|
114
115
|
|
|
116
|
+
def __repr__(self):
|
|
117
|
+
return str(vars(self))
|
|
118
|
+
|
|
115
119
|
def prefix_all(self, abool=True):
|
|
116
120
|
"""
|
|
117
121
|
prefix_all takes a boolean
|
|
@@ -225,7 +229,7 @@ class Node:
|
|
|
225
229
|
"""
|
|
226
230
|
for child in self.children:
|
|
227
231
|
while self.depth > MAXDEPTH:
|
|
228
|
-
red(f
|
|
232
|
+
red(f"{self.depth} is too deep for SCTE-35 nodes.")
|
|
229
233
|
return False
|
|
230
234
|
child.depth = self.depth + 1
|
|
231
235
|
|
|
@@ -303,7 +307,7 @@ class Node:
|
|
|
303
307
|
set slot to insert at index slot.
|
|
304
308
|
"""
|
|
305
309
|
while len(self.children) > MAXCHILDREN:
|
|
306
|
-
red(f
|
|
310
|
+
red(f"{len(self.children)} is too many children")
|
|
307
311
|
return False
|
|
308
312
|
if not slot:
|
|
309
313
|
slot = len(self.children)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: threefive3
|
|
3
|
-
Version: 3.0.
|
|
3
|
+
Version: 3.0.43
|
|
4
4
|
Summary: SCTE-35 decoder and encoder with MPEGTS and HLS and XML support.
|
|
5
5
|
Home-page: https://github.com/superkabuki/threefive3
|
|
6
6
|
Author: Adrian of Doom
|
|
@@ -20,9 +20,11 @@ Description-Content-Type: text/markdown
|
|
|
20
20
|
License-File: LICENSE
|
|
21
21
|
|
|
22
22
|
[__Install__](#install) |[__SCTE-35 Cli__](#the-cli-tool) | [__SCTE-35 HLS__](https://github.com/superkabuki/threefive3/blob/main/hls.md) | [__Cue__ Class](https://github.com/superkabuki/threefive3/blob/main/cue.md) | [__Stream__ Class](https://github.com/superkabuki/threefive3/blob/main/stream.md) | [__Online SCTE-35 Parser__](https://iodisco.com/scte35) | [__Encode SCTE-35__](https://github.com/superkabuki/threefive3/blob/main/encode.md) | [__SCTE-35 Examples__](https://github.com/superkabuki/threefive3/tree/main/examples)
|
|
23
|
-
| [__SCTE-35 XML__](https://github.com/superkabuki/SCTE-35/blob/main/xml.md)
|
|
23
|
+
| [__SCTE-35 XML__](https://github.com/superkabuki/SCTE-35/blob/main/xml.md)
|
|
24
|
+
|
|
25
|
+
|
|
24
26
|
|
|
25
|
-
# threefive3 is
|
|
27
|
+
# threefive3 is ready.
|
|
26
28
|
✅ SCTE-35 __Parser__ ✅ SCTE-35 __Encoder__ ✅ SCTE-35 __HLS__ ✅ SCTE-35 __Xml+binary__ ✅ SCTE-35 __Cli__ ✅ SCTE-35 __library__
|
|
27
29
|
|
|
28
30
|
|
|
@@ -32,20 +34,40 @@ License-File: LICENSE
|
|
|
32
34
|
* Automatic AES decryption for HLS.
|
|
33
35
|
* All HLS __SCTE-35__ Tags are Supported.
|
|
34
36
|
|
|
35
|
-
# Heads up.
|
|
37
|
+
# Heads up, I'm about to push v3.0.43
|
|
36
38
|
<pre>
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
Q.
|
|
40
|
+
Why the release?
|
|
41
|
+
|
|
42
|
+
A.
|
|
43
|
+
I made a mistake with the xml method in the Cue class. I intended it to return a node instance,
|
|
44
|
+
but instead I had it return just the xml output of a Node instance, not a big deal really,
|
|
45
|
+
but everything else returns a node instance from their xml() method, Cue should too..
|
|
46
|
+
I don't want people getting used to it not return a Node instance.
|
|
47
|
+
v3.0.43 fixes Cue.xml() to return a Node instance.
|
|
48
|
+
I also added more autodetection of SCTE-35 Formats to the Cue class,
|
|
49
|
+
no other SCTE-35 software can do even half of these.
|
|
50
|
+
Base64,
|
|
51
|
+
Bytes,
|
|
52
|
+
Dicts,
|
|
53
|
+
MPEGTS SCTE-35 packets,
|
|
54
|
+
Hex (literal and string),
|
|
55
|
+
Integers (literal, bytestring,and string),
|
|
56
|
+
JSON(strings and bytestrings),
|
|
57
|
+
XML(string and bytestring)
|
|
58
|
+
XML+Binary(string and bytestring)
|
|
59
|
+
|
|
60
|
+
I brought in the PMT module,that really cleans SixFix and SuperKabuki up a lot.
|
|
61
|
+
SuperKabuki is now a subclass of SixFix instead of the Stream class, that gets rid of a lot
|
|
62
|
+
of redundant code.
|
|
42
63
|
|
|
43
|
-
|
|
44
|
-
|
|
64
|
+
The Super Kabuki MPEGTS SCTE-35 Packet Injection Engine is working really really well.
|
|
65
|
+
I've tested the SuperKabuki output with ffmpeg and tsduck and everything works.
|
|
66
|
+
It's workinng perfectly for me, so I want to get it out there and see if y'all break it. :)
|
|
45
67
|
</pre>
|
|
46
68
|
|
|
47
69
|
|
|
48
|
-
# Latest release is v3.0.
|
|
70
|
+
# Latest release is v3.0.43
|
|
49
71
|
_Released Thursday April 18th, 2025
|
|
50
72
|
* just 4300 lines of code.
|
|
51
73
|
* cyclomatic complexity __2.05__
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|