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.

PythonSubtitle removalInpainting

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 mlslabs

Step 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 retry

Step 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

SymptomCauseFix
No text detectedCaption style outside trainingUse mode="text" or region boxes
Partial erasureTight detection boxBox 30–50% larger than the text
Job failedTransient errorCheck job.error; credits were refunded — retry