---
title: "How to add a luma fade with Claude (tested prompt and script)"
description: "Clip B appears through the brightest parts of clip A first and spreads down into the shadows, so the darkest areas switch over last. Install one skill and ask Claude Code, or run the Python script we tested yourself."
url: https://www.recharm.com/effects/luma-fade
---

# How to add a luma fade with Claude

Clip B appears through the brightest parts of clip A first and spreads down into the shadows, so the darkest areas switch over last.

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 luma fade
   Length of the transition in seconds: 1.0
   Width of the soft edge between the clips, as a share of the brightness range: 0.25
   ```

## 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 luma fade.

## 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`     | `1.0`   | Length of the transition in seconds.                                          |
| `SOFT`  | `0.25`  | Width of the soft edge between the clips, as a share of the brightness range. |
| `BLUR`  | `6`     | Blur radius in pixels on the brightness map, so B spreads in smooth shapes.   |
| `FPS`   | `30`    | Frame rate of the output.                                                     |

## 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 1.0 second luma fade that starts 1.0 seconds before A ends, so the result is 11 seconds. On each transition frame, take A's brightness (grayscale), blur it with a 6 pixel Gaussian blur, and stretch it so A's darkest 2% is 0 and brightest 2% is 1. With progress p going from 0 to 1 across the 30 frames, set threshold = 1 - p * 1.25 and show B where the mask clip((brightness - threshold) / 0.25, 0, 1) is 1, A where it is 0, and a mix in between, so B appears through A's brightest areas first and A's darkest areas go last. Before the transition show only A, after it only B. Fit B to A's size (scale to cover, center crop) at 30fps. Do the per-pixel mixing in Python with numpy and Pillow, piping frames to and from ffmpeg. Crossfade the audio over the same 1.0 second. Encode H.264 yuv420p and save it as output.mp4.
```

## Run it without Claude

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

```
python3 luma-fade.py clipA.mp4 clipB.mp4 output.mp4
```

```
#!/usr/bin/env python3
"""Luma fade: clip B shows through the brightest parts of clip A first, then spreads down into the shadows.

Usage: python3 luma-fade.py clipA.mp4 clipB.mp4 output.mp4  (both clips need an audio track)
Needs ffmpeg, Pillow and numpy (pip install pillow numpy).
"""
import json
import subprocess
import sys

import numpy as np
from PIL import Image, ImageFilter

D = 1.0          # transition length in seconds
SOFT = 0.25      # width of the soft edge between the clips, as a share of the brightness range
BLUR = 6         # blur radius (pixels) on the brightness map, so B spreads in smooth shapes, not specks
FPS = 30

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):
    """Every frame of a clip, fitted to A's size at 30fps, as an RGB array."""
    fit = f"scale={w}:{h}:force_original_aspect_ratio=increase,crop={w}:{h},fps={FPS}"
    ff = subprocess.Popen(["ffmpeg", "-v", "error", "-i", path, "-vf", fit, "-f", "rawvideo", "-pix_fmt", "rgb24", "-"],
                          stdout=subprocess.PIPE)
    while chunk := ff.stdout.read(w * h * 3):
        yield np.frombuffer(chunk, np.uint8).reshape(h, w, 3)

def brightness(img):
    """A's brightness, blurred and stretched so its darkest 2% is 0 and brightest 2% is 1."""
    lum = np.asarray(Image.fromarray(img).convert("L").filter(ImageFilter.GaussianBlur(BLUR)), np.float32)
    lo, hi = np.percentile(lum, [2, 98])
    return np.clip((lum - lo) / max(hi - lo, 1), 0, 1)

def luma_fade(a, b, p):
    """Mix of A and B at progress p (0-1): a pixel turns to B once the falling threshold passes its brightness."""
    threshold = 1 - p * (1 + SOFT)
    mask = np.clip((brightness(a) - threshold) / SOFT, 0, 1)[..., None]
    return (a * (1 - mask) + b * mask).astype(np.uint8)

a_path, b_path, out = sys.argv[1:4]
w, h, a_len = probe(a_path)
start = round((a_len - D) * FPS)    # first frame of the transition
ff = subprocess.Popen(["ffmpeg", "-y", "-v", "error", "-f", "rawvideo", "-pix_fmt", "rgb24", "-s", f"{w}x{h}",
                       "-r", str(FPS), "-i", "-", "-i", a_path, "-i", b_path,
                       "-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)
b_frames = frames(b_path)
for i, a in enumerate(frames(a_path)):
    if i >= start:
        a = luma_fade(a, next(b_frames), (i - start + 1) / (round(D * FPS) + 1))
    ff.stdin.write(a.tobytes())
for b in b_frames:
    ff.stdin.write(b.tobytes())
ff.stdin.close()
if ff.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)
