AWS for M&E Blog

Amplify Video now supports MPEG-DASH for on-demand video

Introduction

Amplify Video now supports generating MPEG-DASH manifests in addition to HLS manifests for on-demand video delivery, making it easier to leverage the two dominant HTTP streaming protocols for delivering video over the internet.  In this post we highlight how users can use the AWS Amplify framework with the Amplify Video plugin to create and distribute MPEG-DASH content. Amplify Video users can use the same simple questionnaire process to seamlessly generate DASH and HLS manifests, host on Amazon Simple Storage Service (Amazon S3) and expose the content over Amazon CloudFront for consumption by end-users.

MPEG-DASH (Dynamic Adaptive Streaming over HTTP) is an independent international standard for delivering adaptive video over HTTP.  DASH works by breaking up the video into 2-10 second segments that can be delivered over HTTP. It is “adaptive” because multiple quality levels of the video are exposed to  the user-agent, which then selects the highest possible quality level for each segment based on the bandwidth available to the end-user. This adaptability reduces buffering as the user-agent can quickly switch to lower quality levels when there are constraints on the bandwidth.

Though HLS and MPEG-DASH provide similar functionality, a key difference is the implementation of MPEG-DASH has an open-source javascript library dash.js, which gives you the ability to modify the implementation to suit your specific needs. In terms of security, HLS only supports Fairplay as a DRM technology which works on iOS devices only, MPEG-DASH supports Playready and Widevine which are supported on a variety of Android and Windows devices. If your use case requires DRM and non-DRM content, for example, premium content with sponsored ads/content thrown in, it is easier to have MPEG-DASH for non-iOS devices and HLS for iOS devices.

Creating  a MPEG-DASH video stream using Amplify Video

The following procedure will create a MPEG-DASH stream using Amplify Video. In order to complete this, you will need

Step 1: Install Amplify CLI and Amplify Video

  1. Navigate to the terminal window
  2. Install and configure Amplify CLI, this helps you deploy and manage your backend infrastructure using the command-line

npm install -g @aws-amplify/cli

amplify configure

  1. Install Amplify Video, a plug-in for Amplify CLI which helps manage on-demand and live video workflows

npm i amplify-category-video -g

  1. Initialize Amplify CLI by running the following command. You need to select the region, provide credentials and provide a name for the project.

amplify init

Step 2: Build the video pipeline using Amplify Video

  1. Run the following command to start the Amplify Video questionnaire

amplify video add

For the question “Please select from one of the below mentioned services”, choose “Video-On-Demand”. Provide a name for your project for the question “Provide a friendly name for your resource to be used as a label for this category in the project”. In the “Select a system-provided encoding template” question, you will see an option for Default DASH Adaptive Bitrate. Select “Default DASH Adaptive Bitrate” for generating only MPEG-DASH renditions or select “Default HLS+DASH Adaptive Bitrate” if you want to generate both HLS and DASH renditions

Select an encoding profile

  1. Answer “No” to “Do you want to get notifications on the video processing job”. The answer to “Is this a production environment” is “Yes” as it instructs Amplify to create a CloudFront distribution to deliver the videos. This is helpful to ensure you are able to deliver your videos without giving public read access to your S3 bucket. For this walkthrough you will answer “No” to the questions “Do you want to protect your content with signed urls” and “Do you want Amplify to create a new GraphQL API to manage your videos

 Amplify Video CLI walk-through completed

  1. Push the configuration changes using the following command. Amplify Video builds and configures all the components required for creating a MPEG-DASH video in your AWS account.

amplify push

  1. Once the push has successfully completed, you should see the location of the Input Storage Bucket and the Output URL for content

Step 3: Test Playback

  1. Open the Amazon S3 console.
  2. Select the bucket that was created as the input bucket and upload a sample video file.

After the content is uploaded, the processing of the video is automatically initiated and the file is transcoded using AWS Elemental MediaConvert and the output is stored on the -output bucket. The output S3 Bucket is configured to be blocked from public access and the content can only be accessed via CloudFront. The CloudFront domain is available in the output of Amplify video push command, to get the URL of the video, the S3 prefix, and key is appended to the CloudFront CDN domain.

https://<CloudFrontDomain>/{ InputFilename }/{InputFilename}.mpd”

If you selected “Default HLS+DASH Adaptive Bitrate” in Step 2-1, the output URL is:

https://<CloudFrontDomain>/{ InputFilename }/hls/{InputFilename}.m3u8″

https://<CloudFrontDomain>/{ InputFilename }/dash/{InputFilename}.mpd”

  1. To playback content, create a sample HTML page using Amplify Video

amplify video setup-video-player 

HTML code for a webpage with an embedded video player is displayed as an output of the Amplify Video command. Copy the code into your favorite text editor and edit the <source> tag to update the src attribute with the URL as described in Step 3-2 and update type attribute with the value “application/x-mpegURL

Amplify Video generated video player HTML page for video playback

  1. Host the webpage on your localhost or web server and navigate to the page in your browser. The video will begin to playback once the page loads.

Congratulations! Using a few commands, you just set up an end-to-end pipeline for generating MPEG-DASH content from a source video file.

As Amplify Video continues to evolve, we are looking to support Common Media Application Format (CMAF), which is a standard for segmented video delivery that aims to be a single set of video files that can be used on all devices. Content creators don’t need to duplicate their video encoding and storage to create HLS and MPEG-DASH to ensure their content can be consumed on all devices. If you’d like to see this feature, please add your comments to https://github.com/awslabs/amplify-video/issues/292.

AWS offers the most purpose-built services for direct-to-consumer (D2C) & streaming to help companies reliably deliver, monetize, and support live and on-demand media over the internet, and bring unparalleled experiences to screens everywhere. Explore https://aws.amazon.com/media/direct-to-consumer-d2c-streaming/ to learn more.

Shamik Shah

Shamik Shah

Shamik is a Solutions Architect in the Strategic Accounts organization helping customers use AWS services effectively. When he isn't geeking out on AWS, he is experimenting with hydration percentages for sourdough bread or trying to balance on his SUP on the many lakes in Seattle!