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.

PythonSDR2HDRHDR10

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 mlslabs

Step 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

ParameterOptionsNotes
output_formathdr10 / hlgHDR10 is the compatibility baseline
resolutionpreserve / upscale_4kUpscale before grading if your master is SD/HD
presetcinema / dynamicScene 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 entirely

Step 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=bt2020

Troubleshooting

ErrorCauseFix
401 invalid_api_keyWrong or expired keyRotate the key in the dashboard
413 file_too_largeInput over size limitUse object storage input URLs
429 rate_limit_exceededFree-tier rate limitUpgrade tier or back off