---
title: "How to add a swirl transition with Claude (tested prompt and script)"
description: "Clip A winds into a spiral whirlpool around the center of the frame while its corners stay put, and clip B unwinds out of the same whirlpool. Install one skill and ask Claude Code, or run the Python script we tested yourself."
url: https://www.recharm.com/effects/swirl-transition
---

# How to add a swirl transition with Claude

Clip A winds into a spiral whirlpool around the center of the frame while its corners stay put, and clip B unwinds out of the same whirlpool.

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

## 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

   ```
   Join clipA.mp4 and clipB.mp4 with a swirl transition
   Length of the transition in seconds: 0.8
   Degrees the center of the frame turns at the peak; the twist fades to nothing at the corners: 540
   ```

## 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.

Put a sale badge on **@clip1.mp4**, give **@clip2.mp4** a VHS look, then join them with a swirl transition.

## 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                                                                                  |
| ------- | ------- | --------------------------------------------------------------------------------------------- |
| `D`     | `0.8`   | Length of the transition in seconds.                                                          |
| `TWIST` | `540`   | Degrees the center of the frame turns at the peak; the twist fades to nothing at the corners. |
| `SWAP`  | `0.2`   | Share of the transition, around the peak, over which A dissolves into B.                      |

## Without the skill

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

```
Join clipA.mp4 and clipB.mp4 with a 0.8 second swirl transition, overlapping the clips by 0.8 seconds (the output is 11.2 seconds). Over the last 0.8 seconds of A, twist each frame about the frame's center: a pixel at distance r from the center turns by angle * (1 - r/R)^2, where R is the distance from the center to a corner, so the center spins most and the corners don't move. The angle rises from 0 to 540 degrees and back to 0 with a cosine ease (angle = 540 * (1 - cos(2*pi*p)) / 2, p going 0 to 1 across the transition). Twist the first 0.8 seconds of B the same way and dissolve from twisted A to twisted B over the middle 20% of the transition (p from 0.4 to 0.6), so B unwinds out of the whirlpool and lands untwisted. Before the transition the output is A untouched, after it B carries on from 0.8 seconds in. Crossfade the audio over the same 0.8 seconds. Match B's size and frame rate to A, use Python with OpenCV (cv2.remap) and numpy for the frames and ffmpeg for the rest, and save it as output.mp4 (H.264, yuv420p, 30fps).
```

## Run it without Claude

This is the exact script we tested. Save it as `swirl-transition.py` and run:

```
python3 swirl-transition.py clipA.mp4 clipB.mp4 output.mp4
```

```
#!/usr/bin/env python3
"""Swirl transition: clip A twists into a whirlpool around the frame's center, then clip B untwists out of it, over 0.8s.

Usage: python3 swirl-transition.py clipA.mp4 clipB.mp4 output.mp4  (both clips need an audio track)
Needs ffmpeg, OpenCV and numpy (pip install opencv-python-headless numpy).
"""
import json
import math
import subprocess
import sys

import cv2
import numpy as np

D = 0.8          # transition length in seconds
TWIST = 540      # degrees the center turns at the peak; the twist fades to nothing at the corners
SWAP = 0.2       # share of the transition, around the peak, over which A dissolves into B

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 frames(path, start):
    """The transition's frames from path, starting at `start` seconds, fitted to A's size and frame rate."""
    raw = subprocess.check_output(["ffmpeg", "-v", "error", "-ss", f"{start:.3f}", "-i", path, "-frames:v", str(n),
                                   "-vf", f"scale={w}:{h}:force_original_aspect_ratio=increase,crop={w}:{h},fps={rate}",
                                   "-f", "rawvideo", "-pix_fmt", "rgb24", "-"])
    return [np.frombuffer(raw[i * w * h * 3:(i + 1) * w * h * 3], np.uint8).reshape(h, w, 3) for i in range(n)]

def swirled(img, degrees):
    """img twisted about its center: each pixel turns by `degrees` times (1 - distance/corner distance)^2."""
    phi = theta + math.radians(degrees) * falloff
    return cv2.remap(img, (cx + r * np.cos(phi)).astype(np.float32), (cy + r * np.sin(phi)).astype(np.float32),
                     cv2.INTER_LINEAR, borderMode=cv2.BORDER_REFLECT)

def swirl_frame(i):
    """Frame i: the twist winds up to TWIST and back down (cosine ease), A dissolving into B around the peak."""
    p = i / (n - 1)
    degrees = TWIST * (1 - math.cos(2 * math.pi * p)) / 2
    mix = min(max((p - 0.5) / SWAP + 0.5, 0), 1)
    a, b = swirled(a_frames[i], degrees), swirled(b_frames[i], degrees)
    return cv2.addWeighted(a, 1 - mix, b, mix, 0)

a_path, b_path, out = sys.argv[1:4]
w, h, rate, fps, a_len = probe(a_path)
n = round(D * fps)
offset = a_len - D
a_frames, b_frames = frames(a_path, offset), frames(b_path, 0)

# polar coordinates of every output pixel, worked out once
cx, cy = (w - 1) / 2, (h - 1) / 2
ys, xs = np.mgrid[0:h, 0:w].astype(np.float32)
r, theta = np.hypot(xs - cx, ys - cy), np.arctan2(ys - cy, xs - cx)
falloff = (1 - r / math.hypot(cx, cy)) ** 2

# A up to the transition, the swirled frames, then B from where the transition ends; the sound crossfades over D
ff = subprocess.Popen(["ffmpeg", "-y", "-v", "error", "-i", a_path, "-i", b_path,
                       "-f", "rawvideo", "-pix_fmt", "rgb24", "-s", f"{w}x{h}", "-r", rate, "-i", "-",
                       "-filter_complex",
                       f"[0:v]trim=end={offset:.4f},setpts=PTS-STARTPTS,fps={rate},format=yuv420p,setsar=1[a];"
                       f"[1:v]scale={w}:{h}:force_original_aspect_ratio=increase,crop={w}:{h},fps={rate},"
                       f"trim=start={D},setpts=PTS-STARTPTS,format=yuv420p,setsar=1[b];"
                       f"[2:v]format=yuv420p,setsar=1[s];"
                       f"[a][s][b]concat=n=3:v=1:a=0[v];[0:a][1:a]acrossfade=d={D}[au]",
                       "-map", "[v]", "-map", "[au]", "-c:v", "libx264", "-crf", "18", "-pix_fmt", "yuv420p",
                       "-c:a", "aac", out], stdin=subprocess.PIPE)
for i in range(n):
    ff.stdin.write(swirl_frame(i).tobytes())
ff.stdin.close()
if ff.wait():
    sys.exit("ffmpeg failed")
```

## More transitions

- [Barn door transition **Barn door transition**](https://www.recharm.com/effects/barn-door)
- [Blinds transition **Blinds transition**](https://www.recharm.com/effects/blinds-transition)
- [Block dissolve **Block dissolve**](https://www.recharm.com/effects/block-dissolve)
- [Blur transition **Blur transition**](https://www.recharm.com/effects/blur-transition)
- [Bounce transition **Bounce transition**](https://www.recharm.com/effects/bounce-transition)

## 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)
