❆ Creating a Live Ad Replacement service

How to activate Dynamic Ad Insertion on a live stream

Your live stream holds ad breaks and you would like to be able to replace these slots by alternative ads? Guess what? This article shows how to implement it easily and in no time.

This service is based on a content - a live stream - and uses an ad server to identify the ads that have to be inserted. The specifity there, compared to live preroll ad insertion, is that the stream includes information ("markers") that indicates when the ad breaks begin for how long. Each time such a marker is identified, broadpeak.io starts replacing original content by ads.

To set a Live Ad Replacement Service, we will follow these steps:

  1. Create a Live stream as a Source
  2. Create an ad server as a Source
  3. Create a slate as a Source
  4. Create an ad insertion Service
  5. Preview the service & retrieve the output URL

If you want to implement a Service but you don’t have relevant Sources yet, we provide Sources samples you can use in your own tests.

Create a Live stream as a Source

Sample: https://d1uz2gd9rhh5xg.cloudfront.net/out/v1/7964741b79554296ba60e6b1b92ba3c1/index.m3u8

This source delivers the live content you want to manipulate. Find the "Source" tab and click on the "create new" button.

The small status box indicates that the source is valid and matches requirements, including being a dynamic source (in opposition with a VOD asset). It doesn't check the validity of markers for ad replacement.

Note : the provided source sample has markers that indicate 2 minutes long ad breaks every 5 minutes.

Create an ad server as a Source

Sample: https://bpkiovast.s3.eu-west-1.amazonaws.com/vastmultibpkio

An ad server Source is accessible through an HTTP url and returns a VAST payload, often called a "VAST tag". The response payload identifies one or more commercials that have to be inserted in the stream. In this example, we keep it simple : the VAST always indicates the same list of ads of variable durations, to be able to fill the ad server break.

Usually, the ad server is a third-party that dynamicaly returns different ads according to the user profile. This decision is made thanks to query parameters that are part of the request sent to the ad server. Some usually come from the player's request to match ads with user's profile. The "queries" field is there to set this behavior. To keep things simple, we don't use this option in our current scenario.

Create a slate as a Source

Sample: https://bpkiosamples.s3.eu-west-1.amazonaws.com/broadpeakio-slate.jpg

A slate Source is a static image or video. It can be used in broadpeak.io to fill a gap that may exist within the ad break slot: if no ad is short enough no be inserted between the last inserted ad and the end of the ad break slot. In case no slate is used, the stream may switch back to the live content before the ad break duration has past.

Create an ad insertion service

Once we have our 3 main components - a live stream, an ad server & a slate - created as Sources, we can start building our Service. Several ad insertion scenarios are possible. Here we want to insert ads when ad break slots happen: it's the ad replacement feature, also called "mid-roll" as opposed to pre-roll.

The Gap Filler is targetting our slate Source. The transcoding of ads and slate is necessary for these contents to match the format of the live Source and have smooth transitions.

The transcoding profile is part of your account settings; if your account needs some to match your source encoding format, please reach the support team out. If your ads are already encoded, be sure that they are encoded the same way your live source is.

Preview your service and retrieve output URL

Is our service ready to operate ? Let's check that with the preview page, from your service list.

The preview page streams the original live source on its left side. On its right side, the manipulated stream, with the ad inserted. We just have to wait the next markers to compare what's inside the original content and what has been replaced by broadpeak.io during the ad break.

At the end of the ad break, we can see below the slate being displayed before switching back to the live, for no ad is short enough to fill the remaining time of the ad break.

The output service URL can be used in any other web video player.


The very first time the platform get in touch with an ad or a slate that need to be transcoded, the transcoding processs may take few seconds. To guarantee a good user experience, the insertion won't happen during this transcoding period. So you may have to wait for the 2nd slot to get the ads inserted.

Video tutorial

You want the same story but in a video tutorial? Here it is!