Tutorial · Python · ~10 min

Extract Subtitles from MP4

MP4 is everywhere, and its subtitles hide in two places: metadata tracks or pixels. This covers both.

PythonMP4API

Why this matters

MP4 can carry soft subtitles as metadata tracks, but most short-form exports burn them into pixels instead. The right tool depends on which case you have.

The API probes the container first — if an embedded track exists it extracts it; otherwise it falls back to OCR.

How it works

Submit the MP4 URL and the API auto-detects: embedded track extraction is instant, OCR takes a bit longer.

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

  • Check for embedded tracks first — they are free to extract.
  • For hardcoded subs, 1080p or higher gives the best OCR accuracy.
  • Export VTT for web players, SRT for editors and translation.

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

Does it handle the MOV variant?

Yes — MOV containers behave the same for extraction purposes.

What if the MP4 has no subtitles at all?

The API reports no-track-found; OCR then scans for burned-in text automatically.

Can I extract only the subtitle track without re-encoding video?

Yes — for embedded tracks the video is passed through untouched.