How to add a discount code overlay with Claude

A yellow coupon with a dashed cut-here border slides up into the lower part of the frame, reading "USE CODE GLOW20" and "20% off, ends Sunday".

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 discount code overlay to input.mp4
    Label, code, expiry: USE CODE, GLOW20, 20% OFF · ENDS SUNDAY

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 discount code overlay 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
LABEL, CODE, EXPIRYUSE CODE, GLOW20, 20% OFF · ENDS SUNDAYThe three lines on the coupon.
START1.0Second the coupon starts sliding in.
SLIDE0.4Seconds the slide takes.
X, Y0.5, 0.78Coupon center, 0-1 across and down the frame.
COLOR(255, 210, 0)Coupon color.
INK(25, 25, 25)Text and dashed border color.

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 a discount code overlay to input.mp4: a yellow (255, 210, 0) rounded rectangle 76% of the frame width and 20% of the frame height, centered at 50% across and 78% down, with corner radius 1/8 of its height. Inside it, inset by 1/12 of its height, draw a dashed border in near-black (25, 25, 25). Center three lines of bold near-black text on it: "USE CODE" at 26% of its height (font 12% of its height), "GLOW20" at 52% (font 30%) and "20% OFF · ENDS SUNDAY" at 77% (font 10%). It appears at 1.0 second: over 0.4 seconds it fades in and slides up from 12% of the frame height lower with an ease-out, then stays to the end. Nothing is shown before 1.0 second. 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 discount-code-overlay.py and run:

python3 discount-code-overlay.py input.mp4 output.mp4
Show the script
#!/usr/bin/env python3
"""Discount code overlay: a yellow coupon with a dashed cut-out border slides up with a promo code and its expiry.

Usage: python3 discount-code-overlay.py input.mp4 output.mp4
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

LABEL = "USE CODE"                     # small line above the code
CODE = "GLOW20"                        # the promo code
EXPIRY = "20% OFF  ·  ENDS SUNDAY"     # small line under the code
START = 1.0                            # second the coupon starts sliding in
SLIDE = 0.4                            # seconds the slide takes
WIDTH, HEIGHT = 0.76, 0.20             # coupon size as a share of the frame width and height
X, Y = 0.5, 0.78                       # coupon center (0-1 across and down the frame)
COLOR = (255, 210, 0)                  # coupon color
INK = (25, 25, 25)                     # text and dashed border color
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 coupon():
    cw, ch = round(w * WIDTH), round(h * HEIGHT)
    img = Image.new("RGBA", (cw, ch))
    draw = ImageDraw.Draw(img)
    draw.rounded_rectangle([0, 0, cw - 1, ch - 1], radius=ch // 8, fill=COLOR)
    inset, dash, line = ch // 12, ch // 14, max(2, ch // 60)
    left, top, right, bottom = inset, inset, cw - inset, ch - inset
    for x in range(left, right, dash * 2):        # dashed border, the "cut along here" line
        draw.line([x, top, min(x + dash, right), top], fill=INK, width=line)
        draw.line([x, bottom, min(x + dash, right), bottom], fill=INK, width=line)
    for y in range(top, bottom, dash * 2):
        draw.line([left, y, left, min(y + dash, bottom)], fill=INK, width=line)
        draw.line([right, y, right, min(y + dash, bottom)], fill=INK, width=line)
    draw.text((cw / 2, ch * 0.26), LABEL, font=ImageFont.truetype(FONT_FILE, round(ch * 0.12)), anchor="mm", fill=INK)
    draw.text((cw / 2, ch * 0.52), CODE, font=ImageFont.truetype(FONT_FILE, round(ch * 0.30)), anchor="mm", fill=INK)
    draw.text((cw / 2, ch * 0.77), EXPIRY, font=ImageFont.truetype(FONT_FILE, round(ch * 0.10)), anchor="mm", fill=INK)
    return img


def overlay(t):
    img = Image.new("RGBA", (w, h))
    p = ease_out_cubic((t - START) / SLIDE)
    if p > 0:
        card = full.copy()
        card.putalpha(card.getchannel("A").point(lambda a: round(a * p)))
        rise = round((1 - p) * h * 0.12)              # starts 12% of the frame lower and slides up into place
        img.alpha_composite(card, (round(w * X - card.width / 2), round(h * Y - card.height / 2) + rise))
    return img


def ease_out_cubic(p):
    """0 -> 1, fast at first and settling gently."""
    p = min(max(p, 0), 1)
    return 1 - (1 - p) ** 3


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)
full = coupon()
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