Tutorial · Python · ~10 min
Batch Convert SDR to HDR
One script, an S3 folder, and every episode comes back HDR-ready — with per-file status and retries handled by the platform.
Why this matters
A 50-episode drama is not 50 conversions you babysit — it is one queue. Batch workflows need queueing, retries, and per-file status, not a loop that crashes at episode 12.
The mlslabs API accepts a folder prefix and renders each matching file as an independent job with its own URL and status.
How it works
Point the API at a folder or manifest, choose the preset, and poll the batch endpoint. Each file becomes a job; failures are isolated and retried.
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
import requests, time
API = "https://api.mlslabs.io/v1/sdr2hdr/jobs"
headers = {"X-API-Key": "YOUR_API_KEY"}
payload = {"input": "s3://bucket/season1/", "preset": "cinema", "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
- Run a 3-file smoke batch with your exact preset before the full library.
- Store per-file status in your pipeline table so the UI can show progress.
- Schedule batches off-peak — bandwidth is cheaper and output buckets are quieter.
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
How does the API know which files to convert?
Pass a folder prefix (s3://bucket/folder/) and an optional glob pattern like *.mp4.
What happens if one file fails?
That job is marked failed and retried up to 3 times. Successful files are unaffected.
Can I prioritize some files?
Yes — submit them as individual jobs with a higher priority flag; batch jobs run at default priority.
Keep exploring