How to add an animated pie chart with Claude

A dark chart card fades in over the lower third and a pie fills clockwise from 12 o'clock, opening a yellow 50% slice, then pink 30% and red 20%, while the legend beside it counts each share up.

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 an animated pie chart to input.mp4
    Title: First change users noticed
    Slices: [("Brighter", 50, (255, 196, 0)), ("Smoother", 30, (240, 70, 150)), ("Firmer", 20, (230, 40, 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 an animated pie chart 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
TITLEFirst change users noticedHeading on the chart card.
SLICES[("Brighter", 50, (255, 196, 0)), ("Smoother", 30, (240, 70, 150)), ("Firmer", 20, (230, 40, 50))]Label, value (adding up to 100) and color for each slice.
START0.8Second the sweep starts at 12 o'clock.
SWEEP1.8Seconds the sweep takes to go all the way round.
PIE(0.28, 0.755, 0.17)Pie center across and down, and radius 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 an animated pie chart to input.mp4. At 0.4 seconds fade in, over 0.3 seconds, a dark (15, 15, 25) rounded card at 84% opacity spanning 6% to 94% across and 55% to 90% down, titled "First change users noticed" in white bold text 5.5% of the frame width tall, its middle 3.5% of the frame height below the card's top and 4% of the frame width in from its left edge. On the card's left draw a pie centered 28% across and 75.5% down with a radius of 17% of the frame width: a faint white circle at first, then from 0.8 seconds a sweep that starts at 12 o'clock and goes clockwise all the way round in 1.8 seconds with an ease-in-out cubic, filling three slices in turn: "Brighter" 50% in yellow (255, 196, 0), "Smoother" 30% in pink (240, 70, 150) and "Firmer" 20% in red (230, 40, 50), with thin card-colored lines between them. To the right put a legend with rows centered 68%, 75.5% and 83% down: a dot in the slice color starting 52% across, the slice's name in white bold text 4.4% of the frame width tall just right of it, and right-aligned at 90% across that slice's percentage, counting up from 0% as its slice opens. Everything 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 animated-pie-chart.py and run:

python3 animated-pie-chart.py input.mp4 output.mp4
Show the script
#!/usr/bin/env python3
"""Animated pie chart: three colored slices sweep open clockwise from 12 o'clock while a legend counts up their percentages.

Usage: python3 animated-pie-chart.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

TITLE = "First change users noticed"   # heading on the chart card
SLICES = [("Brighter", 50, (255, 196, 0)),   # label, value (they add up to 100) and color for each slice
          ("Smoother", 30, (240, 70, 150)),
          ("Firmer", 20, (230, 40, 50))]
CARD_IN = 0.4            # second the card fades in
FADE = 0.3               # seconds the fade takes
START = 0.8              # second the sweep starts at 12 o'clock
SWEEP = 1.8              # seconds the sweep takes to go all the way round
CARD = (0.06, 0.55, 0.94, 0.90)  # card box: left, top, right, bottom (0-1 of the frame)
PIE = (0.28, 0.755, 0.17)        # pie center across, center down, and radius as a share of the frame width
LEGEND_X = (0.52, 0.90)          # legend's left and right edges (0-1 across the frame)
ROW_Y = [0.68, 0.755, 0.83]      # legend row centers (0-1 down the frame)
CARD_COLOR = (15, 15, 25)        # card color, shown at 84% 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 pie(swept):
    """The pie with `swept` (0-1) of the circle filled, drawn 4x larger and shrunk so its edges are smooth."""
    d = round(PIE[2] * w * 2) * 4
    img = Image.new("RGBA", (d, d))
    draw = ImageDraw.Draw(img)
    draw.ellipse([0, 0, d - 1, d - 1], fill=(255, 255, 255, 30))
    begin = 0
    for _, value, color in SLICES:
        end = min(begin + value / 100, swept)
        if end > begin:
            draw.pieslice([0, 0, d - 1, d - 1], -90 + begin * 360, -90 + end * 360, fill=color, outline=CARD_COLOR, width=12)
        begin += value / 100
    return img.resize((d // 4, d // 4), Image.LANCZOS)


def overlay(t):
    img = Image.new("RGBA", (w, h))
    fade = min(max((t - CARD_IN) / FADE, 0), 1)
    if fade == 0:
        return img
    draw = ImageDraw.Draw(img)
    x0, y0, x1, y1 = CARD[0] * w, CARD[1] * h, CARD[2] * w, CARD[3] * h
    draw.rounded_rectangle([x0, y0, x1, y1], radius=w * 0.04, fill=CARD_COLOR + (round(215 * fade),))
    white = (255, 255, 255, round(255 * fade))
    draw.text((x0 + w * 0.04, y0 + h * 0.035), TITLE, font=title_font, anchor="lm", fill=white)
    swept = ease_in_out_cubic((t - START) / SWEEP)
    chart = pie(swept)
    chart.putalpha(chart.getchannel("A").point(lambda a: round(a * fade)))
    img.alpha_composite(chart, (round(PIE[0] * w - chart.width / 2), round(PIE[1] * h - chart.height / 2)))
    begin, dot = 0, w * 0.016
    for (label, value, color), cy in zip(SLICES, ROW_Y):
        y, left = cy * h, LEGEND_X[0] * w
        draw.ellipse([left, y - dot, left + 2 * dot, y + dot], fill=color + (round(255 * fade),))
        draw.text((left + 3 * dot, y), label, font=label_font, anchor="lm", fill=white)
        shown = min(max(swept - begin, 0), value / 100) * 100
        draw.text((LEGEND_X[1] * w, y), f"{round(shown)}%", font=label_font, anchor="rm", fill=white)
        begin += value / 100
    return img


def ease_in_out_cubic(p):
    """0 -> 1, starting slowly, speeding up, then slowing into the full circle."""
    p = min(max(p, 0), 1)
    return 4 * p ** 3 if p < 0.5 else 1 - (2 - 2 * p) ** 3 / 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)
title_font = ImageFont.truetype(FONT_FILE, round(w * 0.055))
label_font = ImageFont.truetype(FONT_FILE, round(w * 0.044))
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