How to add a gradient text with Claude

"NEW DROP" fades in near the top in heavy letters whose yellow, pink and violet fill keeps drifting rightward through the words.

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 gradient text to input.mp4
    Text: NEW DROP
    Colors: yellow (255, 214, 0), pink (255, 45, 150), violet (130, 60, 255)

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 gradient 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
TEXTNEW DROPThe headline.
START0.5Second the text fades in.
COLORSyellow (255, 214, 0), pink (255, 45, 150), violet (130, 60, 255)Gradient stops; the loop returns to the first.
BAND1.0Width of one loop of the colors, as a share of the frame width.
SPEED0.4How far the colors slide per second, as a share of the frame width.
SIZE0.15Text height as a share of the frame width.

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 animated gradient text to input.mp4: the words "NEW DROP" in a heavy bold font (Arial Black or similar), 15% of the frame width tall, centered horizontally at 15% down the frame. Fill the letters with a horizontal gradient that blends evenly from yellow (255, 214, 0) to pink (255, 45, 150) to violet (130, 60, 255) and back to yellow, one full loop spanning 100% of the frame width and repeating across it, with the yellow stop at the frame's left edge when the text appears. The gradient slides to the right at 40% of the frame width per second (one full loop every 2.5 seconds) and wraps around, while the letters stay still. Put a soft black drop shadow (55% opacity, offset 4 px right and 5 px down, 6 px blur) behind the letters. The text fades in from 0.5 to 0.8 seconds, with nothing on screen before 0.5 seconds, and stays to the end. Use Python with Pillow and numpy to draw the text and gradient (don't use ffmpeg's drawtext 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 gradient-text.py and run:

python3 gradient-text.py input.mp4 output.mp4
Show the script
#!/usr/bin/env python3
"""Gradient text: a bold headline filled with yellow, pink and violet that keep sliding left to right through the letters.

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

import numpy as np
from PIL import Image, ImageDraw, ImageFilter, ImageFont

TEXT = "NEW DROP"           # the headline
START = 0.5                 # second the text fades in
FADE_IN = 0.3               # seconds the fade in takes
Y = 0.15                    # text center, 0-1 down the frame
SIZE = 0.15                 # text height as a share of the frame width
COLORS = [(255, 214, 0), (255, 45, 150), (130, 60, 255)]  # gradient stops: yellow, pink, violet (it loops)
BAND = 1.0                  # width of one full loop of the colors, as a share of the frame width
SPEED = 0.4                 # how far the colors slide per second, as a share of the frame width
SHADOW = 0.55               # drop shadow opacity behind the letters (0 = none)
FONTS = ["/System/Library/Fonts/Supplemental/Arial Black.ttf",    # macOS
         "/System/Library/Fonts/Supplemental/Arial Bold.ttf",
         "/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 masks():
    """The letter shapes, and a soft shadow nudged down and right, as 0-1 arrays the size of the frame."""
    font = ImageFont.truetype(FONT_FILE, round(w * SIZE))
    letters = Image.new("L", (w, h))
    ImageDraw.Draw(letters).text((w / 2, h * Y), TEXT, font=font, anchor="mm", fill=255)
    shadow = Image.new("L", (w, h))
    ImageDraw.Draw(shadow).text((w / 2 + 4, h * Y + 5), TEXT, font=font, anchor="mm", fill=255)
    shadow = shadow.filter(ImageFilter.GaussianBlur(6))
    return np.asarray(letters, np.float32) / 255, np.asarray(shadow, np.float32) / 255 * SHADOW


def gradient_row():
    """One loop of the colors, blended evenly from stop to stop and back to the first, BAND of the frame wide."""
    n = round(w * BAND)
    stops = np.array(COLORS + COLORS[:1], np.float32)
    pos = np.linspace(0, len(COLORS), n, endpoint=False)
    i = pos.astype(int)
    f = (pos - i)[:, None]
    return stops[i] * (1 - f) + stops[i + 1] * f


def overlay(t):
    shown = min(max((t - START) / FADE_IN, 0), 1)
    if shown <= 0:
        return blank
    shift = round((t - START) * SPEED * w)
    cols = (np.arange(w) - shift) % len(row)            # each column's place in the loop, moving right over time
    fill = np.broadcast_to(row[cols], (h, w, 3))
    alpha = letters + shadow * (1 - letters)
    rgb = fill * (letters / np.maximum(alpha, 1e-6))[..., None]  # shadow pixels are black
    img = np.dstack([rgb, alpha * 255 * shown])
    return Image.fromarray(img.round().astype(np.uint8))


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, shadow = masks()
row = gradient_row()
blank = Image.new("RGBA", (w, h))
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