Create an Automatic video transcoding using AWS Elastic MediaConverter for a Video Streaming App
Automatic video transcoding using AWS Elastic MediaConverter offers a powerful solution for streaming apps to handle various video formats and resolutions efficiently.
Objectives
The objective was to set up an automatic workflow to transcode a media object to different types of formats and resolution using AWS MediaConverter and Transcoding Job.
The client provides various kinds of financial services to their customers all over the world. They had recently planned to build a mobile app which helps the end signed user to learn more about financial courses. Initially the client had built their application in AWS Cloudfront with encrypted signed urls. However, the Cloudfront charges had become very high due to the large number of video downloads and streaming. The client had approached us to find a solution to reduce AWS cost to optimum level. So we planned to create an architecture of an online video streaming without using Cloudfront. Instead of Cloudfront, we used AWS Media Converter and KMS encryption to achieve the automatic video conversion and passed to the application level. The client’s development team had worked on integrating the encrypted & converted urls from AWS Mediaconverter to their mobile app.
In a nutshell, the following were the main requirements from the client side.
Client Requirements:
- Create an automated transcoding job to convert input media files in a S3 bucket to transcoded media files as output and keep the thumbnail images.
- The conversion task is triggered when the user uploads a media file to the input S3 bucket. Notification service and triggering is handled by SNS & Cloudwatch.
- Arrange the transcoded outputs files to respective names of folders in the output S3 bucket.
- Setup KMS for video encryption and decryption.
The Workflow of the Environment setup
- A user uploads a MP4 video object to the input directory of the S3 bucket. Whenever an object is added to the inputs folder, workflow will be triggered.
- The s3:PutItem event triggers a Lambda function that calls MediaConvert to convert the video to different resolutions.
- Converted videos are stored in the configured S3 output folder by MediaConvert.
- When the conversion job finishes, MediaConvert sends a report to CloudWatch events with the job status.
- The complete and error status events trigger SNS to send notifications to the administrator.
Tools Used
- Json script
- Python Script
- AWS Lambda
- AWS MediaConverter
- AWS KMS
- AWS Cloudwatch
- AWS SNS
- AWS IAM
- AWS S3 Buckets
Results
We deployed the stack script and modified the JSON & Python scripts to achieve the desired output in AWS.
- Uploaded a MP4 video file to the input folder of the S3 bucket by using the upload option in the bucket.
- Once the upload was completed, the mediaconverter service was opened and the jobs option selected. The mediaconverter started to convert the media file and completed status was shown when the job was done.
- The converted media files are stored in the output folder of the S3 bucket.
- The programmer used KMS for decrypting the video files from their application and also enabled a sign-in option to watch and download the videos.