Understanding HLS Interstitials and EXT-X-DISCONTINUITY in Ad Insertion

on 20 February 2025 AD INSERTION, Apple HTTP Live Streaming, HLS, JMETER, JMETER-PLUGINS, PERFORMANCE, VIDEO and Tags: , , , , , , , , with 0 comments

www.freepik.com

Ad insertion

Ad insertion in video streaming refers to the process of dynamically inserting advertisements into video content during playback.

This technique, widely used in both live and on-demand video streaming, allows content providers to generate revenue by displaying targeted ads to viewers.

This is a primary source of income for many streaming services, especially those offering free or ad-supported content.

How video streaming works / lexicon

In the rest of this blog we’ll be using the terms player and server, this section will explain roughly how a video is played.

To play a video you need 2 things:

  • a server that will produce a stream containing the information needed for playback (URL of the video chunks to be played, order of the video chunks, etc…)
  • a player that will retrieve the video chunks and interpret them in order to put them end to end to get the whole video

With streaming, the user doesn’t have to download the video to his device (Smartphone, Smart TV, Laptop, etc…) to play it.

Ad insertion technologies

In the previous blog we discussed the concept of SSAI (Server Side Ad Insertion), which works like the following:

The addition of the ad is managed by STCE-35 markers which are sent as chunks upstream. The origin will process the SCTE-35 markers to communicate with the ad server using SCTE-30. It is the origin which replaces the content in the manifest according to the response from the ad server.

An alternative way to insert Ads is based on CSAI (Client Side Ad Insertion). In this latter case, the player makes a request to the ad server, which then sends back a response containing the ad. The player is in charge of ad management.

Pros and cons of SSAI:

ProsCons
Smooth Playback: SSAI allows for seamless transitions between content and adsCost : SSAI requires significant server resources for real-time ad stitching
Ad Blocker Resistance : since ads are integrated into the video stream on the server side, it is harder for Ad Blocker to do their workServer implementation : server needs to add advertising at the right time
Client implementation : no specific implementation is needed on client sideClient control : the logic is server-side – the client has no knowledge of the ads, so it is harder to tailor the ads for the customer

Pros and cons of CSAI:

ProCon
Client control : The client can dynamically request and insert ads based on real-time user behavior and contextAd Blocker Resistance : CSAI is more vulnerable to ad blockers, which can intercept and block ad requests made by the client
Personalization : The client can send user-specific data (e.g., location, preferences) to the ad server to request targeted adsUser experience : Ads may have different encoding parameters than the main content, leading to variations in quality and potential playback issues
Cost: No specific treatment is needed on server sideClient implementation : the player must implements the logic for calling ad servers

SSAI vs CSAI

NotionCSAISSAI
How ads are addedCalls the ad server to retrieve chunksServers add chunks directly into the manifest
Content personalizationCall made by the player possibility of transmitting customer information to the ad serverCall made by the server, player must send information for ads personalization
Ad blockersPossible to block adsAds blocker-resistan
CostNo expensive cost because treatment is made by the playerCost more important than CSAI because server dynamically inserting ads into the video stream before delivering it to the client

To mitigate the pros/cons of those 2 approaches, a new kid on the block has entered the game called SGAI (Sever-Guided Ad Insertion).

In SGAI, the player manages ad insertion, but the server adds indications in the manifests to inform it of ad insertion.
With SGAI, if the player does not wish to parse the ads break information, it can simply ignore it and continue playback.

SGAI is more resistant to ad blockers than CSAI only if the ASSET-LIST or ASSET-URI attribute contains a URL to the server. If the URL redirects to a different URL (e.g. https://interstitials.mediatailor.eu-west-1.amazonaws.com/) then SGAI content is likely to be blocked.

The following diagram summarizes the differences between SSAI and SGAI.

Ads insertion with HLS

This blog will focus on Ad Insertion with HLS.

HLS is a technology developed by apple and used for video streaming (LIVE or VOD), it is compatible with the following types of device iOS, macOS, and Android-and every major browser and is used by platforms like twitch.

From https://developer.apple.com/streaming/ :

Send live and on‐demand audio and video to Apple devices and PCs with HTTP Live Streaming (HLS) technology from Apple. Using the same protocol that powers the web, HLS lets you deploy content using ordinary web servers and content delivery networks. HLS is designed for reliability and dynamically adapts to network conditions by optimizing playback for the available speed of wired and wireless connections.

If we want to sum up HLS in a basic way, it’s a technology that splits a video into small videos called chunks, which are referenced in a file called a manifest in m3u8 format.

HLS lets you add Ads into streaming in 2 different ways:

  • The old way using EXT-X-DISCONTINUITY
  • The new way using HLS Interstitials

EXT-X-DISCONTINUITY

In the context of advertising within HTTP Live Streaming (HLS), the EXT-X-DISCONTINUITY tag is used to signal transitions between different types of content, such as switching from primary content to an advertisement and back to the primary content.

This is important for ensuring that the player can handle these transitions smoothly, especially when there are differences in encoding parameters, timestamps, or other characteristics between the main content and the ads.

Use of EXT-X-DISCONTINUITY in Advertising

  • Switching Between Content and Ads: When an ad break is inserted into the main/primary content, the EXT-X-DISCONTINUITY tag is used to signal the start and end of the ad break. This helps the player reset its state and handle any differences in encoding or timestamps.

  • Handling Different Encoding Parameters: Ads may be encoded differently from the main content (e.g., different codecs, bitrates, or resolutions). The EXT-X-DISCONTINUITY tag informs the player that it needs to reinitialize its decoder to handle the new encoding parameters.

  • Managing Timestamps: There may be discontinuities in the media timestamps when switching between content and ads. The EXT-X-DISCONTINUITY tag helps the player manage these timestamp changes and maintain smooth playback.

  • Seamless Playback: By using the EXT-X-DISCONTINUITY tag, content providers can ensure that the transition between content and ads is seamless, providing a better viewing experience for users.

Before the addition of HLS interstitial, EXT-X-DISCONTINUITY tag was used to insert ads into a manifest, this tag is used to determine a difference in one of the following points :

  • file format
  • number, type, and identifiers of tracks
  • timestamp sequence
  • encoding parameters
  • encoding sequence

This tag can be used to manage the transition between two different types of content, here’s an example of a manifest with an 18-second ad starting after chunk principalChunk4:

#EXTM3U
#EXT-X-TARGETDURATION:10
#EXT-X-VERSION:4
#EXT-X-MEDIA-SEQUENCE:0
#EXTINF:10.0,
principalChunk1.ts
#EXTINF:10.0,
principalChunk2.ts
#EXTINF:10.0,
principalChunk3.ts
#EXTINF:10.0,
principalChunk4.ts
#EXT-X-DISCONTINUITY
#EXTINF:10.0,
adChunk1.ts
#EXTINF:8.0,
adChunk2.ts
#EXT-X-DISCONTINUITY
#EXTINF:10.0,
principalChunk5.ts
#EXTINF:10.0,
principalChunk6.ts

Interstitials

Improvements over EXT-X-DISCONTINUITY

With EXT-X-DISCONTINUITY, the sub-content chunks are already present in the manifest, so they’re not personalized for the user.


With interstitials, it’s possible to have a playback session, so the user doesn’t see the same ad at every break. Interstitial attributes allow you to do more than discontinuity :

  • return to live before the end: Ensuring important Live events are not missed
  • playback obligation: Ensuring ads cannot be skipped by users
  • transitions: Ensuring smoother switches between ads and primary content
  • etc…

History

Below is a diagram of interstitial’s history

Definition

Interstitial is a new class equals to “com.apple.hls.interstitial” of EXT-X-DATERANGE tag added by Apple in 2021 to handle the addition of sub-content within main content.
A sub-content can be an ad or a presentation of an article during a conference or any other content that is different from the main content.

HLS Interstitials use ad markers (EXT-X-DATERANGE tags) to indicate where sub-content should be inserted.
These markers provide metadata about the ad break, such as its duration or URL.

HLS Interstitials allow for the dynamic insertion of VOD sub-content into a live or on-demand stream without requiring changes to the main playlist.

This enables more flexible and targeted ad delivery.

Principle

To summarize interstitials, the player must call another manifest in order to retrieve chunks not present in the main content playlist and which correspond to something else (ad, article presentation, video recorded before a presentation, etc.).
It must read these new chunks from a date defined in the EXT-X-DATERANGE tag.
When returning to the main content, it may have to ignore certain chunks.
For example, in live broadcasts, the sub-content completely replaces the main content, whereas in VOD it’s an add-on (e.g. ads on YouTube or streaming platforms).

Attributs in common for all EXT-X-DATERANGE classes

  • ID : the unique identifier as string
  • CLASS : the date range class which allows for special treatment
  • START-DATE : ISO_8601 date/time at which the Date Range begins
  • CUE : containing 2 possible values PRE (should be played before principal content) or POST (should be played after principal content) which determines when the date change should be played or ONCE (sub content read only once)
  • END-DATE : ISO_8601 date/time at which the Date Range ends
  • DURATION : the duration of the date range in seconds
  • PLANNED-DURATION : the expected duration in seconds if duration is not yet know

Attributs only for interstitials

  • X-ASSET-URI : URL to the sub-content manifest
  • X-ASSET-LIST : URL to a json containing the sub-contents
  • X-RESUME-OFFSET : offset to be performed in seconds after sub-content playback, to ignore certain chunks for a live stream. In most cases it is equal to 0 in VOD and the duration of the sub-content in LIVE.
  • X-PLAYOUT-LIMIT : sub-content playback must stop after X-PLAYOUT-LIMIT seconds, even if this value is less than the sub-content duration
  • X-SNAP : used to adjust the start and end date of the sub-content
  • X-RESTRICT : used to manage mandatory sub-content playback (SKIP) or to modify sub-content playback speed (JUMP). In the case of skip, it forces the user to watch the ad and not be able to skip it

X-SNAP

The X-SNAP attributs can adjust start and end dates to align with segment boundaries, reducing playback interruptions and manage clock drifting.

IF X-SNAP contains OUT then the start date must be changed to the end date of the nearest segment, iF X-SNAP contains IN then the end date must be modified to use the start end date of the segment closest to the end.

It’s possible to have a sub-content start date in the middle of a main content chunk if there is a difference between the packager and the encoder clock.

Query parameters

  • _HLS_interstitial_id : must be present for X-ASSET-LIST and X-ASSET-URI calls and the value corresponding to date range id. From the RFC documentation “This supports interoperability between content producers and decisioning servers”
  • _HLS_start_offset : must be present for X-ASSET-LIST calls, if reading is started during sub-content, calculate the offset between the interstitial start and now. This parameter allows the server to adapt the json content according to the offset in seconds

Examples

X-ASSET-LIST
{
    "ASSETS": [
        {
            "DURATION": 10,
            "URI": "https://example.com/manifest_ads_1.m3u8"
        },
        {
            "DURATION": 3,
            "URI": "https://example.com/manifest_ads_2.m3u8"
        }
    ],
}

Manifest

#EXTM3U
#EXT-X-TARGETDURATION:6
#EXT-X-PROGRAM-DATE-TIME:2020-01-02T21:55:40.000Z
#EXTINF:6,
main1.0.ts
#EXTINF:6,
main1.1.ts
#EXTINF:6,
main1.2.ts
#EXT-X-ENDLIST
#EXT-X-DATERANGE:ID="ad1",CLASS="com.apple.hls.interstitial",START-DATE="2020-01-02T21:55:46.000Z",DURATION=15.0,X-ASSET-URI="http://example.com/ad1.m3u8",X-RESUME-OFFSET=0 X-RESTRICT="SKIP,JUMP"

The previous manifest corresponds to a manifest with sub-content that cannot be skipped and that starts after the main1.0.ts chunk, resume offset equals 0 so no chunks must be ignored.

#EXTM3U
#EXT-X-TARGETDURATION:7
#EXT-X-VERSION:10
#EXT-X-MEDIA-SEQUENCE:6491349
#EXT-X-PROGRAM-DATE-TIME:2025-02-04T14:26:24+01:00
#EXTINF:6,
https://example.com/4.m4s
#EXTINF:6,
https://example.com/5.m4s
#EXTINF:6,
https://example.com/6.m4s

#EXT-X-DATERANGE:ID="ad1",CLASS="com.apple.hls.interstitial",START-DATE="2025-02-04T14:27:38.000Z",DURATION=30.0,X-ASSET-URI="https://example.com/ads.m3u8?_HLS_interstitial_id=ad1",CUE="PRE,ONCE",X-RESTRICT="SKIP,JUMP",X-RESUME-OFFSET=0 

The previous manifest corresponds to a manifest with sub-content that must be read before starting the main content

Interstitials vs EXT-X-DISCONTINUITY

Interstitials and EXT-X-DISCONTINUITY may seem similar at first glance, but they serve different purposes in the context of HTTP Live Streaming (HLS).
With EXT-X-DISCONTINUITY, the sub-content chunks are already present in the manifest, whereas with interstitials it’s the player that parses and processes them.

What’s next

This feature will be available in a future release of our Tool for performance testing Video Streaming.
A new blog will be available when this release is available.

About UbikLoadPack :

Ubik Load Pack Streaming Solution features

You’ll probably also like: