How to add burned-in subtitles with Claude

Each line from the subtitle file appears near the bottom in white type on a see-through black strip, timed to its cue and gone between cues.

Get this effect

  1. Switch to Code in your Claude Desktop App

  2. Install the skill (once)

    Show the prompt
    Install the Recharm video effects skill: download https://recharm-growth-staging.s3.us-east-2.amazonaws.com/website/downloads/recharm-video-effects.zip and unzip it into ~/.claude/skills
  3. Ask for the effect

    Add burned-in subtitles to input.mp4
    Text: white

Several videos, several effects, one ask

Put your clips in the folder, mention them with @, and ask for everything at once. Claude runs one tested script after another on each clip, then joins them.

Add burned-in subtitles to @clip1.mp4, put a sale badge on @clip2.mp4, give @clip3.mp4 a VHS look, then join all three with crossfades.

Settings you can change

Ask Claude to change any of these, or edit them at the top of the script.

SettingDefaultWhat it does
SIZE0.064Text height as a share of the frame width.
Y0.86Where the bottom line's center sits, from top (0) to bottom (1).
MAX_WIDTH0.86Longest line as a share of the frame width before a cue wraps.
TEXTwhiteText color.
STRIP(0, 0, 0, 170)Color and opacity of the strip behind each line.
PAD0.022Space around the text inside the strip.

Without the skill

Don’t want to install the skill? Paste this prompt into Claude Code and Claude writes the script itself.

Show the prompt
Burn the subtitles in subtitles.srt into input.mp4. Show each cue from its start time to its end time and nothing between cues: white bold text (Arial Bold) 6.4% of the frame width tall, centered horizontally with its line's center 86% of the way down the frame, on a black strip at 67% opacity (alpha 170) with rounded corners that reaches 2.2% of the frame width past the text on the left and right and 1.3% above and below. Wrap a cue onto more lines, stacked upward, if it is wider than 86% of the frame. Use Python with Pillow to draw the text (don't use ffmpeg's drawtext or subtitles filter) and ffmpeg to put it on the video, keep the audio, and save it as output.mp4.

Run it without Claude

This is the exact script we tested. Save it as burned-in-subtitles.py and run:

python3 burned-in-subtitles.py input.mp4 subtitles.srt output.mp4
Show the script
#!/usr/bin/env python3
"""Burned-in subtitles: each line of an .srt file drawn onto the frames in white on a dark see-through strip.

Usage: python3 burned-in-subtitles.py input.mp4 subtitles.srt output.mp4
subtitles.srt is an ordinary subtitle file:
  1
  00:00:00,300 --> 00:00:01,820
  This serum cleared my
Needs ffmpeg and Pillow (pip install pillow).
"""
import json
import math
import re
import subprocess
import sys
from pathlib import Path

from PIL import Image, ImageDraw, ImageFont

SIZE = 0.064          # text height as a share of the frame width
Y = 0.86              # where the bottom line's center sits (0 = top, 1 = bottom)
MAX_WIDTH = 0.86      # longest line as a share of the frame width; longer cues wrap onto more lines
TEXT = "white"        # text color
STRIP = (0, 0, 0, 170)  # color and opacity (0-255) of the strip behind each line
PAD = 0.022           # space around the text inside the strip, as a share of the frame width
FONTS = ["/System/Library/Fonts/Supplemental/Arial Bold.ttf",     # macOS
         "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",  # Linux
         "C:/Windows/Fonts/arialbd.ttf"]                          # Windows
FONT_FILE = next((f for f in FONTS if Path(f).exists()), None) or sys.exit("No bold font found: add one to FONTS")


def read_srt(path):
    """[(start, end, text)] from an .srt file, times in seconds."""
    cues = []
    stamp = r"(\d+):(\d+):(\d+)[,.](\d+)"
    for block in re.split(r"\n\s*\n", Path(path).read_text(encoding="utf-8-sig").replace("\r", "")):
        lines = block.strip().split("\n")
        for i, line in enumerate(lines):
            m = re.match(stamp + r"\s*-->\s*" + stamp, line)
            if m:
                h0, m0, s0, ms0, h1, m1, s1, ms1 = map(int, m.groups())
                text = " ".join(lines[i + 1:])
                cues.append((h0 * 3600 + m0 * 60 + s0 + ms0 / 1000, h1 * 3600 + m1 * 60 + s1 + ms1 / 1000, text))
                break
    return cues


def wrap(text):
    """Split a cue into lines that fit MAX_WIDTH."""
    lines = []
    for word in text.split():
        if lines and font.getlength(lines[-1] + " " + word) <= w * MAX_WIDTH:
            lines[-1] += " " + word
        else:
            lines.append(word)
    return lines


def subtitle(text):
    """The cue drawn once: its lines stacked up from Y, each on its own strip."""
    img = Image.new("RGBA", (w, h))
    draw = ImageDraw.Draw(img)
    pad = w * PAD
    step = font.size * 1.18 + 2 * pad * 0.6
    lines = wrap(text)
    for n, line in enumerate(lines):
        cy = h * Y - (len(lines) - 1 - n) * step
        x0, y0, x1, y1 = draw.textbbox((w / 2, cy), line, font=font, anchor="mm")
        draw.rounded_rectangle([x0 - pad, y0 - pad * 0.6, x1 + pad, y1 + pad * 0.6], radius=pad * 0.5, fill=STRIP)
        draw.text((w / 2, cy), line, font=font, anchor="mm", fill=TEXT)
    return img


def overlay(t):
    for i, (start, end, text) in enumerate(cues):
        if start <= t < end:
            return drawn.get(i) or drawn.setdefault(i, subtitle(text))
    return blank


def probe(path):
    info = json.loads(subprocess.check_output(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries",
                                               "stream=width,height,r_frame_rate:format=duration", "-of", "json", path]))
    s = info["streams"][0]
    num, den = s["r_frame_rate"].split("/")
    return s["width"], s["height"], s["r_frame_rate"], float(num) / float(den), float(info["format"]["duration"])


def render(src, out):
    """Draw overlay(t) on every frame of src and save to out, keeping the audio."""
    ff = subprocess.Popen(["ffmpeg", "-y", "-v", "error", "-i", src,
                           "-f", "rawvideo", "-pix_fmt", "rgba", "-s", f"{w}x{h}", "-r", rate, "-i", "-",
                           "-filter_complex", "[0:v][1:v]overlay=shortest=1,format=yuv420p[v]",
                           "-map", "[v]", "-map", "0:a?", "-c:v", "libx264", "-crf", "18", "-c:a", "copy", out],
                          stdin=subprocess.PIPE)
    for i in range(math.ceil(duration * fps)):
        ff.stdin.write(overlay(i / fps).tobytes())
    ff.stdin.close()
    if ff.wait():
        sys.exit("ffmpeg failed")


src, srt_file, out = sys.argv[1:4]
cues = read_srt(srt_file)
w, h, rate, fps, duration = probe(src)
font = ImageFont.truetype(FONT_FILE, round(w * SIZE))
blank = Image.new("RGBA", (w, h))
drawn = {}
render(src, out)

Find 3x winning ads

Recharm cuts your ad footage into tagged, searchable clips: hooks, testimonials, product shots. Find the shots that win, add the effect with Claude, and ship 3x more ad edits.

Start 14-day free trial