AWS for M&E Blog

How to implement reliable dynamic ad insertion using AWS Media Services

During these peculiar times and with the accompanying difficulties of organizing live events, streaming of live proceedings, such as music concerts, sporting events, and linear television, has exploded since the beginning of the COVID-19 pandemic. An increased amount of content is available exclusively through over-the-top (OTT) live streaming on mobile phones and desktop browsers or directly through smart TV applications.

Online audiences are growing exponentially as the number of viewers watching these live streams increases year over year. For example, Super Bowl LV increased online viewership by over 65 percent versus 2020. In addition, broadcasters in Europe broke new live streaming records during the Union of European Football Associations (UEFA) Euro 2020 soccer competition. Free ad-supported TV (FAST) channels are also on the rise with the launch of new services like Peacock (NBCUniversal), IMDb TV (Amazon), and Pluto TV (ViacomCBS) .

According to eMarketer, digital advertisement sees a very promising future: “US advertisers increased their spending on digital ads in 2020 by almost 15 percent despite the [COVID-19] pandemic, and growth will accelerate this year as digital surpasses two-thirds of the US ad market.”

It is an exciting moment for broadcasters and live streaming operators using Amazon Web Services (AWS) with the availability of new and innovative ways to monetize live streams and deliver personalized or regionalized ads. Placing midrolls during a live stream offers a new method for broadcasters and distributors to generate revenue. Dynamic ad insertion (DAI) is the technology to place midrolls within a stream. Live ad replacement, one use case for DAI, replaces ads from a traditional live TV broadcast with digital ads during an ad break.

By using AWS Media Services, broadcasters and distributors can see a fast time-to-market as they implement live ad replacement solutions with “manifest manipulation,” which lets them switch between content and personalized ads for viewers on OTT solutions.

This blog post guides the implementation of a reliable DAI solution with server-side ad insertion (SSAI) using AWS Elemental services, particularly AWS Elemental MediaTailor—a channel assembly and personalized ad insertion service. This blog post steps through the architecture and explains the configuration of AWS Elemental services and Amazon CloudFront—a content delivery network (CDN) service—to create an ad replacement architecture on AWS for linear TV channels.


Before diving deep into the architecture and the implementation of a DAI solution on AWS, let’s start with a preliminary explanation of the traditional ways to place ads during a live stream. Here are the major ways to generate revenue for a video streaming provider:

  • Pre-Roll ads: Video ads display before viewers access the live feed
  • Mid-Roll ads: Video ads display anywhere in the live feed, usually placed within the content at specified markers; the majority of ad revenue opportunity comes from midroll ads.
  • Post-Roll ads: Video ads display at the end of the live feed

The benefit of SSAI, compared with client-side ad insertion, is that it improves the viewing experience by providing a seamless, TV-like playback experience with managed transcoding of ad assets to match program content with no buffering before or between ads. SSAI, seamlessly stitches advertisements into the content. Ads can be tailored to individual viewers, maximizing monetization opportunities for every ad break and mitigating ad blocking. Another benefit of SSAI is that it simplifies development at the player level. By pushing the business logic to the server side, you can deliver a homogeneous experience across a broad range of internet-connected devices, like connected TVs, tablets, smart phones, and set-top boxes.

With SSAI, the video resolution and bitrate of the ads can match live content, compared to client-side ad insertion, where ads tend to be lower quality than primary content, creating a poor end user experience. By offering personalized ads, ad agencies and marketing teams can better address segmented markets and generate more revenue by reducing wasted advertising on audiences that are not within the targeting parameters and by delivering relevant ads to support the customer journey.

The following illustration summarizes what a live ad replacement system should do to switch ads from a live linear feed to digital ads:

NOTE: For OTT distribution, it is challenging to replace the whole ad break with digital ads of the same duration. The purpose of the video slate is to fill video until the end of a digital ad break.

In a traditional broadcast setup, ad markers are inserted at a specific frame to indicate the beginning and the duration of an ad break (this is usually done at the playout level). The duration of an ad break can vary depending on the broadcaster and/or the event. There is no limit on AWS Elemental MediaTailor with respect to ad breaks duration. Multiple ad pods or ad creatives can be displayed during the ad break.

Using DAI makes it possible to replace an ad break in full or in only one specific ad pod. The markers used during the ad breaks are usually Society of Cable Telecommunications Engineers (SCTE) markers (SCTE-104 for uncompressed video feeds and SCTE-35 for compressed feeds). AWS Elemental offers broad flexibility to handle SCTE markers; you can find out more information on how AWS Elemental MediaLive—a broadcast-grade live video processing service—processes SCTE messages here.

The diagram below represents the architecture to build a reliable live DAI on AWS.

It is worth noting that MediaTailor also supports other non-AWS-origin and CDN solutions, but we present a complete AWS configuration here.

  • Ingestion: The source can be any live feed using SCTE markers. In this blog post, we use a live source from AWS Elemental MediaConnect—a high-quality transport service for live video. The source is an MPEG-2 transport stream that has SCTE-35 markers and includes multiple components: audio, video, and subtitles.
  • Live transcoding: We use MediaLive, which works as a live transcoder to create multiple video renditions. The SCTE markers can be pass-throughs from the source or can be directly sent to MediaLive through an API call using the schedule feature.
  • Packaging: We use AWS Elemental MediaPackage—which reliably prepares and protects video for delivery over the internet—as a packager and to convert the stream on the fly from MediaLive into various formats: HTTP Live Streaming (HLS) and MPEG Dynamic Adaptive Streaming over HTTP (DASH).
  • SSAI: We use MediaTailor as a manifest manipulator. It stitches the ads received from the ad decision service (ADS) to the live stream. The ADS can be any ad server for direct sold advertising and includes supply-side solutions for programmatic sold advertising that are downstream from the ad server.
  • CDN: We use Amazon CloudFront as the CDN to distribute live content. Note that you can also use any other third-party CDN.
  • Player: Use a video player supporting HLS with the “EXT-X-DISCONTINUITY” tag or a video player supporting MPEG-DASH with multiple periods. MPEG-DASH streams with single periods are also supported by MediaTailor as origins (more info here).

The following is an illustration of what ad replacement looks like in side-by-side video players.

Step-by-step deployment

This section guides you through the required steps to implement a live ad replacement solution on AWS.



This blog post guides the implementation of a live DAI workflow using AWS Elemental services and Amazon CloudFront. It includes a simple how-to guide for configuring a DAI workflow, but there are many more possibilities and settings you can use to better personalize your ads, thereby increasing your revenue. MediaLive and MediaPackage offer a wide range of settings to better process the SCTE-35 signaling. And MediaTailor gives you many options to better personalize the ad experience by passing session and player information to the ADS or providing click-through or VPAID capabilities. For more details on the MediaTailor dynamic ad variable, refer to our documentation.