Tutorial · Python · ~10 min
How to Convert SDR to HDR in Python
In this tutorial you will convert an SDR clip to HDR10 in under 10 minutes. No footage of your own? Use the free sample clips from our cloud library.
Before you start
Prerequisites
- A free mlslabs account and API key (2 minutes)
- Python 3.9+
- pip install mlslabs
- A sample video URL — or use our cloud sample (landscape-sdr.mp4)
Step 1 — Install the SDK
The SDK wraps the async job model: submit, poll or webhook, download.
Bash
pip install mlslabsStep 2 — Set your API key
Keys are scoped per project and rotate anytime from the dashboard.
Python
import mlslabs
client = mlslabs.Client("YOUR_API_KEY")Step 3 — Submit a conversion job
| Parameter | Options | Notes |
|---|---|---|
| output_format | hdr10 / hlg | HDR10 is the compatibility baseline |
| resolution | preserve / upscale_4k | Upscale before grading if your master is SD/HD |
| preset | cinema / dynamic | Scene analysis mode for the conversion |
Python
job = client.sdr2hdr.submit(
input_url="s3://bucket/landscape-sdr.mp4",
output_url="s3://bucket/landscape-hdr.mp4",
output_format="hdr10", # hdr10 | hlg
resolution="preserve", # preserve | upscale_4k
)
print(job.job_id)Step 4 — Poll the job status
Python
job.wait() # blocks until done or failed
print(job.status) # done
# or register a webhook and skip polling entirelyStep 5 — Download and verify
Bash
# download the HDR master
curl -L -o landscape-hdr.mp4 <output_url>
# verify with ffprobe: 10-bit, BT.2020, PQ transfer
ffprobe -show_streams landscape-hdr.mp4 | grep -E "pix_fmt|color"
# => pix_fmt=yuv420p10le, color_transfer=smpte2084, color_primaries=bt2020Troubleshooting
| Error | Cause | Fix |
|---|---|---|
| 401 invalid_api_key | Wrong or expired key | Rotate the key in the dashboard |
| 413 file_too_large | Input over size limit | Use object storage input URLs |
| 429 rate_limit_exceeded | Free-tier rate limit | Upgrade tier or back off |
Keep exploring