AWS for M&E Blog

Using program rules with AWS Elemental MediaTailor

With the release of program rules, it is now possible to define alternate media for audience cohorts using AWS Elemental MediaTailor Channel Assembly. This provides customers with an easy and cost effective way to create up to 50 unique audiences on a channel, for use cases such as market-based localization according to content rights or segments of content types to increase engagement. This post outlines how to configure program rules using audience identifiers as a query string added to the streaming manifest.

Example use case

To explain program rules, let’s take a common regional playout use case. For the majority of the day, channel programming is the same for all geographical markets. But there is also a live sporting event that can only be distributed in certain markets. Prior to program rules, customers would have to run separate channels. Now a live source event is set as the default program, and it can be substituted with a video on demand (VOD) source as the alternate media for a certain audience using program rules.

As shown in the following drawing, a single MediaTailor channel is created that starts with a program as video on demand source (blue), followed by a default program that uses a live source (green). This is the content that is provided to viewers without any audience identifier, so it is fully backwards compatible with existing channels. The live source could be a sports event, for example, with a fixed start time and a duration that can be updated if the end time of the event needs to be extended.

However, the audience that needs to branch into alternate media at the schedule boundary of the live event will require an audience identifier, for example “georestricted”, to be associated with a program rule for a VOD source (yellow). Given that the live event duration is longer than the VOD source, another VOD source (red) can be scheduled for this audience identifier as filler until the live event completes. After the live event, the default audience of the parent program resumes with all audiences viewing the same VOD source (blue) until the next program rule is applied.

Drawing of an example timeline showing how a default audience will view live source and the audience with audienceId = georestricted will see a VOD source.

Example architecture

The workflow in the example use case could be implemented using the architecture depicted in the following diagram to create a live and VOD source. While the specifics are outside the scope of this blog post, see the Amazon Web Services (AWS) Solutions Library for Live Streaming on AWS and Video on Demand on AWS. AWS Elemental MediaTailor is purely a manifest manipulation service so it will not alter the media content. It rewrites the manifest to include the content segments for advertising insertion and the linear assembled stream.

The video player loads the multi-variant streaming manifest generated by MediaTailor, with content delivery via Amazon CloudFront. If a query string is appended with audienceId, MediaTailor will check if alternate content has been defined for the current program with that audience id value. If a request is received with an audience id that is not defined on the channel, a 404 error results.

AWS Architecture drawing showing live workflow using AWS Elemental MediaConnect, MediaLive, MediaPackage and a VOD workflow with MediaConvert and Amazon S3. These sources are used by MediaTailor to process the manifest and serve with Amazon CloudFront to an audience. The georestricted audience will have a query string for audienceId to set the Program Rule associated.

Steps to create program rules

Step 1 – Create a channel 

You can either modify an existing channel or for detailed instructions on how create a new channel, please see How to Use Channel Assembly with AWS Elemental MediaTailor to Launch Virtual Channels from Existing Sources.

Step 2 – Configure audiences

The channel edit form now has a step to define audiences for the channel as shown, with up to 50 unique Audience identifiers possible. Note that the format must be alphanumeric, with a maximum of 32 characters.

AWS Console for MediaTailor showing configuring audiences in a text form

Step 3 – Add program and set program alternate media 

When adding programs to the channel schedule, an extra step is available to associate audience identifiers with the program using the dropdown list as shown. This example adds a program named “LiveSport” with a live source, with a minimum duration of 10 minutes and absolute transition type for scheduled start time greater than 1 minute in the future.

AWS Console for MediaTailor showing configuring audience ID.

Next, use the “Add alternate media” button for this audience, which will expand to specify the alternate media as shown. For VOD sources, it is possible to specify a clip range, from beginning to a specified end offset in milliseconds. For a live stream source as alternate media, specify the scheduled start time in milliseconds since epoch and the duration in milliseconds. For this example, the alternate media for the live stream will be a VOD source named “BigCats”.

AWS Console for MediaTailor showing updating alternate media for program rule.

Step 4 – View channel schedule for audience

Having added programs to the channel, the schedule panel now has a dropdown list of audience to filter the schedule associated. Using the earlier example, for the scheduled program of “LiveSport” the audience Id of “georestricted” now has alternate media as the VOD source “BigCats”. However, the default audience will have the original LiveSport program with live source.

AWS Console for MediaTailor showing channel schedule and a dropdown list of audiences to filter the schedule per audience.

Step 5 – Start channel and test playback

Once the Channel is started, preview the linear channel in your preferred video player using the channel outputs manifest name. To view as the “georestricted” audience, add the following query string to the manifest:

?aws.mediatailor.channel.audienceId=georestricted

For example, a full channel manifest URL would be similar to the following:

https://<some prefix>.channel-assembly.mediatailor.us west2.amazonaws.com/v1/channel/ExampleChannel/index.m3u8?
aws.mediatailor.channel.audienceId=georestricted

Congratulations – you now have a single MediaTailor linear assembled stream with two unique audiences using program rules!

Content protection

For scenarios requiring content rights to be enforced, it is recommended to prevent tampering of query strings to circumvent program rules. This can be achieved by implementing the solution Secure Media Delivery at the Edge on AWS, which protects unauthorized access when delivered through Amazon CloudFront. Unique tokens are generated for the playback session and by adding the audienceId query string as a parameter in the token attributes, as outlined in the implementation guide. The value of the query string can then be checked at the edge using CloudFront Functions on every request, to ensure it is a valid audienceId.

Geolocation rules

When personalizing program rules based on viewer location, there are options to identify viewer location at the edge using Amazon CloudFront Geolocation headers. This approach could include the following steps:

  1. Configure CloudFront to add the required request headers, such as CloudFront-Viewer-Postal-Code, then ensure it’s included in the cache policy and added to the origin request policy for MediaTailor.
  2. Create a CloudFront Function with custom code to map the postal code to an audienceId. This could benefit from using CloudFront KeyValueStore to update the lookup data separately to function code.
  3. CloudFront Function would then append the audienceId query string associated with the location, which is passed to MediaTailor as an origin request.
  4. Viewer response now has the custom manifest modified per program rules, but the viewer will never know which audienceId they are assigned.

Pricing

Additional charges apply when you configure a program with alternate media. Each additional hour of content, defined as alternate media, incurs the standard tier channel hour usage.

For example, if your channel has two audiences configured (movie_comedy and movie_action) and 4 times per month a 2 hour program is configured with alternate media, pricing in region US-West-2 would be:

default audience = 730 hours per month * 0.35 per hour (Standard Tier) = $255.50
“movie_comedy” audience = 4 * 2 hours (per month) * 0.35 per hour (Standard Tier) = $2.80
“movie_action” audience = 4 * 2 hours (per month) * 0.35 per hour (Standard Tier) = $2.80

Total: $255.50 + $2.80 + $2.80 = $261.10 per month.

Summary

This post introduced AWS Elemental MediaTailor program rules, some potential use cases and suggested approaches to content protection and geolocation rules. The example scenario outlines the steps and configuration options in the AWS Management Console, where a live event is replaced with a VOD source for an audience. Using these features, it is possible to efficiently create more cohorts of content to scale your viewing audience and also monetize your content with MediaTailor as your ad insertion service.

To learn more, please visit the AWS Elemental MediaTailor overview page.

Phil Harrison

Phil Harrison

Phil is an AWS Media Services Product Manager focusing on the Channel Assembly capability within AWS Elemental MediaTailor

Damian McNamara

Damian McNamara

Damian McNamara is a Senior Specialist Solution Architect for AWS Edge Services, with two decades experience in Broadcast and Digital Media.