Creating CMAF for Accurate Player using AWS Elemental MediaConvert
Introduction
This short guide will explore how to encode media files in the CMAF container format, using AWS Elemental MediaConvert, for easy playback of both HLS and DASH using Accurate Player. One advantage of CMAF is that it allows us to use the same segment files for both HLS and DASH, thus having to encode only once, saving on cost, processing power, and time in the encoding pipeline. Since CMAF only uses fragmented mp4, it makes it much easier to distribute and cache segments on CDN servers as well.
What is CMAF?
CMAF, or the Common Media Application Format, is a container format that was designed to unify the fragmented video streaming market where predominantly DASH and Apple’s HLS are used. The challenge lies when delivering content across a wide range of devices, where you’ll need HLS to mainly target iOS and Mac devices, and DASH for others. With CMAF, both HLS and DASH can refer to the same delivery segments from different manifest files, using fragmented mp4 for segments. This leads to a much easier pipeline for encoding, packaging, and storing segments on CDN servers, without competing with each other. CMAF also comes with other benefits, for more details you can check out this article on the Apple developer page.
AWS Elemental MediaConvert
AWS Elemental MediaConvert is a file-based video transcoding service on AWS, which makes it very easy to encode content in many different formats, for all kinds of devices. The biggest advantage of MediaConvert is that it requires no setup, management, or maintenance. It automatically scales based on your workload, with predictable, on-demand pricing. We’ll explore how to create and start jobs, configure output presets, and define job templates.
Accurate Player
Accurate Player is a web browser-based, frame-accurate, professional video, audio, and subtitle player framework. Accurate Player includes advanced software functionality, a front-end component library, and well-documented APIs for integration into any application or workflow. It’s the best option when you require frame-accurate, broadcast-level features for playback of content with integration into a CMS or MAM-like solution.
Create job
Let’s explore how to create a job in MediaConvert in the console UI, which is easier for seeing all the options available (there are many!). Before creating a new job, let’s explore job templates. There are a lot of options and different parameters available when encoding content. Sometimes you just want to get quickly started using recommended defaults, or define your own custom job that can be reused later without having to specify all the options. This is where job templates are useful.
Click job templates to the left, and set the category to OTT-CMAF. You’ll see four pre-created templates available. Select the first one and press create job, this will launch the create job wizard using the template with pre-configured options. This specific template uses AVC (h264) for video and AAC for audio.
Add input
You’ll see the create job screen with a lot of pre-created outputs. These represent the different renditions at different quality levels that will be created for the ABR ladder. The template used is suitable for OTT, thus there are many renditions created to target everything from low bandwidth devices up to high-resolution TVs. Next, we’ll need to create an input, meaning the source file for the encoding. Click add next to the Input and select a sample mp4 file from S3.
Output destination
Select the CMAF output group, and select an S3 bucket for storing the output files.
Recommended by LinkedIn
You can see some of the predefined configuration variables here. Two of the interesting ones are Write DASH manifest and Write HLS manifest, both of which are enabled. This means that MediaConvert will produce both an mpd (DASH) and m3u8 (HLS) manifest file.
Scroll down and click Create job. You’ll be redirected to the job summary page, and the job will be queued for execution in MediaConvert. This might take a while depending on what input file you selected, so keep refreshing until you see the status of the job changes to COMPLETE.
Output files
Let’s move on to S3 and explore the files created by the MediaConvert encoding job. Looking inside the bucket, there are 110 objects! The reason is all the different renditions that have been created. There are two master manifests, mpd and m3u8.
DASH uses a single manifest mpd file, but for HLS you’ll see many additional m3u8 manifests, one per rendition. This is according to the specification. In addition to these files, there are a lot of cmfv (CMAF video) and cmfa (CMAF audio) files.
This specific job template creates multiple fMP4 files for each output, but there is an option when encoding to create a single audio and video file for each rendition, which can be retrieved using byte-range requests in the manifest files. This is similar to how progressive download works and makes it easy to migrate existing proxy-based (mp4 files) workflows to ABR and CMAF.
Playing in Accurate Player
Both the DASH (mpd) and HLS (m3u8) manifest can now be loaded in Accurate Player (make sure to give the player access to the bucket first). All renditions are available automatically and the player seamlessly switches between them based on available bandwidth. Loading HLS or DASH is done just by selecting the corresponding manifest file, all the segments are shared and use the same fragmented mp4 files. Note that you’ll also need to enable CORS on the output S3 bucket.
The job template uses 29.97 (NTSC) frame rate, so make sure to select that as the source frame rate. From here the content will play frame-accurately without problems. Below you can see screenshots of a demo environment with Accurate Player playing both the DASH and HLS manifest.
Summary
This guide explored CMAF, a container format that makes it easy to encode to both DASH and HLS using the same segments. We’ve explored how to use MediaConvert to create a job from a pre-configured job template for CMAF, designed for OTT delivery with multiple renditions. Although this is great to quickly get started, creating your own custom job template gives you a higher level of control of encoding parameters, such as frame rate, segment size, and the number of renditions.
If you’re interested in learning more about Accurate Player or Codemill, please contact us at sales@codemill.se. You can also find more details on our homepages below.