Sanchit Dilip Jain/Exploring video transcoding on AWS using AWS Elemental Mediaconvert 🔍

Created Thu, 29 Jul 2021 12:00:00 +0000 Modified Fri, 06 Dec 2024 18:05:09 +0000
643 Words 3 min

AWS Elemental Mediaconvert

Introduction

  • AWS Elemental MediaConvert is a file-based video transcoding service with broadcast-grade functionality. It offers to easily generate on-demand video (VOD) content for transmitting and multiscreen distribution at a larger scale.

  • The service merges advanced video and audio functionality via a UI with pay-as-you-go pricing. This service also allows for delivering compelling media experiences without having to worry about the criticality of building and operating your own video processing infrastructure.

  • Below are the different features of AWS Elemental Mediaconvert

    • Broadcast Capabilities for Video-on-Demand Content

    • Comprehensive Input and Output Support

    • Automated Resource Provisioning

    • Built-in Reliability

    • Pay-as-you-go pricing

MediaConvert components

  • Jobs: A job performs the task of transcoding. When we configure a job, specify the name of the file that we want to transcode, the name we want MediaConvert to provide to the finished output files, and other configuration

  • Queues: A queue provide to control the resources that are available to the AWS account for parallel processing

  • Presets: A preset is a persisted group of encoding configurations for an output. We can create many such outputs by simply choosing a system preset

  • Job templates: A job template contains all the configurations for an end-to-end job, excluding IAM role and settings like the input file location and name, and user metadata that we might tag the job with.

Demo

  • Now we will learn how to leverage MediaConvert to configure jobs using AWS Lambda in an automation fashion

    image1

  • Steps to implement to MediaConvert jobs

    • Step 1: Prerequisite

      • Download the cloudformation template from this link and Deploy it

      • Once the Cloudformation stack is deployed successfully please capture the values for BucketName, IAMRoleForLambda, and IAMRoleForMediaConvert from the Output Section of the stack

        image2

      • Download the Sample Audio from this link and upload it to the S3 bucket

    • Step 2: Execution via AWS console

      • Open the AWS MediaConvert console at link

      • Click on get started from the home page

      • Choose Input 1 from the left navigation panel under Inputs and provide Input file S3 location under Input 1

        image3

        image4

      • Choose Output Groups from the left navigation panel and click Add

      • Check the File group box then click on Select

        image5

      • Next, provide a name to the File group and provide an S3 output location. And leave the remaining settings as the default

        image6

      • Now click on H.264, AAC under Output section to provide Output configuration

        • Under the Encoding settings panel enter 1280 and 720 in the Resolution box (w x h)

        • Ensure Rate control mode is selected to QVBR and enter 3000000 for the Max birate (bit/s)

        • Leave all other settings for Output 1 as the default

          image7

      • Choose the AWS Integration under Job settings section from the left navigation panel

        • Provide IAM role detail under the Service access

        • Select Use an existing role and then select the role starting with mediaconvert-tutorial-xxx-xx

          image8

          Note: This IAMRole should be the same as the IAMRoleForMediaConvert which we deployed via Cloudformation stack under the Prerequisite section

      • Finally, scroll to the bottom of the page and click Create

        • Once the job is submitted

          image9

        • Post the job is completed

          image10

      • Let’s verify the output from the S3 location provide under the output section

        image11

        image12

      • At last, we will export the job as a json file from the Job summary console so we can execute the same via Lambda in an automated fashion

        image13

    • Step 3: Automatation via AWS Lambda

      • Download the MediaConvert Job Template from this link

      • Download the Lambda code for MediaConvert Job from this link

      • Deploy Lambda from the code we downloaded above and provide IAMRoleForLambda which we deployed via Cloudformation stack under the Prerequisite section

        image14

        image15

        image16

      • Now we will test the Lambda, choose the S3 Put event from the list of samples and update the S3 bucket and S3 key details. After changes in the event json save it.

        image17

      • Now click Test and provide event json we saved above and wait for the result

        • Lambda output

          image18

        • S3 bucket output

          image19