101: How to Create SCTE 35 & 224 Markers for HLS, JSON, XML, Python, JavaScript, & Ruby

To create SCTE markers for DAI (Dynamic Ad Insertion) for live streaming, you can use a variety of scripting languages and tools. Here are a few examples:

SCTE-35 is a standard for signaling ad insertion opportunities in live streams. It uses MPEG-2 Transport Stream packets to insert “cue” messages that indicate the start and end of ad breaks. To create SCTE-35 markers, you can use tools like SCTE-35 Commander or SCTE-35 Injector. These tools allow you to create SCTE-35 messages and insert them into your live stream.

1. HLS: HLS (HTTP Live Streaming) is a streaming protocol that allows for dynamic ad insertion in live streams. To create SCTE markers for HLS, you can use the EXT-X-CUE-OUT and EXT-X-CUE-IN tags. These tags indicate the start and end of an ad break and can be used to trigger the insertion of ad content. Here is an example of an HLS manifest with SCTE markers:

“`m3u8
#EXTM3U
#EXT-X-VERSION:3
#EXT-X-TARGETDURATION:10
#EXT-X-MEDIA-SEQUENCE:0
#EXT-X-CUE-OUT:DURATION=30
#EXTINF:10.0,
https://example.com/live/stream_720p/chunk_00001.ts
#EXTINF:10.0,
https://example.com/live/stream_720p/chunk_00002.ts
#EXT-X-CUE-IN
#EXTINF:10.0,
https://example.com/live/ad_720p/chunk_00001.ts
#EXTINF:10.0,
https://example.com/live/ad_720p/chunk_00002.ts
#EXT-X-CUE-OUT:DURATION=30
#EXTINF:10.0,
https://example.com/live/stream_720p/chunk_00003.ts
#EXTINF:10.0,
https://example.com/live/stream_720p/chunk_00004.ts
#EXT-X-CUE-IN
#EXTINF:10.0,
https://example.com/live/ad_720p/chunk_00003.ts
#EXTINF:10.0,
https://example.com/live/ad_720p/chunk_00004.ts
#EXT-X-ENDLIST
“`

In this example, the SCTE markers are represented by the EXT-X-CUE-OUT and EXT-X-CUE-IN tags. These tags indicate the start and end of an ad break, and the ad content is inserted between them.

2. JSON: SCTE-224 is a standard for signaling ad breaks in live streams using JSON metadata. To create SCTE markers using SCTE-224, you can use tools like the SCTE-224 Event Scheduler or the SCTE-224 Event Injector. These tools allow you to create JSON metadata that signals the start and end of ad breaks in your live stream.

3. XML: Like JSON, SCTE-224 also supports XML metadata for signaling ad breaks in live streams. You can use XML tags to specify the start and end of ad breaks and other metadata. For example:

“`xml
<ADI>
<Asset>
<Metadata>
<SCTE35>
<SpliceInfoSection>
<SpliceInsert>
<SpliceEvent>
<SpliceEventId>12345</SpliceEventId>
<SpliceOutOfNetworkIndicator>false</SpliceOutOfNetworkIndicator>
<SpliceImmediateFlag>true</SpliceImmediateFlag>
<BreakDuration>30000</BreakDuration>
</SpliceEvent>
</SpliceInsert>
</SpliceInfoSection>
</SCTE35>
</Metadata>
</Asset>
</ADI>
“`

In this example, an SCTE-35 splice event is specified using XML tags within an Asset Description and Metadata Interface (ADI) file.

4. Python: You can also use Python scripts to generate SCTE-35 messages for DAI. For example, the SCTE-35 Python library allows you to create SCTE-35 messages using Python code. Here’s an example Python script that creates an SCTE-35 message:

“`python
from scte35 import SpliceInfoSection, SpliceInsert

splice_event = SpliceInsert(
splice_event_id=12345,
out_of_network=False,
immediate=True,
break_duration=30
)

splice_info_section = SpliceInfoSection(
splice_insert=splice_event
)

scte35_message = splice_info_section.to_bytes()
“`

This script creates a splice event with ID 12345, a break duration of 30 seconds, and other parameters, and then generates an SCTE-35 message using the scte35 library.

5. JavaScript: If you’re working with web-based live streaming technologies like HLS or DASH, you can use JavaScript to manipulate the manifest files and insert SCTE markers. For example, you could use JavaScript to modify the EXT-X-CUE-OUT and EXT-X-CUE-IN tags in an HLS manifest file to indicate ad breaks.

6. Ruby: Ruby is another scripting language that can be used to generate SCTE-35 messages for DAI. The SCTE35 gem is a Ruby library that allows you to create and parse SCTE-35 messages. Here’s an example Ruby script that creates an SCTE-35 message:

“`ruby
require ‘scte35’

splice_event = SCTE35::SpliceInsert.new(
splice_event_id: 12345,
out_of_network: false,
immediate: true,
break_duration: 30
)

splice_info_section = SCTE35::SpliceInfoSection.new(
splice_insert: splice_event
)

scte35_message = splice_info_section.to_binary_s
“`

This script creates a splice event using the SCTE35 gem, sets its parameters, and generates an SCTE-35 binary message.

Overall, the choice of scripting language and tool depends on the specific requirements of your live streaming setup. These examples show some common options for creating SCTE markers for DAI in live streaming.