How to add a slit-scan with Claude

As the camera pushes in, each lower row of the picture lags further behind in time, so the serum bottle stretches tall with a big cap over a narrow, tapering label, then eases back to normal.

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 slit-scan to input.mp4
    Second the bend starts: 1.0
    Second it is fully gone again: 5.5

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 slit-scan 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
START1.0Second the bend starts.
END5.5Second it is fully gone again.
RAMP1.0Seconds it takes to ease in, and to ease out.
DELAY2.5Seconds the bottom row lags behind the top row at full strength. More bends moving things further.

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 slit-scan (time displacement) effect to input.mp4. Every output row comes from an earlier frame than the row above it: row y (0 at the top, h-1 at the bottom) of output frame i is row y of input frame i - round(L × y / (h - 1)), where L is the lag in frames, clamped so it never reaches before frame 0. L = 2.5 seconds × 30 fps × s(t), where s(t) is 0 before 1.0 seconds and after 5.5 seconds, eases up to 1 between 1.0 and 2.0 seconds and back down to 0 between 4.5 and 5.5 seconds, with the smoothstep curve u²(3 − 2u) for both ramps. So the top row is always the current frame, the bottom row is up to 2.5 seconds behind, and before 1.0 seconds and after 5.5 seconds the video is unchanged. Use Python with numpy and ffmpeg, keep the size (540x960), 30 fps and the audio, and save it as output.mp4.

Run it without Claude

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

python3 slit-scan.py input.mp4 output.mp4
Show the script
#!/usr/bin/env python3
"""Slit-scan: each row of the picture shows a slightly earlier moment than the row above, so anything moving bends and leans.

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

import numpy as np

START = 1.0    # second the bend starts
END = 5.5      # second it is fully gone again
RAMP = 1.0     # seconds it takes to ease in and to ease out
DELAY = 2.5    # seconds the bottom row lags behind the top row at full strength


def strength(t):
    """0 outside START-END, easing up to 1 over RAMP seconds and back down before END."""
    u = min(max(min(t - START, END - t) / RAMP, 0), 1)
    return u * u * (3 - 2 * u)


def slit_scan(history, lag):
    """Build a frame row by row: row y comes from the frame lag * y / (h - 1) frames back."""
    back = np.round(lag * np.arange(h) / (h - 1)).astype(int)
    back = np.minimum(back, len(history) - 1)
    frame = np.empty_like(history[-1])
    for k in np.unique(back):
        rows = back == k
        frame[rows] = history[-1 - k][rows]
    return frame


def probe(path):
    info = json.loads(subprocess.check_output(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries",
                                               "stream=width,height,r_frame_rate", "-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)


src, out = sys.argv[1:3]
w, h, rate, fps = probe(src)
reader = subprocess.Popen(["ffmpeg", "-v", "error", "-i", src, "-f", "rawvideo", "-pix_fmt", "rgb24", "-"],
                          stdout=subprocess.PIPE)
writer = subprocess.Popen(["ffmpeg", "-y", "-v", "error", "-f", "rawvideo", "-pix_fmt", "rgb24", "-s", f"{w}x{h}",
                           "-r", rate, "-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)
keep = round(DELAY * fps) + 1  # frames of history the bottom row can reach back to
history, i = [], 0
while raw := reader.stdout.read(w * h * 3):
    history = (history + [np.frombuffer(raw, np.uint8).reshape(h, w, 3)])[-keep:]
    lag = DELAY * fps * strength(i / fps)
    writer.stdin.write((slit_scan(history, lag) if lag > 0 else history[-1]).tobytes())
    i += 1
writer.stdin.close()
if reader.wait() or writer.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