How to add boxed captions with Claude

Each phrase sits in black type on a white rounded box, four words at a time.

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 boxed captions to input.mp4 using the word timings in words.json
    Words per phrase: 4
    Text height as a share of the frame width: 0.065

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 boxed captions 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
CHUNK4Words per phrase.
SIZE0.065Text height as a share of the frame width.
PAD0.03Space inside the box.

In other editors

From each editor’s own help pages, in our words. We haven’t run these ourselves.

Built in: subtitle background · web

  1. In the Subtitles tab, pick the spoken language and click Auto-subtitle.
  2. Under Styles, choose a preset, then click Edit beneath it.
  3. In the Background setting, pick one of the 4 preset backgrounds.
  4. Set the background color, and adjust font and text color in the same panel.

Source: How to add subtitles to your video automatically (VEED), checked October 22, 2026.

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
Add captions to input.mp4 using the word timings in words.json. Show four words at a time as black text on a white rounded box, centered 72% of the way down, from the group's first word to its last word. Use Python with Pillow to draw it and ffmpeg to put it on the video (don't rely on ffmpeg's drawtext filter), keep the audio, and save it as output.mp4.

Run it without Claude

This is the exact script we tested. Save it as boxed-captions.py and run:

python3 boxed-captions.py input.mp4 words.json output.mp4
Show the script
#!/usr/bin/env python3
"""Boxed captions: each phrase in black text on a white rounded box, on screen while it is spoken.

Usage: python3 boxed-captions.py input.mp4 words.json output.mp4
words.json holds word timings, for example from Whisper:
  [{"word": "This", "start": 0.30, "end": 0.69}, {"word": "serum", "start": 0.77, "end": 1.13}, ...]
Needs ffmpeg and Pillow (pip install pillow).
"""
import json
import math
import subprocess
import sys
from pathlib import Path

from PIL import Image, ImageDraw, ImageFont

SIZE = 0.065     # text height as a share of the frame width (shrinks to fit long phrases)
Y = 0.72         # where the box's center sits (0 = top, 1 = bottom)
CHUNK = 4        # words per phrase
PAD = 0.03       # space inside the box, 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")


fonts = {}


def fitted_font(text):
    size = round(w * SIZE)
    while size > 12:
        font = fonts.get(size) or fonts.setdefault(size, ImageFont.truetype(FONT_FILE, size))
        if font.getlength(text) <= w * (0.9 - 2 * PAD):
            return font
        size -= 2
    return font


def overlay(t):
    img = Image.new("RGBA", (w, h))
    for group in (words[i:i + CHUNK] for i in range(0, len(words), CHUNK)):
        if group[0]["start"] <= t < group[-1]["end"]:
            text = " ".join(word["word"].strip() for word in group)
            font = fitted_font(text)
            draw = ImageDraw.Draw(img)
            x0, y0, x1, y1 = draw.textbbox((w / 2, h * Y), text, font=font, anchor="mm")
            pad = w * PAD
            draw.rounded_rectangle([x0 - pad, y0 - pad, x1 + pad, y1 + pad], radius=pad, fill="white")
            draw.text((w / 2, h * Y), text, font=font, anchor="mm", fill="black")
    return img


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, words_file, out = sys.argv[1:4]
words = json.loads(Path(words_file).read_text())
w, h, rate, fps, duration = probe(src)
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