LESSON 05 · Metadata and visibility

Publish only a playable video

Keep queryable metadata separate from media bytes and make state changes explicit.

SYSTEM VIEW

The video path

Diagram view
Video status—
Manifests—
Time—

Follow video 81 from processing to ready, where a verified check, not a worker’s report, changes its status.

  1. Video 81’s row in the Metadata DB holds its owner, title, visibility, duration, status and manifest pointers: a few kilobytes that must support queries. Video storage holds the multi-gigabyte files, read as streams. The Metadata cache speeds hot reads, but the DB stays authoritative.

    What changed

    • Row: a few KB, queried
    • Files: multi-GB, streamed
    • Cache speeds hot reads
  2. A viewer opens video 81’s watch page. The Watch API reads the row through the Metadata cache and returns processing, with no manifest URL. Completion may span storage and database writes without one atomic transaction, so status moves only along allowed transitions.

    Status path
    pending → uploaded → processing
    Then
    ready or failed

    What changed

    • GET /watch/v81
    • Status: processing
    • No manifest URL returned
  3. At 10:00 a worker reports done. The Verifier checks the main manifest and all four rendition manifests in Video storage, finds the 1080p one absent, and leaves the status at processing.

    Expected
    main + 4 renditions
    Found
    4 of 5

    What changed

    • Worker reports done at 10:00
    • 1080p manifest absent
    • Status stays processing
  4. A retry writes the missing manifest. At 10:05 the Verifier finds all five and runs the equivalent of SET status = ready WHERE status = processing. The Metadata DB now says ready, and the cached entry is refreshed.

    Update
    SET status = ready
    Only where
    status = processing

    What changed

    • Retry writes the 1080p manifest
    • 5 of 5 found at 10:05
    • Status: processing → ready
    • Cache entry refreshed
  5. The worker’s done event arrives again. Repeats are normal: Amazon S3 event notifications, for instance, arrive at least once and without guaranteed order. The update runs again, but WHERE status = processing matches no row, so 0 rows change and video 81 stays ready.

    Where
    status = processing
    Matches
    0 rows

    What changed

    • Done event, again
    • 0 rows changed
    • Status stays ready
  6. The viewer opens video 81’s watch page again. The refreshed cache entry says ready, so the Watch API returns a permitted manifest location and the player can start.

    What changed

    • Cache returns ready
    • Manifest URL returned
  7. A Reconciler, a background job, compares the Metadata DB with what Video storage holds and can find stuck jobs, orphaned objects and missing outputs. The cost is more states for the interface and support staff to explain; an internal tool that encodes while the uploader waits could manage with one flag.

    What changed

    • Reconciler takes the Verifier’s place
    • Looks for stuck jobs and orphans

Space plays · ← → step · Home resets

THE IDEA

How it works

Store ownership, title, visibility, duration, status, and pointers to manifests or thumbnails in a metadata database. Keep original and encoded bytes in object storage. The two have little in common: a row of a few kilobytes that must support queries, and a multi-gigabyte file read as a stream. A cache can accelerate hot metadata reads, but the database remains authoritative; invalidate or update cached entries after writes.

A viewer opening a watch page asks the API for metadata and access policy. It returns a permitted manifest location only when status is ready; before then the interface shows processing or a clear failure. Completion may span storage and database operations without one atomic transaction, so use a durable state machine: a status that moves only along allowed transitions, such as pending, uploaded, processing, then ready or failed.

Follow one publication. A worker reports “done” at 10:00. A verifier checks the main manifest and all four rendition manifests in storage, finds one absent, and leaves the status at processing. A retry writes it. At 10:05 the verifier passes and runs the equivalent of SET status = ready WHERE status = processing, so a repeated event changes nothing. Repeats are normal: Amazon S3 event notifications, for instance, arrive at least once and without guaranteed order.

Reconciliation, a background job comparing database state with what storage actually holds, can find stuck jobs, orphaned objects, and missing outputs. The cost is more states for the interface and support staff to explain. An internal tool that encodes while the uploader waits could manage with one flag.

DECISION POINT

A worker reports success, but the manifest is absent from storage. Should the watch page expose the video?

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

Keep in mind

  • Metadata describes and authorizes media; object storage holds the bytes.
  • Publication is a validated state transition, not a queue acknowledgment alone.
CHECK YOUR UNDERSTANDING

Put it into practice.

1 OF 3
ApplyQUESTION 01

A creator shares a watch link while only 480p has finished, and required renditions and the manifest are still pending. What should the watch API return?

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.