Tutorial · Python · ~10 min
How to Extract Hardcoded Subtitles from Video in Python
No CUDA setup. No GPU. No model weights. Just an API call that turns burned-in subtitles into clean, timestamped SRT files.
Why an API beats rolling your own OCR
Open-source OCR on video means CUDA configs, tile sizes, VRAM limits and accuracy tuning — then batch code on top. The API removes the GPU problem entirely. See the full comparison on the open-source tools page.
Step 1 — Get your API key
- Sign up (free tier included)
- Copy the key from the dashboard
- pip install mlslabs
Step 2 — Use our sample video (or your own)
import mlslabs
client = mlslabs.Client("YOUR_API_KEY")Step 3 — Submit the extraction job
job = client.subtitle_extractor.submit(
input_url="s3://bucket/short-drama-cn.mp4",
output_url="s3://bucket/subs/",
languages=["zh", "en"],
output_format="srt", # srt | vtt | json
confidence_threshold=0.6,
)
print(job.job_id)Step 4 — Poll for the result
job.wait()
print(job.status)
print(job.files) # SRT + JSON sidecarsStep 5 — Inspect the SRT output
JSON output adds per-line bounding boxes, confidence scores and style attributes for downstream tools.
1
00:00:02,120 --> 00:00:04,860
The door creaked open as she stepped inside.
2
00:00:04,860 --> 00:00:07,400
She stepped in and saw the letter on the desk.Step 6 — Batch mode
For a whole episode library, submit one batch: queue thousands of files with per-file webhooks and automatic retries.
Keep exploring
Related guides
Subtitle Extractor API
Extract on-screen text and spoken dialogue with frame-accurate timestamps.
Learn moreSubtitle Eraser API
Remove hardcoded subtitles cleanly for localization and short-drama export.
Learn moreVocal Separator API
Isolate vocals or instrumentals from speech and music mixes.
Learn more