Tutorial · Python · ~10 min

Batch Transcode a Video Library to HEVC

The catalog-wide HEVC rollout, staged and measured: pilots, per-title reports, and a queue that runs itself.

PythonBatchAPI

Why this matters

Library-wide codec migration is a staging problem: encode a pilot, measure the savings, then let a queue chew through the catalog in order of value.

Folder-prefix batch jobs keep per-file status and isolate failures, so one broken file never stops the migration.

How it works

Submit the folder with codec=hevc and your CRF target; each title reports bitrate, size, and VMAF so you can verify the savings claim per title.

Submit a job with an input URL (S3, GCS or HTTPS), poll the job URL, and download the rendered output. No GPU, no queues, no ffmpeg builds to babysit.

Code

Python
import requests, time

API = "https://api.mlslabs.io/v1/encode/jobs"
headers = {"X-API-Key": "YOUR_API_KEY"}
payload = {"input": "s3://bucket/library/", "codec": "hevc", "crf": 26, "pattern": "*.mp4"}

resp = requests.post(API, json=payload, headers=headers)
job = resp.json()
while job["status"] not in ("succeeded", "failed"):
    time.sleep(3)
    job = requests.get(job["url"], headers=headers).json()

print("Output:", job["output_url"])

Pro tips

  • Stage by play count: hot titles first, long-tail later.
  • Exclude already-HEVC files with the pattern filter to avoid double encodes.
  • Pause and review after each 10% of the catalog.

Pricing note

Usage is metered per minute of media processed; the first tier is free each month. Volume discounts kick in automatically.

FAQ

Common questions

Does batch support manifests?

Yes — a manifest of URLs or an S3 prefix both work.

What if a title fails?

It is marked failed and retried; you get a per-title report at the end.

How fast is a large library?

Throughput is concurrency-bound; a few thousand titles typically completes within days.