LESSON 03 · Transcoding pipeline

Process video off the request path

Use a queued task graph so independent work runs in parallel and failed tasks can retry.

SYSTEM VIEW

The video path

Diagram view
Tasks—
Workers—
Video status—

Watch video 81’s source become 150 parallel tasks, survive a worker crash, and publish only when its outputs exist.

  1. Video 81’s source is verified, so an ingestion event starts a processing job. The Scheduler builds a DAG, tasks with dependency arrows and no loops: inspect first, then audio, video renditions, thumbnails and optional moderation, and the manifest last, since it lists their outputs.

    First
    inspect
    Then
    audio, video, thumbs
    Last
    manifest

    What changed

    • Processing job for video 81
    • Task graph, inspect first
    • Video status: processing
  2. The Scheduler queues inspect v81. Messages carry object keys and job IDs, not media: the Worker reads v81/source.mp4 from Video storage and writes 30 aligned 2-minute chunks, each starting on a frame that decodes alone. Then the tasks that waited on inspect are released.

    Source
    60 min
    Chunks
    30 × 2 min

    What changed

    • inspect v81
    • 30 chunks in storage
    • Waiting tasks released
  3. 30 chunks × 5 renditions gives 150 encode tasks, and none depends on another, so they run in parallel. At 4 minutes per task one worker needs 10 hours; 50 workers, 3 tasks each, finish in about 12 minutes.

    Per task
    4 min
    1 worker
    10 h
    50 workers
    about 12 min

    What changed

    • 150 encode tasks
    • 50 workers, 3 tasks each
    • About 12 min, not 10 h
  4. Worker 1 leases encode 720p · c07, writes v81/720p/c07, then dies before its ack. The lease expires and Worker 2 gets the task again. The output key is fixed, so Worker 2 finds the output, verifies it and acks: the repeat does no harm.

    Output key
    v81/720p/c07
    Lease
    expires on crash

    What changed

    • Worker 1 crashes before its ack
    • Lease expires, task redelivered
    • Output verified, not duplicated
  5. Retries are bounded. Pick a failure for video 82. Keeps failing: a task fails on both workers, its retries run out, and it moves to Dead letters for operators. Bad source: inspect hits a decode error, a terminal validation error, so it fails at once with no retry.

    Transient
    retry, bounded
    Persistent
    dead letters
    Malformed
    fail, no retry

    What changed

    • Dead letters, for operators
    • Retries bounded
    • Bad source fails at once
    Failure
  6. Back to video 81. Its renditions, audio and thumbnails are in Video storage, so the Scheduler releases its last task. Worker 2 writes the manifest, the player’s index file, and only with every required output in place does video 81 become ready.

    Publish after
    outputs + manifest

    What changed

    • v81 manifest
    • Video status: ready
  7. A 30-second video needs none of this: one FFmpeg job reads the source and writes the outputs. Workflow engines such as Temporal or AWS Step Functions can hold a long job’s state, but they add a dependency to learn and run.

    What changed

    • No Scheduler or queues needed
    • One FFmpeg job for a 30 s clip

Space plays · ← → step · Home resets

THE IDEA

How it works

Once the source is verified, an ingestion event starts a processing job. A scheduler builds a directed acyclic graph (DAG), a set of tasks with dependency arrows and no loops: inspect first; then audio encoding, video renditions, thumbnails, and optional moderation can run where dependencies allow. Workers read the durable original and write outputs to object storage. Queue messages carry object keys and job IDs, not the media itself.

A preprocessor can inspect tracks and create aligned media chunks for parallel encoding. For example, a 60-minute source cut into 2-minute chunks with five renditions gives 150 encode tasks. At 4 minutes per task, one worker needs 10 hours; 50 workers could finish in about 12 minutes. Each chunk must start on a frame that decodes alone, a constraint resumable upload parts do not have.

Queues absorb bursts but backlog still needs limits and monitoring. Persist task state, lease work (a claim that expires if the worker dies), retry transient failures with bounds, and send persistent failures to a dead-letter path, a queue operators can inspect. Make outputs idempotent, safe to produce twice, because a worker can fail after writing but before acknowledging. Publish only after required renditions and the manifest, the player’s index file, exist. A malformed source is a terminal validation error; repeating the transcode will not repair it.

Workflow engines such as Temporal or AWS Step Functions can hold this state, though they add a dependency to learn and run. A short clip does not need any of it: a 30-second video can go through one FFmpeg job.

DECISION POINT

A worker dies after writing the 720p output but before acknowledging. What happens on redelivery?

Write a sentence or two to unlock the guidance. Committing first is what makes it stick.

Keep in mind

  • Express dependencies explicitly; parallelize only independent tasks.
  • Retries need durable state, idempotent outputs, and a terminal failure path.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
ApplyQUESTION 01

After inspection, a job needs an audio encode, a 720p encode, a thumbnail, and a manifest. What can run at the same time?

Choose an answer. You’ll see the explanation once you get it right.

Next lesson

0 of 3 checkpoints answered correctly to complete this lesson.