How to add a star rating animation with Claude

A dark card pops up near the bottom of the frame reading "4.9" beside five empty star outlines, which fill gold one at a time from left to right.

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 star rating animation to input.mp4
    Reviews: 2,148 reviews

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 star rating animation 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
RATING4.9The score shown; the last star fills by its fraction.
REVIEWS2,148 reviewsSmall line under the stars.
START0.5Second the card pops up.
FIRST_STAR, STEP1.0, 0.3Second the first star fills, and the seconds between stars.
Y0.80Card center, as a share of the frame height.
GOLD(255, 185, 0)Filled star 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 an animated star rating to input.mp4. At 0.5 seconds a dark rounded card pops up over 0.3 seconds with a slight overshoot: 84% of the frame width, 30% as tall as it is wide, centered across and 80% down, color (22, 22, 30) at 88% opacity, corner radius a fifth of its height. On its left, "4.9" in white bold type 56% of the card height tall; to its right, five star outlines in grey (150, 150, 160) spread evenly from 38% to 94% across the card at 40% of its height, each star 34% of the card height from point to point, with "2,148 reviews" in light grey (185, 185, 195) under them. Starting at 1.0 seconds, the stars fill solid gold (255, 185, 0) one by one, left to right, every 0.3 seconds; each starts 35% larger and settles to size over 0.2 seconds, and the fifth fills only its left 90% to match 4.9. The card then stays to the end. 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 star-rating-animation.py and run:

python3 star-rating-animation.py input.mp4 output.mp4
Show the script
#!/usr/bin/env python3
"""Star rating animation: a dark rating card pops up and five gold stars fill in one by one beside "4.9".

Usage: python3 star-rating-animation.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

RATING = 4.9             # the score; the last star fills by its fraction (0.9 of a star for 4.9)
REVIEWS = "2,148 reviews"  # small line under the stars
START = 0.5              # second the card pops up
POP = 0.3                # seconds the card's pop takes
FIRST_STAR = 1.0         # second the first star fills
STEP = 0.3               # seconds between stars
WIDTH = 0.84             # card width as a share of the frame width (centered across)
Y = 0.80                 # card center, as a share of the frame height
GOLD = (255, 185, 0)     # filled star color
CARD = (22, 22, 30, 225)  # card color and opacity
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 star_points(cx, cy, r):
    """The ten corners of a five-pointed star, point up."""
    return [(cx + (r if i % 2 == 0 else r * 0.42) * math.sin(i * math.pi / 5),
             cy - (r if i % 2 == 0 else r * 0.42) * math.cos(i * math.pi / 5)) for i in range(10)]


def card_layout():
    """The card with the score, empty star outlines and review count, plus where each star sits on it."""
    cw = round(w * WIDTH)
    ch = round(cw * 0.30)
    img = Image.new("RGBA", (cw, ch))
    draw = ImageDraw.Draw(img)
    draw.rounded_rectangle([0, 0, cw - 1, ch - 1], radius=ch // 5, fill=CARD)
    draw.text((ch * 0.22, ch * 0.50), f"{RATING:.1f}", font=ImageFont.truetype(FONT_FILE, round(ch * 0.56)),
              anchor="lm", fill="white")
    r = ch * 0.17                                    # star radius
    x0, gap = cw * 0.38, (cw * 0.94 - cw * 0.38) / 5  # stars span 38% to 94% of the card
    centers = [(x0 + gap * (i + 0.5), ch * 0.40) for i in range(5)]
    for cx, cy in centers:
        draw.polygon(star_points(cx, cy, r), outline=(150, 150, 160), width=max(2, round(r / 9)))
    draw.text((x0 + gap * 2.5, ch * 0.80), REVIEWS, font=ImageFont.truetype(FONT_FILE, round(ch * 0.15)),
              anchor="mm", fill=(185, 185, 195))
    return img, centers, r


def gold_star(r, fill):
    """A gold star on its own square, with only the left `fill` share of it colored."""
    d = math.ceil(r * 2) + 2
    img = Image.new("RGBA", (d, d))
    ImageDraw.Draw(img).polygon(star_points(d / 2, d / 2, r), fill=GOLD)
    img.paste((0, 0, 0, 0), (round(d / 2 - r + 2 * r * fill), 0, d, d))
    return img


def overlay(t):
    img = Image.new("RGBA", (w, h))
    if t < START:
        return img
    c = card.copy()
    for i, (cx, cy) in enumerate(centers):
        p = (t - FIRST_STAR - i * STEP) / 0.2       # each star fills with a 0.2-second pop
        fill = min(1.0, RATING - i)
        if p >= 0 and fill > 0:
            s = 1 + 0.35 * (1 - min(p, 1)) ** 2      # starts 35% bigger and settles
            g = gold_star(radius, fill)
            g = g.resize((round(g.width * s), round(g.height * s)), Image.LANCZOS)
            c.alpha_composite(g, (round(cx - g.width / 2), round(cy - g.height / 2)))
    scale = ease_out_back((t - START) / POP)
    if scale < 0.02:
        return img
    c = c.resize((max(1, round(c.width * scale)), max(1, round(c.height * scale))), Image.LANCZOS)
    img.alpha_composite(c, (round(w / 2 - c.width / 2), round(h * Y - c.height / 2)))
    return img


def ease_out_back(p):
    """0 -> 1 with a small overshoot past 1 before settling, which reads as a 'pop'."""
    p = min(max(p, 0), 1)
    return 1 + 2.70158 * (p - 1) ** 3 + 1.70158 * (p - 1) ** 2


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)
card, centers, radius = card_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