DEV Community

Cover image for AWS Elemental MediaConvert: The Video Service Every Developer Should Know
Tanseer for AWS Community Builders

Posted on

AWS Elemental MediaConvert: The Video Service Every Developer Should Know

About this series

Most AWS learning stops after EC2, S3, IAM, and Lambda. But AWS has over two hundred services, and many of the most useful ones rarely appear in tutorials.

AWS Hidden Gems covers those underrated services you shouldn't ignore. Each article picks one, then explains why it exists, what it does, where it fits, and how to set it up from the console. Know the four basics above and you can follow along. Everything else gets explained as it comes up.

Today's service: MediaConvert

Almost every app has video in it, and every video hides one boring step: converting the raw file into formats that phones, laptops, TVs, and slow networks can all play. That is what MediaConvert does.

Why does this service exist?

Transcoding means rewriting a video into a different format, quality, or resolution. You need it because one file cannot serve every viewer. A weak mobile connection needs a small version. A fast home connection wants the crisp one.

Before AWS, teams ran FFmpeg (a free tool that converts almost any video) on their own server fleets. Those servers were expensive, sat idle between uploads, and needed constant patching. Getting broadcast quality output took specialist knowledge most teams did not have.

MediaConvert removes all of that. You hand it a file, it does the work on infrastructure you never manage, and you pay only for the minutes you process.

What is MediaConvert?

MediaConvert is a fully managed, file based video transcoding service. Fully managed means AWS runs the servers for you. File based means it works on complete video files that already exist, usually in S3, not on live streams.

What it does:

  • Changes the codec, the compression method, such as H.264 or the newer H.265
  • Changes resolution, so one 4K master becomes 1080p, 720p, and 480p
  • Adjusts bitrate, the data used per second and the main quality versus size lever
  • Adds captions, extra audio tracks, logo overlays, and thumbnails
  • Packages video for streaming with HLS and DASH, the formats behind adaptive bitrate, where the player switches quality as the network changes What it does not do is store or deliver your videos. Storage is the job of S3. Delivery is the job of CloudFront, a network that keeps copies of your files close to users.

A real world problem

An online course startup lets instructors upload lectures from their phones. Files arrive in every format and size. A student on wifi watches fine. A student on mobile data sees the giant 4K file stall every few seconds. Some older devices cannot play certain formats at all.

The startup cannot control how instructors record or how students watch. It can only fix the middle: convert every upload into a consistent set of streaming friendly versions. That is what MediaConvert is for.

Real world use cases

  • Streaming platforms turn studio master files into every quality level for phones, browsers, and TVs
  • Education platforms standardize instructor uploads so playback never depends on someone's recording setup
  • Healthcare processes recorded procedures and telehealth sessions into required formats for review and archiving
  • Finance and enterprise transcode earnings calls and training, captioned for accessibility and stored for the long term
  • Ecommerce converts product and review clips into fast loading versions that do not slow the page
  • Gaming and social apps normalize huge volumes of user uploaded clips into formats the app can play The pattern is always the same. Video comes in messy, and it leaves clean and ready to play.

Where it fits in AWS

A common setup: a video lands in S3, the upload triggers a Lambda function, Lambda starts a MediaConvert job, MediaConvert reads the file and writes converted versions back to S3, and CloudFront delivers them worldwide. MediaConvert reports progress through EventBridge, the AWS service for reacting to events, and it accesses S3 using an IAM role, a set of permissions a service borrows to act for you.

flowchart LR
    A[User uploads video] --> B[S3 input bucket]
    B -->|Upload event| C[Lambda function]
    C -->|Start job| D[MediaConvert]
    B -->|Reads source file| D
    D -->|Writes outputs| E[S3 output bucket]
    E --> F[CloudFront]
    F --> G[Viewers on any device]
    D -->|Job status| H[EventBridge]
Enter fullscreen mode Exit fullscreen mode

MediaConvert is the processing engine in the middle. Everything around it is handled by services built for that job.

How the workflow runs

The unit of work is a job: one input file, the outputs you want, and the IAM role to use. A job is submitted, waits in a queue, gets processed on managed infrastructure, and writes its outputs to S3 when done. Status updates flow through EventBridge the whole time, and failures come back with an error message.

Two features save repetition. Presets store output settings, so you set 1080p H.264 once and reuse it. Job templates store a whole job's settings, so your standard outputs become a one line request.

flowchart TD
    A[Job submitted] --> B[Job waits in queue]
    B --> C[MediaConvert processes it]
    C --> D{Success?}
    D -->|Yes| E[Outputs written to S3]
    D -->|No| F[Job marked with error]
Enter fullscreen mode Exit fullscreen mode

Setting it up in the AWS Console

Before you start, upload a short sample video to an S3 bucket. Note the bucket name and the folder where you want the output. Keep the file small so your first job finishes quickly.

  1. Sign in to the AWS Console, type MediaConvert into the search bar at the top, and open it. Look at the region shown in the top right corner and make sure it matches the region of your S3 bucket. MediaConvert reads from and writes to S3, so keeping both in the same region avoids extra data transfer charges and keeps the job faster.
  2. Click Create job. The page splits into two halves. The left panel is where you add the parts of your job, meaning the input and the output groups. The right panel is where you edit the settings for whatever part you have selected.
  3. In the Input section on the left, paste the full S3 path to your sample video, for example s3://your-bucket-name/sample.mp4. This is the file MediaConvert will read. Check the path carefully, because a wrong path or a missing file extension is the most common reason a job fails right away.
  4. In the left panel, find Output groups and click Add. MediaConvert asks what kind of group you want. Choose File group for this first test, which produces one converted file rather than a segmented streaming package, so it is the simplest way to confirm the flow works. Open the group and set its Destination to the S3 folder for your output, for example s3://your-bucket-name/output/.
  5. Inside the output group there is an output entry. Select it and set three things on the right: the video codec to H.264, which every device supports, the resolution to 1280 by 720, and the audio settings left at their defaults. These few values are enough to produce a clean, playable file.
  6. Scroll to the Job settings section and find the service access or IAM role option. MediaConvert needs a role that lets it read your input bucket and write to your output bucket. For a first job, pick the option that lets the console create this role for you. If you prefer to build it yourself, the role needs a trust policy allowing the MediaConvert service to assume it, plus s3:GetObject on the input bucket and s3:PutObject on the output bucket.
  7. Leave the default on demand queue selected. You do not need reserved capacity to start.
  8. Click Create at the bottom. The job appears with a status of Progressing. For a small file it changes to Complete within a minute or two. Open your output folder in S3, download the converted file, and play it to confirm the transcode worked. Common mistakes: a permissions error almost always means the IAM role cannot reach one of your buckets, so check that it covers both the input and the output. A job that fails right away usually means the input path is wrong, so confirm it exactly, including the file extension.

Starting a job with code

Clicking through the console is fine for learning, but in a real system you want jobs to start on their own. The usual pattern is a Lambda function that runs whenever a new video lands in S3 and tells MediaConvert to start a job.

One detail trips up newcomers. MediaConvert gives each account its own endpoint, which is its own address, so you fetch that endpoint once and build the client with it. To keep the code short, first save your settings from steps 4 and 5 as a job template in the console. The template holds the codec, resolution, and output destination, so the function only has to pass the input file.

import boto3

# MediaConvert has a per account endpoint, so fetch it once when the function loads.
default_client = boto3.client("mediaconvert")
endpoint = default_client.describe_endpoints()["Endpoints"][0]["Url"]
mediaconvert = boto3.client("mediaconvert", endpoint_url=endpoint)

def lambda_handler(event, context):
    # The S3 event tells us which file was just uploaded.
    record = event["Records"][0]["s3"]
    source = f"s3://{record['bucket']['name']}/{record['object']['key']}"

    response = mediaconvert.create_job(
        Role="arn:aws:iam::123456789012:role/MediaConvertRole",
        JobTemplate="my-video-template",
        Settings={
            "Inputs": [{"FileInput": source}]
        },
    )

    print("Started MediaConvert job:", response["Job"]["Id"])
    return {"jobId": response["Job"]["Id"]}
Enter fullscreen mode Exit fullscreen mode

To make this run on its own, add an S3 trigger on your input bucket that invokes the function on new uploads, and give the function's role permission to call MediaConvert and to pass the MediaConvert role.

Pricing

Item Detail
Billing unit Per minute of output video, prorated per second
Billed on Output, not input
Output math One 10 minute video into 3 versions = 30 output minutes
Basic tier HD About $0.015 per minute (US, on demand)
Basic tier SD Lower than HD
Basic tier 4K Higher than HD
Professional tier Higher rate, for advanced broadcast features
Cost example 100 videos x 10 min x 2 HD versions = 2,000 min, about $30 per month
Free tier Monthly allowance of basic tier output minutes for 12 months
Reserved pricing Lower rate for large, predictable monthly volume

The AWS media services family

AWS Media Services
├── MediaConvert   file based transcoding for existing videos
├── MediaLive      real time encoding for live broadcasts
├── MediaPackage   packages and protects streams for delivery
├── MediaConnect   reliable transport of live video
├── MediaTailor    inserts personalized ads into streams
└── Amazon IVS     managed low latency interactive live streaming
Enter fullscreen mode Exit fullscreen mode

The key split is file versus live. MediaConvert handles finished files. MediaLive and IVS handle video happening right now. If your video already exists, MediaConvert is the tool.

Wrapping up

MediaConvert takes video in any shape and produces clean, playable versions for every device and network, with no servers to run. Next time you build anything with video, you know the managed service that does the heavy lifting and how to wire it up.

Series progress

You are on stop one of AWS Hidden Gems.

  1. AWS Elemental MediaConvert (you are here)
  2. Amazon IVS
  3. Amazon Rekognition
  4. Amazon Personalize
  5. AWS AppSync Next up is Amazon IVS, which picks up where MediaConvert stops, handling live and interactive video.

Let's connect

Questions, corrections, or want to talk through where this fits in your own project? Reach me at khantanseer43@gmail.com.

Top comments (0)