---
title: "How to add a glitch transition with Claude (tested prompt and script)"
description: "Clip A shudders, splits into red and blue and tears into sideways strips with clip B showing through, then cuts to B as the glitch dies down. Install one skill and ask Claude Code, or run the Python script we tested yourself."
url: https://www.recharm.com/effects/glitch-transition
---

# How to add a glitch transition with Claude

Clip A shudders, splits into red and blue and tears into sideways strips with clip B showing through, then cuts to B as the glitch dies down.

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 glitch transition
   Length of the transition in seconds; the hard cut to B lands halfway through: 0.6
   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 glitch 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.6`   | Length of the transition in seconds; the hard cut to B lands halfway through. |
| `FPS`        | `30`    | Output frame rate.                                                            |
| `SPLIT`      | `16`    | At the peak, how far red moves left and blue moves right, in pixels.          |
| `TEARS`      | `7`     | Horizontal strips torn sideways on each glitch frame at the peak.             |
| `TEAR_SHIFT` | `60`    | Furthest a torn strip slides sideways, in pixels.                             |
| `JITTER`     | `10`    | Furthest the whole picture jumps, in pixels.                                  |
| `SEED`       | `7`     | Random seed; change it for a different but repeatable pattern of tears.       |

## 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.6 second glitch transition that starts 0.6 seconds before the end of A, so the output is 11.4 seconds long. Use Python with numpy and ffmpeg, working frame by frame at 30fps and fitting B to A's size first. On each of the 18 transition frames, with progress p from 0 to 1 and strength s = sin(pi * p): show A for the first half and hard-cut to B at the halfway point (5.7s); jump the whole picture by up to 10 pixels in each direction times s; tear round(7 * s) horizontal strips, each 8 to 96 pixels tall at a random height, sliding them sideways by up to 60 pixels, and fill about 40% of those strips from the other clip so it shows through the tears; then shift the red channel 16 * s pixels left and the blue channel 16 * s pixels right. Use a fixed random seed so it repeats. Leave every frame outside the transition untouched. Crossfade the audio over the same 0.6 seconds. Save it as output.mp4 (H.264, yuv420p).
```

## Run it without Claude

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

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

```
#!/usr/bin/env python3
"""Glitch transition: over 0.6s clip A jitters, splits into red and blue and tears into strips of clip B, then hard-cuts to B as it settles.

Usage: python3 glitch-transition.py clipA.mp4 clipB.mp4 output.mp4  (both clips need an audio track)
Needs ffmpeg and numpy (pip install numpy).
"""
import json
import math
import subprocess
import sys
from itertools import islice

import numpy as np

D = 0.6          # transition length in seconds; the hard cut to B lands halfway through
FPS = 30         # output frame rate
SPLIT = 16       # at the peak, red moves this many pixels left and blue this many right
TEARS = 7        # horizontal strips torn sideways on each glitch frame
TEAR_SHIFT = 60  # furthest a torn strip moves sideways, in pixels
JITTER = 10      # furthest the whole picture jumps, in pixels
SEED = 7         # change for a different (but repeatable) pattern of tears

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 glitch(a, b, p, rng):
    """One transition frame at progress p (0-1): A before the cut, B after, torn and split hardest at the cut."""
    strength = math.sin(math.pi * p)
    main, other = (a, b) if p < 0.5 else (b, a)
    jump = [round(rng.integers(-JITTER, JITTER + 1) * strength) for _ in range(2)]
    img = np.roll(main, jump, axis=(0, 1))
    for _ in range(round(TEARS * strength)):
        y = rng.integers(0, h - 8)
        band = slice(y, y + rng.integers(8, h // 10))
        source = other if rng.random() < 0.4 else img   # some strips show the other clip through the tear
        img[band] = np.roll(source[band], rng.integers(-TEAR_SHIFT, TEAR_SHIFT + 1), axis=1)
    shift = round(SPLIT * strength)
    img[:, :, 0] = np.roll(img[:, :, 0], -shift, axis=1)
    img[:, :, 2] = np.roll(img[:, :, 2], shift, axis=1)
    return img

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

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(glitch(a, b, (i + 0.5) / n, rng).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)
