Tutorial · Go · ~10 min

Convert SDR to HDR in Go

The same SDR-to-HDR pipeline that powers our Python tutorial, with a ready-to-run Go example.

GoAPISDR to HDR

What you will build

A small script that uploads a media file to the SDR to HDR API, polls the job until it finishes, and prints the output URL. The full job lifecycle is the same in every language — only the HTTP client differs.

1. Get an API key

Sign up at mlslabs.io and copy your key from the dashboard. Every request sends it in the X-API-Key header.

2. Submit the job

Go
package main

import (
    "bytes"
    "encoding/json"
    "fmt"
    "net/http"
    "time"
)

func main() {
    var payload map[string]any
    _ = json.Unmarshal([]byte(`{"input": "s3://bucket/video.mp4", "preset": "cinema", "output": "s3://bucket/hdr.mp4"}`), &payload)
    body, _ := json.Marshal(payload)
    req, _ := http.NewRequest("POST", "https://api.mlslabs.io/v1/sdr2hdr/jobs", bytes.NewReader(body))
    req.Header.Set("X-API-Key", "YOUR_API_KEY")
    req.Header.Set("Content-Type", "application/json")
    resp, _ := http.DefaultClient.Do(req)
    var job map[string]any
    json.NewDecoder(resp.Body).Decode(&job)
    resp.Body.Close()
    for job["status"] != "succeeded" && job["status"] != "failed" {
        time.Sleep(3 * time.Second)
        r, _ := http.NewRequest("GET", job["url"].(string), nil)
        r.Header.Set("X-API-Key", "YOUR_API_KEY")
        r2, _ := http.DefaultClient.Do(r)
        json.NewDecoder(r2.Body).Decode(&job)
        r2.Body.Close()
    }
    fmt.Println("Output:", job["output_url"])
}

3. Poll until it finishes

Jobs run asynchronously — you get a job URL back immediately, then poll status until it reaches succeeded or failed. Most jobs finish in seconds to a few minutes depending on input length.

4. Download the result

The output_url points at your rendered file in object storage. Pipe it straight into your pipeline: transcode the HDR master, upload the cleaned episode, or ship the SRT to your translation vendor.

Same job, any language

The request body is identical across languages — a JSON payload with input, options, and an optional webhook. Point the same payload at our webhook URL and you do not even need the polling loop.

FAQ

Common questions

Does the API run on my GPU?

No. Rendering happens on mlslabs GPU workers, so the script runs on any machine — a laptop, a Lambda, or a CI runner.

Can I swap the API key at runtime?

Yes — read it from an environment variable or secret store instead of hardcoding it.

What formats does the output support?

MP4, MOV and MKV for video APIs; WAV, MP3 and FLAC for audio APIs. Set the format in the job payload.