---
title: "How to add a flip transition with Claude (tested prompt and script)"
description: "Clip A turns over in 3D like a playing card spinning on its vertical center line, shrinking back into a near-black backdrop until it's a thin sliver edge-on, then swings round with clip B printed on its back. Install one skill and ask Claude Code, or run the Python script we tested yourself."
url: https://www.recharm.com/effects/flip-transition
---

# How to add a flip transition with Claude

Clip A turns over in 3D like a playing card spinning on its vertical center line, shrinking back into a near-black backdrop until it's a thin sliver edge-on, then swings round with clip B printed on its back.

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 flip transition
   Length of the flip in seconds: 0.8
   Output frame rate: 30
   ```

## 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 flip 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 flip in seconds.                                         |
| `FPS`        | `30`           | Output frame rate.                                                     |
| `BACKGROUND` | `(14, 14, 18)` | Color behind the card while it turns.                                  |
| `DEPTH`      | `0.35`         | How far the card drops back mid-flip, as a share of the frame height.  |
| `LENS`       | `1.6`          | Camera distance in frame heights; smaller exaggerates the perspective. |
| `SHADE`      | `0.45`         | How much the card darkens as it turns edge-on (0 = not at all).        |

## 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 card-flip transition, overlapping the clips by 0.8 seconds (the output is 11.2 seconds, 540x960, 30fps). The flip covers the last 0.8 seconds of A and the first 0.8 seconds of B, frame by frame. On each transition frame, with progress p = (i + 0.5) / 24 for frame i of 24, turn the frame like a card about its vertical center line by angle = 180 * e degrees, where e is a cubic ease-in-out of p (4p^3 below 0.5, else 1 - (2 - 2p)^3 / 2). Draw it in 3D perspective: treat each corner (x, y) relative to the frame center as a point with depth z = x * sin(angle) + 0.35 * 960 * sin(pi * p) (so the card also drops back mid-flip), with the camera 1.6 * 960 pixels away, and project it to (270 + x * cos(angle) * k, 480 + y * k) with k = camera / (camera + z); warp the frame onto those four corners with OpenCV's getPerspectiveTransform and warpPerspective. Below 90 degrees the card shows A; from 90 degrees on it shows its back, which is B the right way round (use angle - 180 for B). Darken the card by multiplying it by 1 - 0.45 * (1 - |cos(angle)|) as it turns edge-on. Fill everything around the card with RGB (14, 14, 18). Before the flip the output is A untouched; after it B carries on from 0.8 seconds in, full frame. Crossfade the audio over the same 0.8 seconds. Use Python with OpenCV and numpy for the frames and ffmpeg for the rest (H.264, yuv420p), keep the audio and save it as output.mp4.
```

## Run it without Claude

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

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

```
#!/usr/bin/env python3
"""Flip transition: clip A turns over like a card in 3D perspective over 0.8s, and clip B is on its back.

Usage: python3 flip-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
from itertools import islice

import cv2
import numpy as np

D = 0.8                  # transition length in seconds
FPS = 30                 # output frame rate
BACKGROUND = (14, 14, 18)  # color behind the card while it turns
DEPTH = 0.35             # how far the card drops back mid-flip, as a share of the frame height
LENS = 1.6               # camera distance in frame heights: smaller exaggerates the perspective
SHADE = 0.45             # how much the card darkens as it turns edge-on (0 = not at all)

def probe(path):
    info = json.loads(subprocess.check_output(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries",
                                               "stream=width,height:format=duration", "-of", "json", path]))
    return info["streams"][0]["width"], info["streams"][0]["height"], float(info["format"]["duration"])

def frames(path):
    """Decode a clip as w x h RGB frames at FPS, cropping it to fill the frame if its shape differs."""
    ff = subprocess.Popen(["ffmpeg", "-v", "error", "-i", path, "-vf",
                           f"scale={w}:{h}:force_original_aspect_ratio=increase,crop={w}:{h},fps={FPS}",
                           "-f", "rawvideo", "-pix_fmt", "rgb24", "-"], stdout=subprocess.PIPE)
    while True:
        data = ff.stdout.read(w * h * 3)
        if len(data) < w * h * 3:
            return
        yield np.frombuffer(data, np.uint8).reshape(h, w, 3)

def ease(p):
    """Slow start, fast middle, slow landing (cubic ease-in-out)."""
    return 4 * p ** 3 if p < 0.5 else 1 - (-2 * p + 2) ** 3 / 2

def card(img, angle, push):
    """img as a card turned `angle` degrees about its vertical center line and pushed `push` pixels away."""
    cam = LENS * h
    a = math.radians(angle)
    corners = []
    for x, y in [(-w / 2, -h / 2), (w / 2, -h / 2), (w / 2, h / 2), (-w / 2, h / 2)]:
        z = x * math.sin(a) + push           # depth of this corner, away from the camera
        k = cam / (cam + z)                   # perspective: farther corners draw closer to the center
        corners.append((w / 2 + x * math.cos(a) * k, h / 2 + y * k))
    shade = 1 - SHADE * (1 - abs(math.cos(a)))
    m = cv2.getPerspectiveTransform(np.float32([(0, 0), (w, 0), (w, h), (0, h)]), np.float32(corners))
    lit = (img * shade).astype(np.uint8)
    return cv2.warpPerspective(lit, m, (w, h), flags=cv2.INTER_LINEAR, borderValue=BACKGROUND)

def flip(a, b, p):
    """One transition frame at progress p (0-1): A turns away until edge-on at the halfway point, then B turns in."""
    angle = 180 * ease(p)
    push = DEPTH * h * math.sin(math.pi * p)
    # past 90 degrees we see the card's back, which is B the right way round
    return card(a, angle, push) if angle < 90 else card(b, angle - 180, push)

A, B, out = sys.argv[1:4]
w, h, length = probe(A)
cut_in = round((length - D) * FPS)   # first frame of the transition
n = round(D * FPS)                   # frames in the transition

enc = subprocess.Popen(["ffmpeg", "-y", "-v", "error", "-f", "rawvideo", "-pix_fmt", "rgb24", "-s", f"{w}x{h}",
                        "-r", str(FPS), "-i", "-", "-i", A, "-i", B,
                        "-filter_complex", f"[1:a][2:a]acrossfade=d={D}[au]", "-map", "0:v", "-map", "[au]",
                        "-c:v", "libx264", "-crf", "18", "-pix_fmt", "yuv420p", "-c:a", "aac", out],
                       stdin=subprocess.PIPE)
clip_a, clip_b = frames(A), frames(B)
for a in islice(clip_a, cut_in):
    enc.stdin.write(a.tobytes())
for i, (a, b) in enumerate(zip(islice(clip_a, n), islice(clip_b, n))):
    enc.stdin.write(flip(a, b, (i + 0.5) / n).tobytes())
for b in clip_b:
    enc.stdin.write(b.tobytes())
enc.stdin.close()
if enc.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)
