Tutorial · Python · ~10 min
How to Remove Hardcoded Subtitles from Video in Python
Hardcoded subtitles are rendered into the pixels, so they can't be toggled off. This tutorial erases them with frame-aware AI inpainting — no masking, no cropping, no manual rotoscoping.
Before you start
Prerequisites
- A free mlslabs account and API key
- Python 3.9+
- pip install mlslabs
- No footage needed — use our cloud sample (short-drama-cn.mp4)
Step 1 — Install the SDK
Bash
pip install mlslabsStep 2 — Set your API key
Python
import mlslabs
client = mlslabs.Client("YOUR_API_KEY")Step 3 — Submit an erasure job
mode="subtitle" targets caption regions automatically. If detection misses stylized text, pass explicit region boxes instead.
Python
job = client.subtitle_eraser.submit(
input_url="s3://bucket/short-drama-cn.mp4",
output_url="s3://bucket/short-drama-clean.mp4",
mode="subtitle", # subtitle | text | region boxes
)
print(job.job_id)Step 4 — Poll until complete
Python
job.wait()
print(job.status) # done | failed
# failed jobs auto-refund credits — check job.error and retryStep 5 — Download and verify
- No residual text, blur or color blocks where captions were
- No flicker across scene cuts
- Resolution matches the source exactly
Troubleshooting
| Symptom | Cause | Fix |
|---|---|---|
| No text detected | Caption style outside training | Use mode="text" or region boxes |
| Partial erasure | Tight detection box | Box 30–50% larger than the text |
| Job failed | Transient error | Check job.error; credits were refunded — retry |
Keep exploring
Related guides
Subtitle Eraser API
Remove hardcoded subtitles cleanly for localization and short-drama export.
Learn moreSubtitle Extractor API
Extract on-screen text and spoken dialogue with frame-accurate timestamps.
Learn moreSDR2HDR API
Convert SDR video to HDR with restored brightness, gamut and detail.
Learn more