How to add a glitch effect with Claude

Twice in the clip, for half a second, the picture jumps off center, slices into bands that slide sideways and splits into red and blue edges.

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 a glitch effect to input.mp4
    Start and end of each glitch burst, in seconds: [(1.0, 1.5), (3.5, 4.0)]
    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.

Add a glitch effect 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
BURSTS[(1.0, 1.5), (3.5, 4.0)]Start and end of each glitch burst, in seconds.
FPS30Output frame rate.
SPLIT12During a burst, how far red moves left and blue moves right, in pixels.
TEARS6Horizontal bands torn sideways on each glitch frame.
TEAR_SHIFT80Furthest a torn band slides sideways, in pixels.
JUMP14Furthest the whole picture jumps, in pixels.
SEED3Random 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.

Show the prompt
Add a glitch effect to input.mp4 in two bursts, from 1.0 to 1.5 seconds and from 3.5 to 4.0 seconds. Use Python with numpy and ffmpeg, working frame by frame at 30fps. On every frame inside a burst: shift the whole picture by a random amount up to 14 pixels up or down and up to 14 pixels left or right (wrapping round the edges); then pick 6 horizontal bands, each 8 to 120 pixels tall at a random height, and slide each one sideways by a random amount up to 80 pixels; then shift the red channel 12 pixels left and the blue channel 12 pixels right. Use a fixed random seed so it repeats. Leave every frame outside the bursts untouched. Keep the audio and save it as output.mp4 (H.264, yuv420p).

Run it without Claude

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

python3 glitch-effect.py input.mp4 output.mp4
Show the script
#!/usr/bin/env python3
"""Glitch effect: in two half-second bursts the picture jumps, tears into sideways bands and splits into red and blue.

Usage: python3 glitch-effect.py input.mp4 output.mp4
Needs ffmpeg and numpy (pip install numpy).
"""
import json
import subprocess
import sys

import numpy as np

BURSTS = [(1.0, 1.5), (3.5, 4.0)]  # start and end of each glitch burst, in seconds
FPS = 30          # output frame rate
SPLIT = 12        # during a burst, red moves this many pixels left and blue this many right
TEARS = 6         # horizontal bands torn sideways on each glitch frame
TEAR_SHIFT = 80   # furthest a torn band slides sideways, in pixels
JUMP = 14         # furthest the whole picture jumps, in pixels
SEED = 3          # 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 RGB frames at FPS."""
    ff = subprocess.Popen(["ffmpeg", "-v", "error", "-i", path, "-vf", f"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(frame, rng):
    """Jump the whole picture, slide random bands sideways, then pull red and blue apart."""
    img = np.roll(frame, [rng.integers(-JUMP, JUMP + 1), rng.integers(-JUMP, JUMP + 1)], axis=(0, 1))
    for _ in range(TEARS):
        y = rng.integers(0, h - 8)
        band = slice(y, y + rng.integers(8, h // 8))
        img[band] = np.roll(img[band], rng.integers(-TEAR_SHIFT, TEAR_SHIFT + 1), axis=1)
    img[:, :, 0] = np.roll(img[:, :, 0], -SPLIT, axis=1)
    img[:, :, 2] = np.roll(img[:, :, 2], SPLIT, axis=1)
    return img


src, out = sys.argv[1:3]
w, h, duration = probe(src)
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", src, "-map", "0:v", "-map", "1:a?",
                        "-c:v", "libx264", "-crf", "18", "-pix_fmt", "yuv420p", "-c:a", "copy", "-shortest", out],
                       stdin=subprocess.PIPE)
for i, frame in enumerate(frames(src)):
    t = i / FPS
    if any(start <= t < end for start, end in BURSTS):
        frame = glitch(frame, rng)
    enc.stdin.write(frame.tobytes())
enc.stdin.close()
if enc.wait():
    sys.exit("ffmpeg failed")

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