AWS News Blog

How to Use Channel Assembly with AWS Elemental MediaTailor to Launch Virtual Channels from Existing Sources

Voiced by Polly

If you’re a broadcaster or Over-the-Top (OTT) channel operator, you can now create virtual channels by pulling together programming from multiple existing on-demand sources and blending them into a linear playlist.

Creating a customized channel for a smaller audience group — such as a category of viewers based on interest, or regional preferences — was traditionally prohibitively expensive due to the cost to transcode the media for online streaming and the complexity of discovering and curating existing media in the catalog.

AWS Elemental MediaTailor Channel Assembly now allows you to create static or dynamic playlists to stream content to viewers by reusing already transcoded video segments from your existing catalogs. It eliminates the need to re-transcode source content for multiple regional or viewer permutations.

You can select between multiple scheduling options, such as loop content, or dynamically add programs in the schedule, either manually, or by inserting a program lineup provided by a recommendation engine. You can also schedule ad breaks with intelligent program-aware rules.

How to Get Started with AWS Elemental MediaTailor
Let’s assume I want to create a new streaming channel by assembling one HLS- and one DASH-packaged stream using content I already have. The content must be encoded and packaged with similar characteristics, such as the same number of bit-rate tiers and the same parameters at each level (codec, resolution, frame rate etc.). I can use AWS Elemental MediaConvert to prepare the content and store it on Amazon Simple Storage Service (Amazon S3). The source formats supported are HLS, DASH and CMAF (with HLS and DASH manifests). For this example, the content is available through my CDN; without surprise, I am using Amazon CloudFront.

The first step is to define the source of my content and to register each individual asset I want to include in the schedule. In the AWS Elemental MediaTailor console, under Channel Assembly, I click Create source location:

Elemental Channel Assembly - Create Source Location

and then I add my video sources:

MediaTailor Channel Assembly add VOD source

or with the AWS Command Line Interface (AWS CLI)

# Create a Source Origin
aws mediatailor create-source-location \
    --source-location-name NewsBlogSourceLocation
    --http-configuration \
           BaseUrl=https://dyye954rrfxy8.cloudfront.net // <-- this is my CloudFront distribution DNS name
{
    "Arn": "arn:aws:mediatailor:us-west-2:1234567890:sourceLocation/NewsBlogSourceLocation",
    "CreationTime": 1614660822156,
    "HttpConfiguration": {
        "BaseUrl": "https://dyye954rrfxy8.cloudfront.net"
    },
    "LastModifiedTime": 1614660822156,
    "Name": "NewsBlogSourceLocation"
}		   

# Register two video assets
aws mediatailor create-vod-source \
    --source-location-name NewsBlogSourceLocation \
    --vod-source-name MyFirstVodSource \
    --http-package-configurations \
        Id=hls,Path=/out/v1/24247f7e7f2942509058713671dce466/209b7701f2224791a9a44440e6e5b9e0/e2fdd7d6ae5f4e41ac57089be4de2d02/index.m3u8,SourceGroup=hls,Type=HLS \
        Id=cmaf,Path=/out/v1/24247f7e7f2942509058713671dce466/d71309185897405383031fd7d4515198/8901ed3df0e842c99fd8523c5b935d2f/index.m3u8,SourceGroup=cmaf,Type=HLS
{
    "Arn": "arn:aws:mediatailor-gamma:us-west-2:898676505562:vodSource/NewsBlogSourceLocation/MyFirstVodSource",
    "CreationTime": 1614661120839,
    "HttpPackageConfigurations": [
        {
            "Id": "hls",
            "Path": "/out/v1/24247f7e7f2942509058713671dce466/209b7701f2224791a9a44440e6e5b9e0/e2fdd7d6ae5f4e41ac57089be4de2d02/index.m3u8",
            "SourceGroup": "hls",
            "Type": "HLS"
        },
        {
            "Id": "cmaf",
            "Path": "/out/v1/24247f7e7f2942509058713671dce466/d71309185897405383031fd7d4515198/8901ed3df0e842c99fd8523c5b935d2f/index.m3u8",
            "SourceGroup": "cmaf",
            "Type": "HLS"
        }
    ],
    "LastModifiedTime": 1614661120839,
    "Name": "MyFirstVodSource",
    "SourceLocationName": "NewsBlogSourceLocation"
}

aws mediatailor create-vod-source \
    --source-location-name NewsBlogSourceLocation \
    --vod-source-name MySecondVodSource \
    --http-package-configurations \
        Id=hls,Path=/out/v1/5bc2c7b8a384403681222f703c6dd3ee/209b7701f2224791a9a44440e6e5b9e0/e2fdd7d6ae5f4e41ac57089be4de2d02/index.m3u8,SourceGroup=hls,Type=HLS \
        Id=cmaf,Path=/out/v1/5bc2c7b8a384403681222f703c6dd3ee/d71309185897405383031fd7d4515198/8901ed3df0e842c99fd8523c5b935d2f/index.m3u8,SourceGroup=cmaf,Type=HLS

{ ... } 

The second step is to create the channel, define the channel outputs, and the channel access permissions.

MediaTailor Channel Assembly create channel step 1

MediaTailor Channel Assembly create channel step 2

MediaTailor Channel Assembly create channel step 3

Do not forget to replace your actual AWS Account Id and AWS Region name.

You can automate the above with the CLI:

# Create the channel
aws mediatailor create-channel \
    --channel-name NewsBlogChannel \
    --playback-mode LOOP \
    --outputs \
        HlsPlaylistSettings={ManifestWindowSeconds=30},ManifestName=index,SourceGroup=hls  \
        HlsPlaylistSettings={ManifestWindowSeconds=30},ManifestName=cmaf,SourceGroup=cmaf

{ ... } 

# define the channel access permissions
# do not forget to replace *MY ACCOUNT ID* with your actual AWS Account ID. Also adjust the AWS Region name.
aws mediatailor put-channel-policy \
    --channel-name NewsBlogChannel \
    --policy "{ \"Version\": \"2012-10-17\", \"Statement\": [ { \"Sid\": \"AllowAnonymous\", \"Effect\": \"Allow\", \"Principal\": \"*\", \"Action\": \"mediatailor:GetManifest\", \"Resource\": \"arn:aws:mediatailor:us-west-2:*MY ACCOUNT_ID*:channel/NewsBlogChannel\" } ] }"

The third and last step before starting the channel is to add the video sources. This can be done once for all or adjusted dynamically as viewers are watching the stream. A program is a combination of an asset and a moment in the schedule. I can add programs wherever I need: before or after other programs.

MediaTailor Channel Assembly create program

Or I can automate this using the CLI:

aws mediatailor create-program \
    --channel-name NewsBlogChannel \
    --schedule-configuration "Transition={Type=RELATIVE,RelativePosition=AFTER_PROGRAM}" \
    --program-name MyFirstProgram \
    --vod-source-name MyFirstVodSource \
    --source-location NewsBlogSourceLocation
{
    "AdBreaks": [],
    "Arn": "arn:aws:mediatailor:us-west-2:1234567890:program/NewsBlogChannel/MyFirstProgram",
    "ChannelName": "NewsBlogChannel",
    "CreationTime": 1614661735435,
    "LastModifiedTime": 1614661735435,
    "Name": "MyFirstProgram",
    "SourceLocationName": "NewsBlogSourceLocation",
    "VodSourceName": "MyFirstVodSource"
}

aws mediatailor create-program \
    --channel-name NewsBlogChannel \
    --schedule-configuration "Transition={Type=RELATIVE,RelativePosition=AFTER_PROGRAM,RelativeProgram=MyFirstProgram}" \
    --program-name MySecondProgram \
    --vod-source-name MySecondVodSource \
    --source-location NewsBlogSourceLocation 
{ ... }	

Finally, I start the channel. The billing starts at this point.

MediaTailor Channel Assembly Start Channel

At any time, I can call describe-channel to get the channel endpoints; one per output format.

aws mediatailor start-channel \
    --channel-name NewsBlogChannel

aws mediatailor describe-channel \
    --channel-name NewsBlogChannel

{
    "Arn": "arn:aws:mediatailor:us-west-2:1234567890:channel/MyFirstChannel",
    "ChannelState": "RUNNING",
    "CreationTime": 1613709143819,
    "Name": "MyFirstChannel",
    "Outputs": [
        {
            "HlsPlaylistSettings": {
                "ManifestWindowSeconds": 30
            },
            "ManifestName": "index",
            "PlaybackUrl": "https://abc123.abc123.channel-assembly.mediatailor.us-west-2.amazonaws.com/v1/channel/NewsBlogChannel/index.m3u8",
            "SourceGroup": "hls"
        },
        {
            "HlsPlaylistSettings": {
                "ManifestWindowSeconds": 30
            },
            "ManifestName": "cmaf",
            "PlaybackUrl": "https://abc123.abc123.channel-assembly.mediatailor.us-west-2.amazonaws.com/v1/channel/NewsBlogChannel/cmaf.m3u8",
            "SourceGroup": "cmaf"
        }
    ],
    "PlaybackMode": "LOOP"
}

I can test my channel by opening the endpoint in a compatible client, such as a modern web browser (I tested it with Safari) or ffplay. The documentation has more advanced examples, including how to add ad breaks or how to create a CloudFront configuration to distribute your stream in one single step.

If you applied the commands above on your AWS Account, do not forget to stop the channel after your test, to avoid accruing charges.

As usual, there are no upfront costs; you only pay for what you use. Pricing starts at $0.10 / channel-hour for on-demand assets. This is the equivalent of $73 /channel-month if you run the channel 24/7.

AWS Elemental MediaTailor Channel Assembly is available in US East (N. Virginia), US West (Oregon), Asia Pacific (Singapore), Asia Pacific (Sydney), Asia Pacific (Tokyo), Europe (Frankfurt), and Europe (Ireland). You can start to use it today.

Sébastien Stormacq

Sébastien Stormacq

Seb has been writing code since he first touched a Commodore 64 in the mid-eighties. He inspires builders to unlock the value of the AWS cloud, using his secret blend of passion, enthusiasm, customer advocacy, curiosity and creativity. His interests are software architecture, developer tools and mobile computing. If you want to sell him something, be sure it has an API. Follow him on Twitter @sebsto.