Tutorial · Python · ~10 min

Convert Video to SRT

One endpoint, two paths: OCR for burned-in text, extraction for embedded tracks. Either way you end up with a standard SRT file.

PythonSRTAPI

Why this matters

SRT is the lingua franca of subtitles — every platform, editor, and translation vendor accepts it. Getting video into SRT is the recurring first step of localization.

For soft-subtitle sources, embedded tracks extract losslessly; for hardcoded sources, OCR does the job.

How it works

Pass the video URL; the API detects the best path (embedded track or OCR) and returns SRT, VTT, or ASS.

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/subtitle-extractor/jobs"
headers = {"X-API-Key": "YOUR_API_KEY"}
payload = {"input": "s3://bucket/video.mp4", "output_format": "srt"}

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

  • Set output_format=srt unless you need styling (ASS) or web captions (VTT).
  • For embedded tracks, extraction is instant and lossless.
  • Re-run OCR on a cleaned master if accuracy is critical.

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

Can it also extract from MKV?

Yes — MKV embedded tracks are supported; hardcoded MKV subtitles go through OCR like any other source.

Are timings preserved from embedded tracks?

Yes — embedded timing is kept exactly.

Is SRT UTF-8?

Yes, UTF-8 with BOM optional — safe for Chinese, Japanese, and Korean.