AWS for M&E Blog

Build your own VAST 3.0 response XML to test with AWS Elemental MediaTailor

In a previous blog, AWS Elemental MediaTailor Supported Video Ad Serving Protocols, we talked about the various video ad protocols that AWS Elemental MediaTailor supports. In this post, we will focus on one of those protocols, namely VAST, and show how you can build a simple VAST response XML which you can use in lieu of a production Ad Decision Server (ADS) for testing purposes. We will then use this XML response when we create a new AWS Elemental MediaTailor configuration from scratch.

To follow along, you’ll need the following:

  • A text editor for creating XML document
  • An AWS account
  • HTTP Live Streaming (HLS) content from an origin server like AWS Elemental MediaPackage, that already has ad markers (you may follow this workshop on how to set up AWS Elemental MediaPackage), or an HLS asset with ad markers, hosted on a server like Amazon S3
  • Video ad content hosted on a server like Amazon S3

Per VAST 3.0 specification (see references [1]), there are a handful of parameters that are required to be present in order to create a valid VAST XML template. Below is a sample XML representing this minimum required set of elements. Copy and paste this on to your editor as a starting point.

<VAST version="3.0">
    <Ad>
        <InLine>
            <AdSystem>2.0</AdSystem>
            <AdTitle>ad-1</AdTitle>
            <Impression/>
            <Creatives>
                <Creative>
                    <Linear>
                        <Duration>00:00:15</Duration>
                        <MediaFiles>
                            <MediaFile delivery="progressive" type="video/mp4" width="1920" height="1080">
                                <![CDATA[http://example.com/ad1.mp4]]>
                            </MediaFile>
                        </MediaFiles>
                    </Linear>
                </Creative>
            </Creatives>
        </InLine>
    </Ad>
</VAST>

The CDATA section of the MediaFile element should point to the URL of your video ad. The Duration element should specify how long the video is. The Delivery method should be set to either “progressive” (for progressive download protocols like HTTP) or “streaming” (for streaming protocols like RTMP), though note that AWS Elemental MediaTailor does not support the “streaming” delivery method. The type should denote the MIME type for the file container. One of the most common MIME types is “video/mp4” for MP4. The width and height should be in pixels, representing the native width and height of the ad, respectively.

Replace the values of the above element and attributes to match the properties of the video ad you’ll be using.

VAST 3.0 supports a feature called Ad Pods where multiple ads can play one after another in a single ad break. If you’d like to take advantage of that feature, use the sequence attribute in the Ad element to specify the order in which the ads will appear, starting at 1. The example below uses two 15-second duration ads.

<VAST version="3.0">
    <Ad sequence="1">
        <InLine>
            <AdSystem>2.0</AdSystem>
            <AdTitle>ad-1</AdTitle>
            <Impression/>
            <Creatives>
                <Creative>
                    <Linear>
                        <Duration>00:00:15</Duration>
                        <MediaFiles>
                            <MediaFile delivery="progressive" type="video/mp4" width="1920" height="1080">
                                <![CDATA[http://example.com/ad1.mp4]]>
                            </MediaFile>
                        </MediaFiles>
                    </Linear>
                </Creative>
            </Creatives>
        </InLine>
    </Ad>
    <Ad sequence="2">
        <InLine>
            <AdSystem>2.0</AdSystem>
            <AdTitle>ad-2</AdTitle>
            <Impression/>
            <Creatives>
                <Creative>
                    <Linear>
                        <Duration>00:00:15</Duration>
                        <MediaFiles>
                            <MediaFile delivery="progressive" type="video/mp4" width="1920" height="1080">
                                <![CDATA[http://example.com/ad2.mp4]]>
                            </MediaFile>
                        </MediaFiles>
                    </Linear>
                </Creative>
            </Creatives>
        </InLine>
    </Ad>
</VAST>

The easiest way to serve up your XML is by saving it and placing it in an Amazon S3 bucket in your AWS account. If you don’t have one already, create a bucket in S3:

Upload your XML file to the bucket.

Make sure that you make the object public once it is in the bucket. Also, note the link to access the file. You will need this when you fill in your AWS Elemental MediaTailor configuration.

Now you’re ready to set up your AWS Elemental MediaTailor configuration. From the AWS console, access the AWS Elemental MediaTailor service. Create a new configuration.

  • Configuration name: config name of your choosing
  • Video Content Source: link to the origin server or content server hosting your video content; note that this is pointing to the directory, not directly to the filename
  • Ad Decision Server:  link to your VAST response XML in S3.

Once your configuration has been created, AWS Elemental MediaTailor generates a Playback Endpoint which is the URL you will use to playback your video with ad content.


To playback your content, copy and paste the HLS playback URL like the one above, and append the filename of your video to create the full playback URL. If your video content filename is video.m3u8, then your full URL is:

https://2907c649a22a4a369145319fefd29c49.mediatailor.us-east-1.amazonaws.com/v1/master/cf6421621b389b384c1fd22e51603ee95db76ae0/MyConfigName/video.m3u8

If you have an Apple device, simply paste this URL on to your Safari browser to start playback. You may also use any HLS player like VideoJS HLS.

What you’ll see during playback depends on the duration of your ad in your content video source and the length of the ad(s) you ended up returning in your VAST XML response. If the length of your ad is equal to or shorter than the ad break duration in your content, then you should see the ad break in its entirety before returning to the main video content. However, if the length of your ad is longer than the ad break duration in your content by 2 seconds or more, then AWS Elemental MediaTailor will, by default, not show the ad.

It is possible not to see an ad the first time it is requested during playback. When your player requests ad segments during playback, AWS Elemental MediaTailor sends the ad to Amazon Elastic Transcoder if the ad is not already transcoded in a format that matches the video content. Subsequent requests for the same ad should work, as AWS Elemental MediaTailor stores transcoded ads on Amazon S3 and they are cached on Amazon CloudFront or other CDNs for distribution.

Once you are ready to go into production and monetize your content, you’re most likely going to want to work with a commercial ADS for a more personalized and targeted ad experience. AWS Elemental MediaTailor is ADS agnostic and has support for commercial ADS like DoubleClick For Publishers (DFP), FreeWheel, and SpotX, to name a few. Meanwhile, you may use a canned VAST XML response like what we have created here to test your initial integration with AWS Elemental MediaTailor.

References:
1.     https://www.iab.com/wp-content/uploads/2015/06/VASTv3_0.pdf

2.     https://github.com/aws-samples/aws-media-services-simple-live-workflow/tree/master/2-MediaPackage