---
title: "How to add a stutter on beat with Claude (tested prompt and script)"
description: "On each kick drum the orbit snaps back and replays the same 4-frame sliver three times, so the camera judders in place like a skipping record, then jumps ahead to stay in time with the 120 BPM loop. Install one skill and ask Claude Code, or run the Python script we tested yourself."
url: https://www.recharm.com/effects/stutter-on-beat
---

# How to add a stutter on beat with Claude

On each kick drum the orbit snaps back and replays the same 4-frame sliver three times, so the camera judders in place like a skipping record, then jumps ahead to stay in time with the 120 BPM loop.

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

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

   ```
   Add a stutter on beat to input.mp4
   Length of the repeated slice as a fraction of a beat: 0.25
   How many times the slice plays on each beat: 3
   ```

## 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 stutter on beat 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.

| Setting   | Default | What it does                                                                                         |
| --------- | ------- | ---------------------------------------------------------------------------------------------------- |
| `SLICE`   | `0.25`  | Length of the repeated slice as a fraction of a beat. 0.25 is a sixteenth note, 4 frames at 120 BPM. |
| `REPEATS` | `3`     | How many times the slice plays on each beat.                                                         |
| `BASS_HZ` | `150`   | Beats are found in the sound below this frequency, where the kick drum sits.                         |
| `RATE`    | `22050` | Audio sample rate the beat tracking uses.                                                            |
| `HOP`     | `256`   | Audio samples per analysis step. Smaller gives more exact beat times.                                |

## Without the skill

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

```
Add a stutter on the beat to input.mp4. Find the kick drum beats with librosa: take the onset strength of the audio (mono, 22050 Hz) with hop_length 256, fmax 150 Hz and n_mels 8, run librosa.beat.beat_track on that envelope, move each beat back to where its hit starts with librosa.onset.onset_backtrack, convert to seconds and round each to the nearest video frame. The slice is a quarter of a beat: the median gap between beats times 0.25, rounded to whole frames (4 frames at 30fps for this 120 BPM loop). On each beat, the frames from the beat onward play the slice three times in a row (output frame beat+i shows source frame beat + i mod 4, for i from 0 to 11), then the video carries on from its own frame (frame beat+12 shows source frame beat+12), so it stays in time with the music. Frames outside a stutter are untouched. Keep the original audio unchanged. No text is needed; if you add any, draw it with Pillow, not ffmpeg's drawtext. Keep the size (540x960) and 30fps, encode H.264 yuv420p, and save it as output.mp4.
```

## Run it without Claude

This is the exact script we tested. Save it as `stutter-on-beat.py` and run:

```
python3 stutter-on-beat.py input.mp4 output.mp4
```

```
#!/usr/bin/env python3
"""Stutter on beat: on every kick drum a quarter-beat slice of the picture plays three times in a row, then the clip carries on in time.

Usage: python3 stutter-on-beat.py input.mp4 output.mp4  (the input needs a music track with a beat)
Needs ffmpeg, librosa and numpy (pip install librosa numpy).
"""
import json
import subprocess
import sys

import librosa
import numpy as np

SLICE = 0.25          # length of the repeated slice, as a fraction of a beat (0.25 = a sixteenth note)
REPEATS = 3           # times the slice plays on each beat
BASS_HZ = 150         # beats are found in the sound below this frequency (the kick drum)
RATE = 22050          # audio sample rate the beat tracking uses
HOP = 256             # audio samples per analysis step (smaller = more exact beat times)

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)

def beat_times(src):
    """Kick drum beats in seconds: track the beat in the bass, then move each one back to where its hit starts."""
    pcm = subprocess.check_output(["ffmpeg", "-v", "error", "-i", src, "-ac", "1", "-ar", str(RATE), "-f", "f32le", "-"])
    audio = np.frombuffer(pcm, np.float32)
    bass = librosa.onset.onset_strength(y=audio, sr=RATE, hop_length=HOP, fmax=BASS_HZ, n_mels=8)
    _, beats = librosa.beat.beat_track(onset_envelope=bass, sr=RATE, hop_length=HOP)
    beats = librosa.onset.onset_backtrack(beats, bass)
    return librosa.frames_to_time(beats, sr=RATE, hop_length=HOP)

src, out = sys.argv[1], sys.argv[2]
w, h, rate, fps = probe(src)
beats = np.round(beat_times(src) * fps).astype(int)              # beats as video frame numbers
slice_len = max(1, round(np.median(np.diff(beats)) * SLICE))      # slice length in frames

frames = []
reader = subprocess.Popen(["ffmpeg", "-v", "error", "-i", src, "-f", "rawvideo", "-pix_fmt", "rgb24", "-"],
                          stdout=subprocess.PIPE)
while True:
    raw = reader.stdout.read(w * h * 3)
    if len(raw) < w * h * 3:
        break
    frames.append(raw)
reader.wait()

# Each output frame shows its own source frame, except for the REPEATS slices after a beat, which loop back to
# the slice that starts on the beat. After the stutter the picture jumps ahead so it stays in time with the music.
source = list(range(len(frames)))
for b in beats:
    for i in range(b, min(b + slice_len * REPEATS, len(frames))):
        source[i] = b + (i - b) % slice_len

writer = subprocess.Popen(["ffmpeg", "-v", "error", "-y", "-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)
for n in source:
    writer.stdin.write(frames[n])
writer.stdin.close()
sys.exit(writer.wait())
```

## More music-synced visuals

- [AI voice orb **AI voice orb**](https://www.recharm.com/effects/ai-voice-orb)
- [Audio-reactive blob **Audio-reactive blob**](https://www.recharm.com/effects/audio-reactive-blob)
- [Audio-reactive particles **Audio-reactive particles**](https://www.recharm.com/effects/audio-reactive-particles)
- [Audio-reactive text **Audio-reactive text**](https://www.recharm.com/effects/audio-reactive-text)
- [Audio waveform **Audio waveform**](https://www.recharm.com/effects/audio-waveform)

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