How to add a shape mask with Claude

The video is cut down to a heart with a thin white outline, and everything outside it is flat blush pink.

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 shape mask to input.mp4
    Heart width as a share of the frame width: 0.90
    Heart center, 0-1 across and down the frame: 0.50, 0.50

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 shape mask 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
WIDTH0.90Heart width as a share of the frame width.
X, Y0.50, 0.50Heart center, 0-1 across and down the frame.
BACKDROP(250, 222, 232)Color everywhere outside the heart.
OUTLINE(255, 255, 255)Color of the heart's edge.
OUTLINE_WIDTH8Edge thickness in pixels; 0 removes it.
SMOOTH4How much larger the heart is drawn before shrinking, for smooth edges.

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
Crop input.mp4 into a heart shape for its whole length. Use Python with Pillow to draw one overlay image the size of the video: a solid (250, 222, 232) blush-pink backdrop with a transparent heart-shaped hole and an 8-pixel white (255, 255, 255) outline round the hole. Draw the heart from the curve x = sin(t)^3, y = -(13cos(t) - 5cos(2t) - 2cos(3t) - cos(4t))/16 (t from 0 to 2*pi, 400 points), scaled so it is 90% of the frame width across, centered at 50% across and 50% down (center of its bounding box), with its point at the bottom. Draw it at 4x size and shrink it for smooth edges. Put the overlay on every frame with ffmpeg (don't use ffmpeg's drawtext), keep the audio and the original size, 30fps H.264 yuv420p, and save it as output.mp4.

Run it without Claude

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

python3 shape-mask.py input.mp4 output.mp4
Show the script
#!/usr/bin/env python3
"""Shape mask: the video plays inside a white-outlined heart on a blush-pink backdrop.

Usage: python3 shape-mask.py input.mp4 output.mp4
Needs ffmpeg and Pillow (pip install pillow).
"""
import io
import math
import subprocess
import sys

from PIL import Image, ImageDraw

WIDTH = 0.90                  # heart width as a share of the frame width
X, Y = 0.50, 0.50             # heart center (0-1 across and down the frame)
BACKDROP = (250, 222, 232)    # color everywhere outside the heart
OUTLINE = (255, 255, 255)     # color of the heart's edge
OUTLINE_WIDTH = 8             # edge thickness in pixels; 0 removes it
SMOOTH = 4                    # draw this many times larger, then shrink, for smooth edges


def heart(cx, cy, width):
    """Points round a heart of the given width, centered on (cx, cy)."""
    pts = [(math.sin(t) ** 3, -(13 * math.cos(t) - 5 * math.cos(2 * t) - 2 * math.cos(3 * t) - math.cos(4 * t)) / 16)
           for t in (i * 2 * math.pi / 400 for i in range(400))]
    top, bottom = min(y for _, y in pts), max(y for _, y in pts)
    s = width / 2
    return [(cx + x * s, cy + (y - (top + bottom) / 2) * s) for x, y in pts]


def frame_overlay(w, h):
    """The backdrop with a clear heart-shaped hole and an outline round it."""
    big = Image.new("RGBA", (w * SMOOTH, h * SMOOTH), BACKDROP + (255,))
    draw = ImageDraw.Draw(big)
    draw.polygon(heart(w * X * SMOOTH, h * Y * SMOOTH, w * WIDTH * SMOOTH), fill=OUTLINE + (255,))
    draw.polygon(heart(w * X * SMOOTH, h * Y * SMOOTH, (w * WIDTH - 2 * OUTLINE_WIDTH) * SMOOTH), fill=(0, 0, 0, 0))
    return big.resize((w, h), Image.LANCZOS)


src, out = sys.argv[1:3]
w, h = map(int, subprocess.check_output(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries",
                                         "stream=width,height", "-of", "csv=p=0", src], text=True).split(","))
png = io.BytesIO()
frame_overlay(w, h).save(png, "PNG")
subprocess.run(["ffmpeg", "-y", "-v", "error", "-i", src, "-f", "png_pipe", "-i", "-",
                "-filter_complex", "[0:v][1:v]overlay,fps=30,format=yuv420p[v]",
                "-map", "[v]", "-map", "0:a?", "-c:v", "libx264", "-crf", "18", "-c:a", "copy", out],
               input=png.getvalue(), check=True)

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