Insert ads using segment redirect

  • This guide details how to configure your manifest manipulator to request ad or slate segments using the ad pod segment method.

  • Prerequisites include setting up a livestream event for Pod serving redirect DAI type and encoding profiles via Ad Manager UI or API.

  • You need to retrieve the content stream, identify ad break segments using EXT-X-CUE-IN and EXT-X-CUE-OUT tags, and replace them with EXT-X-DISCONTINUITY elements.

  • Generating a HMAC token is necessary for authentication of segment requests, requiring gathering specific parameters like custom asset key, network code, and pod ID.

  • Finally, build ad segment URLs to replace content segments between EXT-X-DISCONTINUITY tags, pointing to the ad pod segment method.

This guide covers configuring your manifest manipulator to request ad or slate segments using the ad pod segment method.

Select a streaming protocol:

Prerequisites

Before you continue, you must set up a livestream event for the Pod serving redirect Dynamic Ad Insertion (DAI) type and encoding profiles. To set up a livestream event, choose one of the following methods:

After you set up the livestream event, retrieve the event's encoding profiles from Ad Manager UI or API by calling DaiEncodingProfileService.getDaiEncodingProfilesByStatement method.

Retrieve the content stream

When a user selects a livestream event, the client app makes a stream request to Google Ad Manager. In the stream response, the app extracts the Google DAI session ID and metadata to include in the stream manifest request.

The following example passes a Google DAI session ID to a manifest manipulator:

https://MANIFEST_MANIPULATOR_URL/manifest.m3u8?DAI_stream_ID=SESSION_ID&network_code=NETWORK_CODE&DAI_custom_asset_key=CUSTOM_ASSET_KEY

When processing the video content playback request, store the Google DAI session ID and CUSTOM_ASSET_KEY from the request to prepare for ad stitching.

Identify ad break segments and insert discontinuities

As you process each variant manifest, identify the EXT-X-CUE-IN and EXT-X-CUE-OUT tags in your stream, indicating the start and end of an ad break.

Replace the EXT-X-CUE-IN and EXT-X-CUE-OUT tags with the EXT-X-DISCONTINUITY elements for the client video player to switch between content and ads.

The following example manifest replaces the EXT-X-CUE-IN and EXT-X-CUE-OUT tags:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0

#EXTINF:5.000,
contentorigin.com/1.ts
#EXTINF:5.000,
contentorigin.com/2.ts
#EXT-X-CUE-OUT:15.000
#EXTINF:5.000,
contentorigin.com/3.ts
#EXTINF:5.000,
contentorigin.com/4.ts
#EXTINF:5.000,
contentorigin.com/5.ts
#EXT-X-CUE-IN
#EXTINF:5.000,
contentorigin.com/6.ts
#EXTINF:5.000,
contentorigin.com/7.mp4
#EXTINF:5.000,
contentorigin.com/8.mp4

The following example shows a replaced manifest:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0

#EXTINF:5.000,
contentorigin.com/1.ts
#EXTINF:5.000,
contentorigin.com/2.ts
#EXTINF:5.000,
#EXT-X-DISCONTINUITY
{... Insert ad segments here ...}
#EXT-X-DISCONTINUITY
#EXTINF:5.000,
contentorigin.com/6.mp4
#EXTINF:5.000,
contentorigin.com/7.mp4
#EXTINF:5.000,
contentorigin.com/8.mp4

Google DAI ad segments are not encrypted. If your content is encrypted, remove encryption by inserting EXT-X-KEY:METHOD=NONE element prior to the first ad segment of each ad break. At the end of the ad break, add encryption back by inserting an appropriate EXT-X-KEY.

Keep track of the start time, duration, and index of the upcoming ad break.

Build ad segment URLs

Replace each content segment between the EXT-X-DISCONTINUITY tags with a URL pointing to the ad pod segment method.

The following example assembles an ad pod segment. Note that ad segments use a zero-based index:

https://dai.google.com/linear/pods/v1/seg/network/NETWORK_CODE/custom_asset/CUSTOM_ASSET_KEY/ad_break_id/AD_BREAK_ID/profile/ENCODING_PROFILE/0.ts?sd=AD_SEGMENT_DURATION&pd=AD_BREAK_DURATION&stream_id=SESSION_ID&auth-token=HMAC

The following example inserts the ad pod segments into the manifest:

#EXTM3U
#EXT-X-VERSION:6
#EXT-X-TARGETDURATION:6
#EXT-X-MEDIA-SEQUENCE:0

#EXTINF:5.00,
contentorigin.com/1.ts
#EXTINF:5.00,
contentorigin.com/2.ts
#EXT-X-DISCONTINUITY
#EXTINF:5.00,
https://dai.google.com/linear/pods/v1/seg/network/
NETWORK_CODE/custom_asset/CUSTOM_ASSET_KEY/ad_break_id/AD_BREAK_ID/profile/ENCODING_PROFILE/0.ts?sd=5000&so=0&pd=15000&stream_id=SESSION_ID
#EXTINF:5.00,
https://dai.google.com/linear/pods/v1/seg/network/
NETWORK_CODE/custom_asset/CUSTOM_ASSET_KEY/ad_break_id/AD_BREAK_ID/profile/ENCODING_PROFILE/1.ts?sd=5000&so=5000&pd=15000&stream_id=SESSION_ID
#EXTINF:5.00,
https://dai.google.com/linear/pods/v1/seg/network/
NETWORK_CODE/custom_asset/CUSTOM_ASSET_KEY/ad_break_id/AD_BREAK_ID/profile/ENCODING_PROFILE/2.ts?sd=5000&so=10000&pd=15000&stream_id=SESSION_ID
#EXT-X-DISCONTINUITY
#EXTINF:5.00,
contentorigin.com/6.mp4
#EXTINF:5.00,
contentorigin.com/7.mp4
#EXTINF:5.00,
contentorigin.com/8.mp4

Optional: Schedule an ad break

To enhance your fill rate, send an Early Ad Break Notification (EABN) with the ad pod duration, custom targeting parameters, and SCTE-35 signal data. For more details, see Send early ad break notifications.