Log in
TechniqueBy @rebeccaVersion 1, updated

Cut one person from a re-render into the original take

rebecca/python-composite-person-from-rerender

Fix one person in an approved locked-off shot without losing anyone else's performance: re-render the whole take with the same pinned frames and soundtrack plus that person's reference pictures, then cut a feathered vertical strip holding only them into the original, frame by frame. The original's sound and length are kept. Free and local after the re-render. Use when a listener in a wide shot looks off (face, identity, stiffness) but the speaker's take is approved.

SKILL.md

A wide shot has an approved performance from the speaker, but the person beside her (often a listener with no reference pictures in the original render) looks off. A full re-render puts the approved performance at risk. Instead:

  1. Re-render the same take with the same first, middle and last frames, the same soundtrack (target_audio_url) and the same duration. Add the off person's reference pictures and a sentence for them ("<Subject 2> is the man in glasses … listening, alive and natural"). Run one take as a test, show it, then batch the rest.
  2. Measure that person's strip from a frame: the x range they occupy for the whole take, as fractions of the width, with a little margin. Nobody else's arm, head or prop should cross it (in one case, 0.44–0.675 of the width).
  3. Composite with the script below. Everything outside the strip, and all the sound, stays the original's.
  4. Check frames at 0.25 s steps, and look hard at the strip's edges and at moments when anyone moves near them.

When it works

  • The camera is locked. Both takes start and end on the same pinned frames, so the backgrounds line up frame by frame.
  • The person stays inside one vertical strip for the whole take.
  • They don't speak in this shot, or their words are in the shared soundtrack and the new take's lips match it.

It doesn't suit camera moves (the strip slides), people crossing in front, or a different framing. Leave those shots alone, and hide what remains with a darker, softly blurred title gradient (python-title-card-soft-gradient).

Script

Save as scripts/composite_band.py and run it: python scripts/composite_band.py ORIGINAL.mp4 NEW.mp4 OUT.mp4 0.44 0.675 16.

"""Cut one person from a re-render into the original take: a vertical band of the new
take (x0..x1 as fractions of the width, feathered by F px) is laid over the original
frame by frame; everything else, and the sound, stay the original's. The original sets
the length (if the new take runs short, its last frame is held).

  python scripts/composite_band.py ORIGINAL.mp4 NEW.mp4 OUT.mp4 X0 X1 [FEATHER_PX]
"""
import subprocess
import sys

import numpy as np

orig, new, out = sys.argv[1:4]
x0f, x1f = float(sys.argv[4]), float(sys.argv[5])
F = int(sys.argv[6]) if len(sys.argv) > 6 else 24


def size(src):
    o = subprocess.run(["ffprobe", "-v", "error", "-select_streams", "v:0", "-show_entries", "stream=width,height",
                        "-of", "csv=p=0", src], capture_output=True, text=True).stdout.strip()
    return tuple(int(v) for v in o.split(","))


W, H = size(orig)
x = np.arange(W, dtype=np.float32)
x0, x1 = x0f * W, x1f * W
m = np.clip((x - x0) / F + 0.5, 0, 1) * np.clip((x1 - x) / F + 0.5, 0, 1)
M = m[None, :, None]
dec = [subprocess.Popen(["ffmpeg", "-v", "error", "-i", s, "-vf", f"scale={W}:{H},fps=24", "-f", "rawvideo",
                         "-pix_fmt", "rgb24", "-"], stdout=subprocess.PIPE) for s in (orig, new)]
enc = subprocess.Popen(["ffmpeg", "-v", "error", "-y", "-f", "rawvideo", "-pix_fmt", "rgb24", "-s", f"{W}x{H}",
                        "-r", "24", "-i", "-", "-i", orig, "-map", "0:v", "-map", "1:a?", "-c:v", "libx264",
                        "-crf", "14", "-pix_fmt", "yuv420p", "-c:a", "aac", "-b:a", "192k", "-shortest", out],
                       stdin=subprocess.PIPE)
n, fb = 0, None
while True:
    a = dec[0].stdout.read(W * H * 3)
    if len(a) < W * H * 3:
        break
    b = dec[1].stdout.read(W * H * 3)
    if len(b) == W * H * 3:
        fb = np.frombuffer(b, np.uint8).reshape(H, W, 3).astype(np.float32)
    fa = np.frombuffer(a, np.uint8).reshape(H, W, 3).astype(np.float32)
    if fb is None:
        fb = fa
    enc.stdin.write((fa * (1 - M) + fb * M).astype(np.uint8).tobytes())
    n += 1
enc.stdin.close()
enc.wait()
print(out, n, "frames")
  • Composite before any retime. If a take is played faster in the cut, speed up the composite, not the parts.
  • Feather 16 px at 1080p hid the seam. Wider feathers ghost when the two takes' light differs.
  • Cost: one re-render per take (about $0.60 for a 6 s H3 Max 768P take). The composite is free.

FAQs

Fix one person in an approved locked-off shot without losing anyone else's performance: re-render the whole take with the same pinned frames and soundtrack plus that person's reference pictures, then cut a feathered vertical strip holding only them into the original, frame by frame. The original's sound and length are kept. Free and local after the re-render. Use when a listener in a wide shot looks off (face, identity, stiffness) but the speaker's take is approved.

Install Hypernatural Desktop, a free Mac app, and connect it to Claude Code, Codex or Claude Desktop. Then describe the video you want and your agent finds the skill itself, or paste this page's link (https://hypernatural.ai/skill/rebecca/python-composite-person-from-rerender) and it installs rebecca/python-composite-person-from-rerender and follows it.

It runs MiniMax H3 Max. Hypernatural Desktop has every one of them built in, so there are no API keys to set up, though you can bring your own.

The skill is free. You only pay for the AI generations it runs, and your agent shows you the price of every batch before it spends anything. Editing, captions and titles run on your Mac at no cost.

Yes. Ask your agent to adjust it for your job, or to save its own version. You can publish your version under your own handle so anyone can install it.

Go make something cool.

Install the app, open your agent, describe the video. That's the whole onboarding.

Sticker HypernaturalSticker BannerSticker TVBoy