Closed wabiloo closed 2 months ago
Here's the thing, USE threefive to encode! Why are you using tsduck?
Segmentation descriptors have UPIDs, that is kind of the point.Declare a UPID, but make it zero length,, I believe that will work. Give me a little while, and I'll do one for you.
Here you go
jason ='''{
"info_section": {
"table_id": "0xfc",
"section_syntax_indicator": false,
"private": false,
"sap_type": "0x03",
"sap_details": "No Sap Type",
"section_length": 59,
"protocol_version": 0,
"encrypted_packet": false,
"encryption_algorithm": 0,
"pts_adjustment_ticks": 1004614680,
"pts_adjustment": 11162.385333,
"cw_index": "0x00",
"tier": "0x0fff",
"splice_command_length": 5,
"splice_command_type": 6,
"descriptor_loop_length": 37,
"crc": "0x592280ed"
},
"command": {
"command_length": 5,
"command_type": 6,
"name": "Time Signal",
"time_specified_flag": true,
"pts_time": 58.52,
"pts_time_ticks": 5266800
},
"descriptors": [
{
"tag": 2,
"descriptor_length": 35,
"name": "Segmentation Descriptor",
"identifier": "CUEI",
"segmentation_event_id": "0x02",
"segmentation_event_cancel_indicator": false,
"segmentation_event_id_compliance_indicator": true,
"program_segmentation_flag": true,
"segmentation_duration_flag": true,
"delivery_not_restricted_flag": false,
"web_delivery_allowed_flag": true,
"no_regional_blackout_flag": false,
"archive_allowed_flag": false,
"device_restrictions": "Restrict Group 1",
"segmentation_duration": 120.04,
"segmentation_duration_ticks": 10803600,
"segmentation_message": "Break Start",
"segmentation_upid_type": 18,
"segmentation_upid_type_name": "Unknown",
"segmentation_upid_length": 0,
"segmentation_upid": "",
"segmentation_type_id": 34,
"segment_num": 0,
"segments_expected": 0,
"sub_segment_num": 0,
"sub_segments_expected": 0
}
]
}'''
from threefive import Cue
cue=Cue()
cue.load(jason)
cue.encode()
cue.show()
print(cue.encode_as_hex())
You can omit the info secrtion, if you have a pts adjustment, it's just as easy to add it to the time signal
jason ='''{
"command": {
"command_type": 6,
"name": "Time Signal",
"time_specified_flag": true,
"pts_time_ticks": 1009881480
},
"descriptors": [
{
"tag": 2,
"name": "Segmentation Descriptor",
"identifier": "CUEI",
"segmentation_event_id": "0x02",
"segmentation_event_cancel_indicator": false,
"segmentation_event_id_compliance_indicator": true,
"program_segmentation_flag": true,
"segmentation_duration_flag": true,
"delivery_not_restricted_flag": false,
"web_delivery_allowed_flag": true,
"no_regional_blackout_flag": false,
"archive_allowed_flag": false,
"device_restrictions": "Restrict Group 1",
"segmentation_duration": 120.04,
"segmentation_duration_ticks": 10803600,
"segmentation_message": "Break Start",
"segmentation_upid_type": 18,
"segmentation_upid_type_name": "Unknown",
"segmentation_upid_length": 0,
"segmentation_upid": "",
"segmentation_type_id": 34,
"segment_num": 0,
"segments_expected": 0,
"sub_segment_num": 0,
"sub_segments_expected": 0
}
]
}'''
from threefive import Cue
cue=Cue()
cue.load(jason)
cue.encode()
cue.show()
print(cue.encode_as_hex())
a@slow:~/cuei$ python3 ../load.py
{
"info_section": {
"table_id": "0xfc",
"section_syntax_indicator": false,
"private": false,
"sap_type": "0x03",
"sap_details": "No Sap Type",
"section_length": 44,
"protocol_version": 0,
"encrypted_packet": false,
"encryption_algorithm": 0,
"pts_adjustment_ticks": 0,
"cw_index": "0x0",
"tier": "0xfff",
"splice_command_length": 5,
"splice_command_type": 6,
"descriptor_loop_length": 22,
"crc": "0x3d698a6b"
},
"command": {
"command_length": 5,
"command_type": 6,
"name": "Time Signal",
"time_specified_flag": true,
"pts_time": 11220.905333,
"pts_time_ticks": 1009881480
},
"descriptors": [
{
"tag": 2,
"descriptor_length": 20,
"name": "Segmentation Descriptor",
"identifier": "CUEI",
"segmentation_event_id": "0x02",
"segmentation_event_cancel_indicator": false,
"segmentation_event_id_compliance_indicator": true,
"program_segmentation_flag": true,
"segmentation_duration_flag": true,
"delivery_not_restricted_flag": false,
"web_delivery_allowed_flag": true,
"no_regional_blackout_flag": false,
"archive_allowed_flag": false,
"device_restrictions": "Restrict Group 1",
"segmentation_duration": 120.04,
"segmentation_duration_ticks": 10803600,
"segmentation_message": "Break Start",
"segmentation_upid_type": 18,
"segmentation_upid_type_name": "Unknown",
"segmentation_upid_length": 0,
"segmentation_upid": "",
"segmentation_type_id": 34,
"segment_num": 0,
"segments_expected": 0,
"sub_segment_num": 0,
"sub_segments_expected": 0
}
]
}
0xfc302c00000000000000fff00506fe3c3191880016021443554549000000027fd10000a4d99012002200003d698a6b
threefive will create an info section for you and it also figures out the Command length and Descriptor length for you,, if you have values there ,it will correct them, same with the crc32.
Media Package is Amazon , right? Those cats are super cool, they use threefive. Me and tunein.com, and NBC and Amazon all had a meeting back in December to make sure we were all in sync doing SCTE-35 stuff, this is actually one of topics we discussed, how to handle this very situation.
The reason I'm using tsduck is that I'm preparing a TS file with embedded SCTE message, which is used as a source in MediaLive -> MediaPackage -> our SSAI solution. To check how our solution reacts to various scenarios. I use tsduck out of habit for the TS preparation. I then use threefive alongside to check what the output of MediaPackage is and what was the input to our solution.
Furthermore I believe that tsduck had inserted a UPID of length 0. Was that not the case?
Don't get me wrong, I like tsduck, but there is a lot of room for interpretation in the SCTE-35 spec, and the SCTE-35 xml fields aren't the same as the SCTE-35 data fields, which baffles me. I don't understand that logic at all.
I don't usually have compatibility issues with tsduck,
I think the xml doesn't have upid length.
the proper way to not have a upid is to set the upid type to 0 and upid length to 0 , which works with threefive.
I forgot until I looked it up.
if you would have specified upid type 0 and upid length 0 , it would have parsed correctly.
jason ='''{
"command": {
"command_type": 6,
"name": "Time Signal",
"time_specified_flag": true,
"pts_time_ticks": 1009881480
},
"descriptors": [
{
"tag": 2,
"name": "Segmentation Descriptor",
"identifier": "CUEI",
"segmentation_event_id": "0x02",
"segmentation_event_cancel_indicator": false,
"segmentation_event_id_compliance_indicator": true,
"program_segmentation_flag": true,
"segmentation_duration_flag": true,
"delivery_not_restricted_flag": false,
"web_delivery_allowed_flag": true,
"no_regional_blackout_flag": false,
"archive_allowed_flag": false,
"device_restrictions": "Restrict Group 1",
"segmentation_duration": 120.04,
"segmentation_duration_ticks": 10803600,
"segmentation_message": "Break Start",
"segmentation_upid_type": 0,
"segmentation_upid_length": 0,
"segmentation_type_id": 34,
"segment_num": 0,
"segments_expected": 0,
"sub_segment_num": 0,
"sub_segments_expected": 0
}
]
}'''
from threefive import Cue
cue=Cue()
cue.load(jason)
cue.encode()
cue.show()
print(cue.encode_as_hex())
{ "info_section": { "table_id": "0xfc", "section_syntax_indicator": false, "private": false, "sap_type": "0x03", "sap_details": "No Sap Type", "section_length": 44, "protocol_version": 0, "encrypted_packet": false, "encryption_algorithm": 0, "pts_adjustment_ticks": 0, "cw_index": "0x0", "tier": "0xfff", "splice_command_length": 5, "splice_command_type": 6, "descriptor_loop_length": 22, "crc": "0x2ca14b7d" }, "command": { "command_length": 5, "command_type": 6, "name": "Time Signal", "time_specified_flag": true, "pts_time": 11220.905333, "pts_time_ticks": 1009881480 }, "descriptors": [ { "tag": 2, "descriptor_length": 20, "name": "Segmentation Descriptor", "identifier": "CUEI", "segmentation_event_id": "0x02", "segmentation_event_cancel_indicator": false, "segmentation_event_id_compliance_indicator": true, "program_segmentation_flag": true, "segmentation_duration_flag": true, "delivery_not_restricted_flag": false, "web_delivery_allowed_flag": true, "no_regional_blackout_flag": false, "archive_allowed_flag": false, "device_restrictions": "Restrict Group 1", "segmentation_duration": 120.04, "segmentation_duration_ticks": 10803600, "segmentation_message": "Break Start", "segmentation_upid_type": 0, "segmentation_upid_length": 0, "segmentation_type_id": 34, "segment_num": 0, "segments_expected": 0, "sub_segment_num": 0, "sub_segments_expected": 0 } ] }
0xfc302c00000000000000fff00506fe3c3191880016021443554549000000027fd10000a4d99000002200002ca14b7d
Hi there,
Another one not parsed by threefive, extracted from a MediaPackage stream: 0xFC302C00000003289800FFF005068000F528F000160214435545490000000100D100002932E00C002200006349D893.
It has a 0x22 BreakStart descriptor with empty UPID (tsduck did not let me insert one without a UPID)