Transcoding Video with S3 and Elastic Transcoder

1 hour
  • 4 Learning Objectives

About this Hands-on Lab

In this hands-on AWS lab, we’ll learn how to convert video files to different formats using Lambda, S3, and Amazon Elastic Transcoder.

Elastic Transcoder is a media service designed to be a highly scalable, easy-to-use, and cost-effective way to convert (or “transcode”) media files from their source format into versions that will play back on devices like smartphones, tablets, and PCs.

In this lab, you will upload 4K Ultra HD sample videos to an S3 bucket and configure an Elastic Transcoder pipeline to automatically convert them to different formats. We’ll set all this up with our own custom Lambda function — written in Python — using the Boto3 SDK.

– Download the sample 4K videos [here](https://raw.githubusercontent.com/linuxacademy/content-lambda-boto3/master/Video-Transcoding/Aerial.mp4) and [here](https://raw.githubusercontent.com/linuxacademy/content-lambda-boto3/master/Video-Transcoding/Clouds.mp4).
– Download the Lambda execution role IAM policy [here](https://raw.githubusercontent.com/linuxacademy/content-lambda-boto3/master/Video-Transcoding/lambda_execution_role.json).
– Download the Lambda function source code [here](https://raw.githubusercontent.com/linuxacademy/content-lambda-boto3/master/Video-Transcoding/lambda_handler.py).

Learning Objectives

Successfully complete this lab by achieving the following learning objectives:

Subscribe to an SNS topic.
  1. In the AWS Management Console, navigate to the SNS service.
  2. Select the Transcode topic.
  3. Under Actions, select Subscribe to topic
  4. In the Protocol dropdown box, select Email.
  5. In the Endpoint box, type an email address you can use to receive the notification.
  6. Click Create subscription.
  7. Go to your email application, and open the message from AWS Notifications.
  8. Click the link to confirm your subscription.
Create Elastic Transcoder pipeline.
  1. In the AWS Management Console, navigate to Elastic Transcoder.
  2. Under Pipelines, select Create New Pipeline.
  3. Pipeline Name: Enter any name you like.
  4. Input Bucket: Select the existing bucket with source in the name.
  5. Allow the IAM role to be created automatically.
  6. For transcoded files, select the existing bucket with transcoded in the name.
  7. Storage Class: Choose either Standard or Reduced Redundancy.
  8. For thumbnails, select the existing bucket with thumbnails in the name.
  9. Storage Class: Choose either Standard or Reduced Redundancy.
  10. Note the Pipeline ID. This is available under pipeline details and is a different value than the pipeline name.
Create Lambda function.
  1. In the AWS Management Console, navigate to AWS Lambda.
  2. Select Create Function.
  3. Give the function any name you like.
  4. For runtime, choose Python 3.7.
  5. Create a custom role, using the IAM policy here.
  6. Select Create Function.
  7. Select S3 as the trigger, and choose the bucket with source in the name.
  8. Select All object create events.
  9. Click Add.
  10. Click the function name at the top of the page to enable the function editor.
  11. Paste in the function body using the source code here.
  12. Set an environment variable called PIPELINE_ID and set its value to the pipeline ID from the previous task.
  13. Save the Lambda function.
Upload video for transcoding.
  1. Download the sample 4K videos here and here.
  2. Navigate to the S3 bucket with source in its name.
  3. Upload one of the 4K video files.
  4. Observe in CloudWatch Logs and in your email inbox that the transcoding job completed successfully.
  5. Navigate to the S3 bucket with transcoded in its name.
  6. Verify that 1080p and 720p versions of your uploaded video are present.

Additional Resources

Make sure you are in the us-east-1 region.

S3 buckets and an SNS topic are provided for you.

  • Download the sample 4K videos here and here.
  • Download the Lambda execution role IAM policy here.
  • Download the Lambda function source code here.

What are Hands-on Labs

Hands-on Labs are real environments created by industry experts to help you learn. These environments help you gain knowledge and experience, practice without compromising your system, test without risk, destroy without fear, and let you learn from your mistakes. Hands-on Labs: practice your skills before delivering in the real world.

Sign In
Welcome Back!

Psst…this one if you’ve been moved to ACG!

Get Started
Who’s going to be learning?