Tutorial · Python · ~10 min

Build a Low-Latency Live Encoding Pipeline

Live latency is a pipeline property, not a knob. Here is the encode path that keeps it low end-to-end.

PythonLiveAPI

Why this matters

For sports, auctions, and live commerce, every second of glass-to-glass latency hurts. The encode stage matters: GOP size, B-frame settings, and segment length all add delay.

A low-latency encode preset trades a little compression efficiency for dramatically shorter delay — the right trade when seconds are money.

How it works

Point the API at your RTMP/SRT ingest with mode=low-latency; it produces short-GOP, segment-aligned renditions for low-latency HLS or WebRTC.

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": "rtmp://ingest.example.com/live/feed", "codec": "hevc", "mode": "low-latency", "ladder": [[1920, 6000000], [1280, 3200000]]}

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

  • Keep GOP ≤ 2s and segment length ≤ 1s for sub-3s latency.
  • Use SRT ingest over public internet — it recovers from jitter without rebuffering.
  • Deliver via low-latency HLS or WebRTC; plain HLS adds 6–10s no matter the encoder.

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

What is the achievable latency?

Typical glass-to-glass is 2–4s with LL-HLS and ~1s with WebRTC, depending on player and network.

Does it support multiview?

Yes — inputs can be composed; ask about the multiview preset.

Is there a 24/7 reliability SLA?

Yes — live jobs support health checks and automatic failover to a second ingest.