How to add a shaking text with Claude

"BACK IN STOCK!" appears in bold yellow near the top and every letter jolts and twists on its own each frame, while the shot behind stays steady.

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 a shaking text to input.mp4
    Lines: ["BACK IN", "STOCK!"]

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 a shaking text 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
LINES["BACK IN", "STOCK!"]The text, one entry per line.
START0.5Second the text appears.
Y0.17Center of the text block (0 = top, 1 = bottom).
WIDTH0.8The longest line's width as a share of the frame width.
COLOR(255, 214, 0)Text color.
OUTLINE0.012Black outline thickness as a share of the frame width.
JITTER0.012How far a letter can jump each frame, as a share of the frame width.
TILT6How far a letter can twist each frame, in degrees.
SEED7Change for a different (but repeatable) shake.

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 shaking text to input.mp4: "BACK IN" over "STOCK!" in a heavy bold font (Arial Black), yellow (255, 214, 0) with a black outline 1.2% of the frame width thick, the longer line 80% of the frame width wide, line spacing 1.1 times the font size, the two-line block centered horizontally and 17% of the way down. It appears at 0.5 seconds and stays to the end. On every frame, move each letter on its own by a random amount up to 1.2% of the frame width left or right and up or down from its place, and turn it by a random angle up to 6 degrees either way, so the letters jitter like a shout. Only the text shakes: the video behind stays untouched, and nothing changes before 0.5 seconds. Draw the text with Python and Pillow (don't rely on ffmpeg's drawtext filter), keep the size and audio, and save it as output.mp4.

Run it without Claude

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

python3 shaking-text.py input.mp4 output.mp4
Show the script
#!/usr/bin/env python3
"""Shaking text: a bold yellow shout appears and every letter jitters on its own, a few pixels each frame.

Usage: python3 shaking-text.py input.mp4 output.mp4
Needs ffmpeg and Pillow (pip install pillow).
"""
import json
import math
import random
import subprocess
import sys
from pathlib import Path

from PIL import Image, ImageDraw, ImageFont

LINES = ["BACK IN", "STOCK!"]   # the text, one entry per line
START = 0.5                     # second the text appears
Y = 0.17                        # center of the text block (0 = top, 1 = bottom)
WIDTH = 0.8                     # the longest line's width as a share of the frame width
COLOR = (255, 214, 0)           # text color
OUTLINE = 0.012                 # black outline thickness as a share of the frame width
JITTER = 0.012                  # how far a letter can jump each frame, as a share of the frame width
TILT = 6                        # how far a letter can twist each frame, in degrees
SEED = 7                        # change for a different (but repeatable) shake
FONTS = ["/System/Library/Fonts/Supplemental/Arial Black.ttf",    # macOS
         "/usr/share/fonts/truetype/dejavu/DejaVuSans-Bold.ttf",  # Linux
         "C:/Windows/Fonts/ariblk.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 layout():
    """Each letter's picture and resting center, with the block sized so the longest line fills WIDTH."""
    stroke = round(w * OUTLINE)
    longest = max(LINES, key=len)
    probe_font = ImageFont.truetype(FONT_FILE, 100)
    font = ImageFont.truetype(FONT_FILE, round(100 * w * WIDTH / probe_font.getlength(longest)))
    line_h = font.size * 1.1
    top = h * Y - line_h * len(LINES) / 2
    letters = []
    for row, line in enumerate(LINES):
        x = (w - font.getlength(line)) / 2
        cy = top + line_h * (row + 0.5)
        for ch in line:
            adv = font.getlength(ch)
            if ch != " ":
                pad = stroke + font.size // 4
                img = Image.new("RGBA", (round(adv) + 2 * pad, font.size + 2 * pad))
                ImageDraw.Draw(img).text((img.width / 2, img.height / 2), ch, font=font, anchor="mm",
                                         fill=COLOR, stroke_width=stroke, stroke_fill="black")
                letters.append((img, x + adv / 2, cy))
            x += adv
    return letters


def overlay(t):
    img = Image.new("RGBA", (w, h))
    if t < START:
        return img
    rng = random.Random(f"{SEED}-{round(t * fps)}")   # a fresh jolt for every letter on every frame
    reach = w * JITTER
    for pic, cx, cy in letters:
        turned = pic.rotate(rng.uniform(-TILT, TILT), resample=Image.BICUBIC)
        x = cx + rng.uniform(-reach, reach)
        y = cy + rng.uniform(-reach, reach)
        img.alpha_composite(turned, (round(x - turned.width / 2), round(y - turned.height / 2)))
    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, out = sys.argv[1:3]
w, h, rate, fps, duration = probe(src)
letters = layout()
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