Skip to content
Tutorials Center
My learning

Topics

Lesson 38 of 70 ยท Serverless and messaging

MediaConvert (Elastic Transcoder's Successor) and SWF

Learn AWS Elemental MediaConvert for video transcoding (job flow, IAM role, S3 in and out, adaptive bitrate) and Simple Workflow Service (SWF) compared with Step Functions.

Two older-sounding AWS services still show up in exams, in legacy systems and in interviews, and both have clear modern answers. This lesson covers them together because both are about processing work in steps without running your own servers: one converts video files, the other coordinates long-running workflows.

  • AWS Elemental MediaConvert is a file-based video transcoding service. It is the successor to the older Elastic Transcoder, which AWS has retired (or is retiring) and recommends replacing with MediaConvert. If you meet Elastic Transcoder in an old project, plan the migration.
  • Amazon Simple Workflow Service (SWF) is an early AWS workflow engine. For new designs AWS recommends Step Functions, and the lesson explains how the two compare so that you can read old code and answer the question.

Neither service can run on this site. The job JSON and CLI commands are real and read-only. The Python programs are stand-ins: one prepares and checks MediaConvert-style output settings, the other shows the SWF decider and worker loop and the Step Functions equivalent.

Why transcode?

A video you record has one format, resolution and bitrate. Viewers have different screens and networks: a phone on a weak connection needs a small file, a big TV needs a high-resolution one, and a browser may support some codecs but not others. Transcoding converts the source into the versions you need. For streaming, you create a bitrate ladder, several renditions of the same video, so the player can switch quality as the connection changes (adaptive bitrate, often with the HLS or DASH formats).

Doing this on your own EC2 servers with a tool like FFmpeg works, but you manage the fleet and the queue. MediaConvert does it as a service: you pay per minute of output video, by resolution and features, and AWS provides the compute.

The MediaConvert job flow

The workflow is simple, and it fits the event-driven pattern of the image pipeline project:

flowchart LR
    U["Upload video<br/>to S3 input bucket"] --> E["S3 event"] --> L["Lambda<br/>creates a job"]
    L --> M["MediaConvert job<br/>reads input, writes outputs"]
    M --> O[("S3 output bucket<br/>MP4 / HLS renditions")]
    M --> EB["EventBridge<br/>job complete / error"]
    O --> CF["CloudFront<br/>delivers to viewers"]

An upload starts a job. MediaConvert writes the outputs to S3 and reports status to EventBridge.

The main objects:

  • Job: one unit of work. It names the input file(s) and describes the outputs.
  • Output groups: the kind of result. A File group produces ordinary files such as MP4. Apple HLS and DASH ISO groups produce segmented adaptive-streaming packages with a manifest. CMAF is a common format that serves both.
  • Outputs and presets: each output has video settings (codec such as H.264, resolution, bitrate), audio settings and a container. A preset is a saved output configuration. A job template saves a whole job description.
  • Queues: jobs wait in a queue. The default queue is on-demand. You can buy a reserved queue for steady, predictable volumes.
  • The IAM role: MediaConvert reads and writes S3 on your behalf, so you give it a role that it assumes. Whoever creates the job also needs iam:PassRole on that role, to prove they may hand it to the service.

The role's trust policy names mediaconvert.amazonaws.com, and its permissions allow reading the input bucket and writing to the output bucket (read-only):

JSON
{
  "Version": "2012-10-17",
  "Statement": [
    { "Effect": "Allow", "Action": "s3:GetObject",  "Resource": "arn:aws:s3:::my-video-input/*" },
    { "Effect": "Allow", "Action": "s3:PutObject",  "Resource": "arn:aws:s3:::my-video-output/*" }
  ]
}

A trimmed job description for two MP4 renditions looks like this. The real JSON has many more optional fields; the console can export a full one for you (read-only):

JSON
{
  "Role": "arn:aws:iam::123456789012:role/MediaConvertRole",
  "Settings": {
    "Inputs": [{
      "FileInput": "s3://my-video-input/uploads/intro.mov",
      "AudioSelectors": { "Audio Selector 1": { "DefaultSelection": "DEFAULT" } }
    }],
    "OutputGroups": [{
      "Name": "File Group",
      "OutputGroupSettings": {
        "Type": "FILE_GROUP_SETTINGS",
        "FileGroupSettings": { "Destination": "s3://my-video-output/intro/" }
      },
      "Outputs": [
        { "NameModifier": "_720p",  "ContainerSettings": { "Container": "MP4" } },
        { "NameModifier": "_1080p", "ContainerSettings": { "Container": "MP4" } }
      ]
    }]
  }
}

Creating and watching the job:

Terminal
aws mediaconvert create-job --cli-input-json file://job.json --region eu-west-1
aws mediaconvert get-job --id 1700000000000-abcdef --region eu-west-1

Status changes (SUBMITTED, PROGRESSING, COMPLETE, ERROR) are emitted as EventBridge events, so a rule can trigger a Lambda function that updates a database or notifies the uploader. MediaConvert APIs use an account-specific endpoint, which current SDKs find for you.

This stand-in builds a bitrate ladder for a source video and checks the output group against basic rules. It uses plain arithmetic and invented bitrates, not MediaConvert's quality-based encoding.

Python Plan a bitrate ladder

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Transcoding cost is per output minute, so five renditions of a 12-minute video are 60 output minutes. Many teams limit the ladder to what their audience needs.

Good habits for MediaConvert

  • Keep input and output in different buckets or prefixes, so an output file can never trigger the input pipeline again.
  • Use job templates and presets so that the application sends only the file names.
  • Use EventBridge for completion, not polling.
  • Put CloudFront in front of the output bucket for delivery, and use signed URLs or cookies for paid content.
  • Choose the right queue: on-demand for spiky work, reserved for steady volumes. Add a lifecycle rule to expire temporary outputs.
  • For live streaming, MediaConvert is the wrong tool: the Elemental MediaLive service handles live video.

SWF: Simple Workflow Service

Before Step Functions existed, SWF coordinated multi-step applications in which some steps are long, can fail, or wait for people. Its ideas are still worth knowing:

  • A workflow is a program that decides what happens next. SWF stores its history of events (reliably, for up to a year).
  • A decider is code that reads the history and decides the next step ("schedule activity A", "start a timer", "complete the workflow"). Because the decider runs again with the full history after every event, your logic must be deterministic.
  • Activity workers are programs that poll SWF for tasks of a given type, do the work (anywhere: EC2, on premises), and report completion.
  • Tasks are assigned to task lists, which workers poll. Workers and deciders can run on any machine with internet access.

Two more actors complete the picture. Workflow starters are any application that begins a workflow execution (a web app taking an order, a scheduled job). And you or an administrator act as oversight: SWF's console and API let you list, signal, cancel or terminate executions and read their full event history, which is a built-in audit record of what happened and when. The state of each execution is kept by SWF, not by your workers, so a worker can crash and restart without losing the workflow.

You write and host both the decider and the workers. This stand-in shows the loop with a tiny order workflow: the decider looks at the history and picks the next activity.

Python A decider and workers, SWF style

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

SWF versus Step Functions

For new work, AWS points to Step Functions. Compare:

SWF Step Functions
How the flow is defined In code (the decider), which you host and keep deterministic Declaratively, as a JSON state machine (Amazon States Language) with a visual editor
Workers You run activity workers that poll Calls AWS services directly (200+ integrations), Lambda, or activities
Operations You run deciders and workers No servers for the flow itself
Long waits Timers, signals, up to a year Standard workflows up to a year, callbacks with task tokens
Child workflows, retries Coded by you Built in: Retry, Catch, Map, Parallel states
Best for Existing SWF systems, flows needing unusual external logic Almost all new workflows

The same order workflow as a Step Functions definition needs no decider code (read-only):

JSON
{
  "StartAt": "ValidateOrder",
  "States": {
    "ValidateOrder": { "Type": "Task", "Resource": "arn:aws:lambda:eu-west-1:123456789012:function:validate", "Next": "ChargeCard" },
    "ChargeCard":    { "Type": "Task", "Resource": "arn:aws:lambda:eu-west-1:123456789012:function:charge",
                       "Retry": [{ "ErrorEquals": ["States.TaskFailed"], "MaxAttempts": 2 }],
                       "Catch": [{ "ErrorEquals": ["States.ALL"], "Next": "OrderFailed" }],
                       "Next": "ShipItems" },
    "ShipItems":     { "Type": "Task", "Resource": "arn:aws:lambda:eu-west-1:123456789012:function:ship", "Next": "SendReceipt" },
    "SendReceipt":   { "Type": "Task", "Resource": "arn:aws:lambda:eu-west-1:123456789012:function:receipt", "End": true },
    "OrderFailed":   { "Type": "Fail" }
  }
}

An exam answer to "which service coordinates a multi-step workflow with human approval, retries and branching, with the least operations?" is Step Functions. SWF is the answer when the question says the application needs a custom decider or already uses SWF.

Check your understanding

Quick check ยท 5 questions

of 5 answered You scored / 5 ยท perfect!

  1. 1. Which AWS service replaced Elastic Transcoder for converting video files?

    MediaConvert is the file-based transcoding service that succeeds Elastic Transcoder. MediaLive is for live video.
  2. 2. Why does a MediaConvert job need an IAM role?

    MediaConvert assumes the role to access S3. The caller also needs iam:PassRole to hand that role to the service.
  3. 3. What is a bitrate ladder?

    Players switch between the renditions to match the viewer's connection and screen.
  4. 4. In SWF, what does a decider do?

    The decider is your code that runs after each event, so it has to be deterministic. Activity workers poll for and perform the tasks.
  5. 5. For a new workflow with retries, branching and little operations work, what do AWS recommend?

    Step Functions defines the flow declaratively with built-in retry, catch, parallel and map states, and integrates with many AWS services directly.

Summary

  • MediaConvert transcodes video files as a managed service: a job reads from S3, writes outputs to S3 through a role, and reports status to EventBridge. It replaces Elastic Transcoder.
  • Output groups (File, HLS, DASH, CMAF), presets and job templates describe the renditions, and a bitrate ladder supports adaptive streaming.
  • Keep input and output apart, use CloudFront for delivery, and use MediaLive for live video.
  • SWF coordinates workflows with a decider and polling activity workers that you run yourself.
  • Step Functions is the modern, declarative choice for new workflows, with retries, catches and many service integrations built in.

Next: Elastic Load Balancing