---
title: "How to add text message bubbles with Claude (tested prompt and script)"
description: "A phone chat about the serum builds down the frame, one bubble popping in each second: white questions on the left, blue replies on the right. Install one skill and ask Claude Code, or run the Python script we tested yourself."
url: https://www.recharm.com/effects/text-message-bubbles
---

# How to add text message bubbles with Claude

A phone chat about the serum builds down the frame, one bubble popping in each second: white questions on the left, blue replies on the right.

Made by the script on this page, from our own test clip.

## Get this effect

1. ### Switch to Code in your [Claude Desktop App](https://claude.com/download)

2. ### Install the skill (once)

   ```
   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 text message bubbles to input.mp4
   Messages: 4 messages at 0.5, 1.5, 2.5, 3.5
   Them, me: white with black text, (0, 122, 255) with white text
   ```

## 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 text message bubbles 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.

| Setting    | Default                                                | What it does                                                         |
| ---------- | ------------------------------------------------------ | -------------------------------------------------------------------- |
| `MESSAGES` | `4 messages at 0.5, 1.5, 2.5, 3.5`                     | Each bubble's start second, side ("them" left, "me" right) and text. |
| `POP`      | `0.25`                                                 | Seconds each bubble takes to pop in.                                 |
| `TOP`      | `0.10`                                                 | First bubble's top, as a share of the frame height.                  |
| `MAX_W`    | `0.68`                                                 | Widest a bubble gets, as a share of the width.                       |
| `SIZE`     | `0.052`                                                | Text height as a share of the frame width.                           |
| `THEM, ME` | `white with black text, (0, 122, 255) with white text` | Bubble and text colors for each side.                                |

## Without the skill

Don’t want to install the skill? Paste this prompt into Claude Code and Claude writes the script itself.

```
Add a text message conversation to input.mp4, like a phone chat. Four bubbles pop in one at a time and stay: at 0.5 seconds "Is the vitamin C serum worth it?" on the left, at 1.5 seconds "Obsessed. My skin actually glows" on the right, at 2.5 seconds "Wait, where do I get it??" on the left, at 3.5 seconds "Link in bio, 20% off today" on the right. Left bubbles are pure white (255, 255, 255) with black text, 5% of the frame width in from the left edge; right bubbles are blue (0, 122, 255) with white text, 5% in from the right edge. Text is a regular sans-serif 5.2% of the frame width tall, wrapped so no bubble is wider than 68% of the frame width. Bubbles have fully rounded ends, a small tail at the bottom corner nearest their edge and a soft dark shadow. The first bubble's top is 10% of the way down and each one sits 1.8% of the frame height below the last. Each pops in over 0.25 seconds with a slight overshoot, growing out of its tail corner. 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 `text-message-bubbles.py` and run:

```
python3 text-message-bubbles.py input.mp4 output.mp4
```

```
#!/usr/bin/env python3
"""Text message bubbles: a phone chat builds up one bubble at a time, white on the left, blue on the right.

Usage: python3 text-message-bubbles.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, ImageFilter, ImageFont

MESSAGES = [  # (second it appears, "them" on the left or "me" on the right, text)
    (0.5, "them", "Is the vitamin C serum worth it?"),
    (1.5, "me", "Obsessed. My skin actually glows"),
    (2.5, "them", "Wait, where do I get it??"),
    (3.5, "me", "Link in bio, 20% off today"),
]
POP = 0.25                       # seconds each bubble takes to pop in
TOP = 0.10                       # first bubble's top, as a share of the frame height
GAP = 0.018                      # space between bubbles, as a share of the frame height
SIDE = 0.05                      # margin from the frame edge, as a share of the width
MAX_W = 0.68                     # widest a bubble gets, as a share of the width
SIZE = 0.052                     # text height as a share of the frame width
THEM = ((255, 255, 255), (0, 0, 0))     # left bubbles: fill, text
ME = ((0, 122, 255), (255, 255, 255))   # right bubbles: fill, text
FONTS = ["/System/Library/Fonts/Supplemental/Arial.ttf",          # macOS
         "/usr/share/fonts/truetype/dejavu/DejaVuSans.ttf",       # Linux
         "C:/Windows/Fonts/arial.ttf"]                            # Windows
FONT_FILE = next((f for f in FONTS if Path(f).exists()), None) or sys.exit("No font found: add one to FONTS")

def wrap(text, font, width):
    lines = [""]
    for word in text.split():
        trial = f"{lines[-1]} {word}".strip()
        if font.getlength(trial) <= width or not lines[-1]:
            lines[-1] = trial
        else:
            lines.append(word)
    return lines

def bubble(side, text):
    """One rounded bubble with a tail at its bottom corner and a soft shadow, as an RGBA image."""
    fill, ink = THEM if side == "them" else ME
    font = ImageFont.truetype(FONT_FILE, round(w * SIZE))
    pad_x, pad_y, line_h = round(w * SIZE * 0.7), round(w * SIZE * 0.45), round(w * SIZE * 1.25)
    lines = wrap(text, font, w * MAX_W - 2 * pad_x)
    bw = round(max(font.getlength(line) for line in lines)) + 2 * pad_x
    bh = line_h * len(lines) + 2 * pad_y
    m = round(w * 0.03)  # room for the tail and shadow
    img = Image.new("RGBA", (bw + 2 * m, bh + 2 * m))
    shape = Image.new("L", img.size)
    d = ImageDraw.Draw(shape)
    d.rounded_rectangle([m, m, m + bw, m + bh], radius=min(bh // 2, round(w * 0.045)), fill=255)
    tail_x = m if side == "them" else m + bw
    outward = -1 if side == "them" else 1
    d.polygon([(tail_x - outward * m * 0.2, m + bh - m * 1.2), (tail_x + outward * m * 0.6, m + bh),
               (tail_x - outward * m * 1.2, m + bh - m * 0.1)], fill=255)
    shadow = Image.new("RGBA", img.size, (0, 0, 0, 0))
    shadow.putalpha(shape.point(lambda v: v * 0.35).filter(ImageFilter.GaussianBlur(m / 3)))
    img.alpha_composite(shadow, (0, round(m * 0.15)))
    img.paste(Image.new("RGBA", img.size, fill), mask=shape)
    draw = ImageDraw.Draw(img)
    for i, line in enumerate(lines):
        draw.text((m + pad_x, m + pad_y + line_h * (i + 0.5)), line, font=font, anchor="lm", fill=ink)
    return img, m

def layout():
    """Each message's bubble and where its top-left corner goes, stacked down the frame."""
    placed, y = [], h * TOP
    for start, side, text in MESSAGES:
        img, m = bubble(side, text)
        x = w * SIDE - m if side == "them" else w * (1 - SIDE) - img.width + m
        placed.append((start, side, img, round(x), round(y - m)))
        y += img.height - 2 * m + h * GAP
    return placed

def overlay(t):
    img = Image.new("RGBA", (w, h))
    for start, side, b, x, y in bubbles:
        scale = ease_out_back((t - start) / POP) if t >= start else 0
        if scale > 0.02:
            s = b.resize((max(1, round(b.width * scale)), max(1, round(b.height * scale))), Image.LANCZOS)
            # grow out of the tail's corner, the way chat apps do
            ax = x if side == "them" else x + b.width - s.width
            img.alpha_composite(s, (ax, y + b.height - s.height))
    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)
bubbles = layout()
render(src, out)
```

## More captions and text

- [AI chat reply animation **AI chat reply animation**](https://www.recharm.com/effects/ai-chat-typing)
- [Animated bar chart **Animated bar chart**](https://www.recharm.com/effects/animated-bar-chart)
- [Animated checklist **Animated checklist**](https://www.recharm.com/effects/animated-checklist)
- [Animated line graph **Animated line graph**](https://www.recharm.com/effects/animated-line-graph)
- [Animated pie chart **Animated pie chart**](https://www.recharm.com/effects/animated-pie-chart)

## 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](https://www.recharm.com/get-started)
