Tutorial · Python · ~10 min
How to Extract Hardcoded Subtitles from Video
A step-by-step walkthrough of the OCR → clustering → export pipeline, with an API example you can run in minutes.
Why this matters
Hardcoded subtitles are pixels, not text — extraction is an OCR problem with a temporal twist: the same line persists across many frames and must be emitted once.
Per-frame OCR alone produces thousands of duplicate lines; the pipeline clusters them by content and timing to produce clean, readable SRT.
How it works
Submit the video, choose output_format (srt/vtt/ass), and poll. The API returns the subtitle file plus per-line confidence scores.
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
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
- Higher source resolution means better OCR — upscale first if the source is low-res.
- Set the source language when you know it; it improves character recognition.
- Review low-confidence lines — usually the ones with partial occlusion or stylized fonts.
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 if the subtitles are in a stylized font?
Accuracy drops slightly; setting the language and using the high-accuracy model recovers most of it.
Can I extract just the burned-in text without the rest of the scene?
The OCR operates on detected text regions only, so background content is ignored.
Do you store my video?
No — inputs are processed and deleted per our retention policy; you keep the URLs.
Keep exploring
Related guides
Subtitle Extractor API
Extract on-screen text and spoken dialogue with frame-accurate timestamps.
Learn moreVideo OCR vs Speech To Text
Speech-to-text listens to audio; video OCR reads text burned into the picture. Learn which one extracts the subtitl...
Read guideSubtitle Eraser API
Remove hardcoded subtitles cleanly for localization and short-drama export.
Learn more