SCTE35 Parser




The SCTE (Society of Cable Telecommunications Engineers) defines the SCTE-35 as "SCTE 35, Digital Program Insertion Cueing Message for Cable, is the core signaling standard for advertising and distribution control (ex. blackouts) of content for content providers and content distributors" 
SCTE-35 CUEs are signals that can be used to identify AD breaks, program chapters etc in a VOD, DVR or live streams contents. While creating the original content, encoders uses SCTE-104 messages to insert appropriate SCTE-35 info in the stream. This usually will be packaged as separate stream with other video, audio streams. The downstream packager can use this info to create appropriate SCTE-35 CUEs on the end user metadata, for example HLS manifest, DASH manifest etc. 

Sample manifest with SCTE-35 cues:
#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:3
#EXT-X-MEDIA-SEQUENCE:00001
http://server-host/path/file44.ts
http://server-host/path/file45.ts 
SCTE 35 2016
SCTE STANDARD ©SCTE 72
#EXT-XSCTE35:TYPE=0x50,TIME=1448946000000,ELAPSED=1761450000,ID=”e+CuqIu3T3i7RFoDiXxENA==”,CUE=”/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==”
#EXT-XSCTE35:TYPE=0x10,TIME=1450707450000,ELAPSED=0,ID=”dAQpTUaQSjOti/JZTqECfQ==”, CUE=”/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==” stream_med_00001.ts
stream_med_00002.ts
#EXT-XSCTE35:TYPE=0x34,TIME=1450708822000,ELAPSED=0,ID=”f6CUQbSqRD+sfOFQxTUrRg==”,CUE=”/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==”
#EXT-XSCTE35:TYPE=0x30,TIME=1450708822000,ELAPSED=0,ID=”QXF5YnniR7alG+ELdulgqQ==”,CUE=”/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==”
stream_med_00003.ts
#EXT-XSCTE35:TYPE=0x31,TIME=1450708882000,ID=”+3yg9xvWQeCSJgsYEqO94w==”,CUE=”/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==”
#EXT-XSCTE35:TYPE=0x36,TIME=1450708882000,ELAPSED=0,ID=”4Ylv5+DZR0m5srzPw6Bp7w==”,CUE=”/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==”
#EXT-XSCTE35:TYPE=0x30,TIME=1450708882000,ELAPSED=0,ID=”LUqmr5C6R4uBDGfyEHvDrw==”,CUE=”/DAIAAAAAAAAAAAQAAZ/I0VniQAQAgBDVUVJQAAAAH+cAAAAAA==”
stream_med_00004.ts
stream_med_00005.ts
stream_med_00006.ts


The hex form of a data from the encoder output will look like as follows.
00000000: fc30 2000 0000 0000 0000 fff0 0f05 0000  .0 .............
00000010: 0000 7fcf ffa7 f7ab d400 6800 0100 0088  ..........h.....
00000020: f3eb af ...

A JavaScript based SCTE-35 parser is created here to parse the data with command_type is splice_insert. This will provide info about the AD break signals in the content stream.

Code repository: https://github.com/hmanikkothu/SCTE35-Parser

This is a helper file to parse the SCTE-35 data in the form of a hex string (usually extracted from the mpeg stream from the encoder / packager), or in the form of base64 encoded string (in HLS manifests)

Sample usage:

var parser = new SCTE35Parser()
var testString = 'fc302000000000000000fff00f05000000007fcfffa7f7abd400680001000088f3ebaf';
var spliceInfo = this.parseFromHex(testString);
console.log(JSON.stringify(spliceInfo));


// Sample output
{
  "table_id": 252,
  "section_syntax_indicator": 0,
  "private_indicator": 0,
  "section_length": 32,
  "protocol_version": 0,
  "encrypted_packet": 0,
  "encryption_algorithm": 0,
  "pts_adjustment": 0,
  "cw_index": 0,
  "tier": 4095,
  "splice_command_length": 15,
  "splice_command_type": 5,
  "splice_command_type_text": "splice_insert",
  "splice_event": {
    "splice_event_id": 0,
    "splice_event_cancel_indicator": 0,
    "out_of_network_indicator": 1,
    "program_splice_flag": 1,
    "duration_flag": 0,
    "splice_immediate_flag": 0,
    "time_specified_flag": 1,
    "pts_time": 7112993748,
    "unique_program_id": 104,
    "avail_num": 0,
    "avails_expected": 1
  },
  "descriptor_loop_length": 0,
  "descriptors": []
}

Comments

Popular posts from this blog

Dijkstra's Algorithm in JavaScript