Tutorial · Python · ~10 min

Reduce Streaming Bandwidth Costs

Bandwidth is the quiet line item that scales with success. HEVC cuts it — here is how to measure and automate the win.

PythonBandwidthAPI

Why this matters

CDN egress is billed by the byte; a 40% bitrate cut on every stream is a 40% cut on egress. For popular titles that is real money every month.

The rollout needs per-title measurement — encode a sample, measure bitrate at the same quality score, and project the savings before touching the catalog.

How it works

Encode a representative sample with codec=hevc at your quality target, read the bitrate reports, then batch the library and monitor the CDN bill.

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": "s3://bucket/library/", "codec": "hevc", "crf": 26, "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

  • Measure on your top-20 titles first — savings are proportional to play counts.
  • Account for the HEVC patent license fee in the ROI math.
  • Keep an H.264 fallback rung for legacy players; stream HEVC to capable devices.

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 much can I actually save?

Typical HEVC savings are 30–50% bitrate at the same VMAF; multiply by egress price per GB for your number.

What about AV1?

AV1 saves more on modern devices but encode cost and older-player support still vary — a later stage.

Does the API handle the license reporting?

We report exactly which titles were HEVC-encoded so your license accountant can work from the data.