Tutorial · Python · ~10 min

Batch Compress Videos

Free up storage and speed up delivery: one queue that re-encodes the library at a consistent quality target.

PythonBatchAPI

Why this matters

Library storage bills grow with every upload. Quality-targeted batch compression cuts size 30–70% while keeping visual quality within a defined score.

Per-file reports make the savings auditable — you can show the storage line going down.

How it works

Submit the folder with a CRF/VMAF target; each file is encoded independently and reported with before/after size and quality score.

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": "h264", "crf": 23, "pattern": "*.mov"}

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

  • Run a 10-file pilot to size the expected savings before the full batch.
  • Exclude already-efficient files (HEVC masters, short clips) via the pattern filter.
  • Verify a sample per batch with the reported VMAF estimates.

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 will my files shrink?

Depends on source: screen content 50–70%, camera content 30–50%, already-encoded content less.

Is it safe to delete the originals?

Only after QC. Keep originals for at least one batch cycle.

Can I set different targets per folder?

Yes — submit each folder as its own batch with its own target.