All guidesfree.johnsavageai.com
John SavageAI guides

a free guide

Pixel Reveal effect: the free skill for Chat GPT or Claude

Upload your pictures, paste one prompt, get the pixel reveal video.

What you’ll get

  • The pixel reveal video from the reel, made from your own pictures
  • One prompt to copy, with the full script inside
  • Soft sounds and a 1080x1920 mp4 that is ready to post
0 of 5 doneNow: Open Claude or Chat GPT
  1. Open Claude or Chat GPT

    Use a chat that can run code. Claude with code execution or Claude Code works best.

  2. Upload 2 to 6 pictures or short clips

    Pictures and short clips both work.

  3. Copy the prompt and paste it

    Paste the prompt below into the chat. Add your own titles if you want: "small line | BIG line | small line" for each picture.

    Prompt 1 of 1: Pixel Reveal
    # PIXEL REVEAL video effect You are making a short vertical video from the files I uploaded (pictures and/or short video clips). Follow these steps exactly. Write code and run it yourself; give me a finished mp4, not instructions. ## What the video looks like - **Stage:** dark background `#1A191C` with a grey grid (`#545458`, big squares 235 px, faint small squares 29 px), fine halftone print dots, light film grain, soft vignette. The camera is never still: the grid slides up 130 px in the first second, then the view slowly pulls back (grid to 90 %, picture card to 84 %, so the two layers move apart = parallax) and keeps drifting very slowly. - **Picture card:** 918 x 1113 px, rounded corners (radius 18 px), centred, top at about y 190. Thin light-blue rim `#A5CDFF` and a faint blue "glass echo" 7 px up-right behind it. Pictures are cropped to fill the card. A video clip keeps playing inside its card (it loops). - **First reveal (0.2 to 1.0 s):** the card rises 320 px into place while the picture appears from bottom to top through a **mosaic matte**: 58 x 58 blocks, hard edges, with a jagged edge of loose blocks. A short warm glow sits around the first strip. - **Title, yellow `#F4EA8E`, three lines:** a small script line that overlaps the card's bottom-left corner, a big bold line as wide as the card, a small script line right-aligned below. Each line rises fast, starts as a grey blur inside a wide soft olive-yellow glow (`#767C34`) with a pale rim (`#FFF6A8`) around the letters, then **snaps sharp** in one step and turns yellow. Every picture has its own title: the old one blurs away when a transition starts, the new one glows in at 45 % of the transition. - **Transitions between pictures**, in this order, repeating: **ring closing** (new picture grows in from the corners and closes on the old subject), **block wipe** bottom to top, **ring opening** (from the new subject outwards), ring closing. They use **big cubes: 32 across the card** (about 29 x 35 px). Cubes flip **one by one in scattered order** near the moving edge, never as a clean line. Each cube **lights up for a split second in its OWN brighter, richer colour** (never white, never grey) and fades over 4 ticks (about 0.13 s), with a small glow of the same colour. - **Speed:** each transition takes 38 ticks = 76 frames = about 1.3 s, then the picture holds about 0.45 s (14 ticks) before the next one starts. Slow enough to read every title. - **End:** a short flash to white, then the empty stage (or `--end hold` to stay on the last picture). - **Sound (optional, on by default):** soft bell notes and tiny ticks made in code, one on every event (blocks climbing, title snap, each transition, flash). C major pentatonic, no music. - **Output:** 1080 x 1920, 60 fps, H.264 mp4 (yuv420p). Length: 1 picture = 4.1 s, 2 pictures = 3.7 s, every extra picture adds 1.73 s (5 pictures = 8.9 s). ## The maths (already in the script; keep it if you change anything) - Time unit: 1 tick = 1/30 s. Tables of keyframes are in ticks. - Mosaic matte, per block: `v = ramp + amp * (noise - 0.5)`; the block is visible when `v < threshold`, and the threshold moves with the progress. Up-scale blocks to pixels with nearest neighbour (hard edges). - First reveal: `ramp` = 0 at the bottom row, 1 at the top row; 58 blocks; `amp` 0.20; `noise` = white noise mixed with sideways clumps. - Block wipe: same ramp, 32 cubes, `amp` 0.08, plain white noise per cube (this gives the scattered flip order), smoothstep progress. - Rings: `ramp` = distance from the subject's centre (in card widths) + `amp * (noise - 0.5)`, compared with a radius that shrinks (closing, table `RING`, 0.80 to 0) or grows (opening, ease-out power 1.8). - Cube shine: build the same mask for 8 earlier moments (0.5 to 4 ticks back). `age = mean of those masks`. `glow = mask * (1 - age)^1.5 * strength_of_this_cube` (random 0.3 to 1.0 per cube) `* 0.85`. Lit colour = `colour * (1 + 1.9 * glow) + 14 * glow`, scaled down so the largest channel stays under 250 (this keeps the hue), then saturation x `(1 + 0.45 * glow)`, plus a blurred copy (sigma 10 px) x 0.55 as glow. - Title glow: haze = (blur 93 px x 5.2 + blur 33 px x 1.3) of the text, added in olive-yellow; rim = blur about 7 to 14 px x 1.7 minus the text body; body = text blurred 15 px to 0. The blur, haze and rim all drop to zero at tick 8 of the title (the snap). ## Steps 1. **Inputs.** Use every file I uploaded, in upload order (or file-name order). Do not ask me questions if you can avoid it. Ask only if there is no picture or clip at all. If a file is HEIC/WEBP or another format Pillow cannot open, convert it to PNG/JPG first. 2. **Titles.** If I gave titles, use them. If not, look at each picture (or the first frame of each clip) and invent a short 3-line title for it: small line (1 to 2 words) | BIG line (1 to 2 words, at most about 12 letters) | small line (1 to 2 words). Example: `Open late|Night Store|24 / 7`. If you cannot look at the pictures, build the titles from the file names. 3. **Subject centre.** For each picture estimate where the main subject is, as `x,y` from 0 to 1 (0,0 = top-left). The rings close and open there. If unsure use `0.5,0.45`. 4. **Save the script below** as `pixel_reveal.py`, exactly as written. Do not rewrite it or "simplify" it. It needs only Python 3.9+, numpy and Pillow, runs on CPU with no internet and finds fonts by itself (a handwriting or italic font for the script lines, a bold sans such as DejaVu Sans Bold for the big line; pass `--font-bold` / `--font-script` with a .ttf path to choose your own). 5. **Encoder.** The script uses `ffmpeg` if it is on PATH. If it is not, try `pip install imageio-ffmpeg` (the script picks it up). If that is not possible either, it falls back to OpenCV (`cv2.VideoWriter`): that file has no sound and is not H.264, so tell me. Clips are read with ffmpeg, or with OpenCV when there is no ffmpeg. 6. **Check 3 still frames first.** Run it with `--stills`. It writes `still_1.jpg`, `still_2.jpg`, `still_3.jpg` in about a second. Open them and really look: - still_1: only the lower part of the picture is visible, its top edge is a jagged line of small blocks, and the big title is a blurred grey word inside a yellow glow. - still_2 and still_3: two pictures share the card, split by a ring or a line made of big square cubes; some cubes at the edge are clearly brighter in their own colour, none is plain white. - All text is inside the frame, not cut off, and each title fits its picture. The subject is not cropped badly (if it is, change `--center`). Fix what is wrong (shorter title, other centre, other font) and check again. 7. **Render the full video.** Speed: all the work is vectorised numpy, about 0.1 to 0.4 s per frame, so a 9 s video takes about 1 to 4 minutes. If your tool stops long commands, start it in the background (`nohup python pixel_reveal.py ... > log.txt 2>&1 &`) and read `log.txt` until it says `DONE`. 8. **Hand back** the mp4 and one short line such as: "Tell me new titles, a new picture order or a speed (for example 0.8 = slower) and I will render it again." Nothing else is needed. Example command: ``` python pixel_reveal.py one.jpg two.mp4 three.png -o pixel_reveal.mp4 \ --title "How to|Pixel Reveal|Effect" --title "Open late|Night Store|24 / 7" --title "Above|Sky Whale|the clouds" \ --center 0.5,0.42 --center 0.62,0.5 --center 0.5,0.42 ``` Options: `--speed 0.8` (slower transitions and holds; 1.25 = faster), `--kinds ring_in,wipe_up,ring_out` (order of the transitions), `--end hold`, `--no-sound`, `--preset veryfast` (quicker encode). To change look values (block counts `NB1` / `NB2`, colours, `SHINE`, `GRAIN`) edit the constants at the top of the script. ## The script ```python #!/usr/bin/env python3 """PIXEL REVEAL: pictures or clips appear through big pixel blocks on a dark grid stage, with glowing yellow titles. Needs numpy + Pillow, and for the mp4: ffmpeg on PATH, or `pip install imageio-ffmpeg`, or OpenCV (last resort). python pixel_reveal.py a.jpg b.mp4 c.png -o out.mp4 --title "How to|Pixel Reveal|Effect" --title "Open late|Night Store|24 / 7" add --stills to write 3 check frames (still_1.jpg ...) instead of the video. Time unit in the tables: 1 tick = 1/30 s (2 frames at 60 fps). Pixel numbers are for 1080 x 1920.""" import argparse, glob, math, os, re, shutil, subprocess, sys, time, wave import numpy as np from PIL import Image, ImageDraw, ImageFont, ImageOps W, H, FPS = 1080, 1920, 60 CW, CH = 918, 1113 # picture card (85 % of the width), corner radius 18 STAGE, GRIDC = (26, 25, 28), (84, 84, 88) # #1A191C stage, #545458 grid lines CREAM, HAZEC, RIMC = (244, 234, 142), (118, 124, 52), (255, 246, 168) # title #F4EA8E, glow haze, glow rim NB1, AMP1 = 58, 0.20 # first reveal: 58 blocks across, jagged band NB2, AMP2 = 32, 0.08 # transitions: 32 big cubes across, per-cube scatter T0, TN, STEP = 40, 38, 52 # first transition starts at tick 40; 38 ticks long (76 frames); next one 52 ticks later SHINE, GRAIN = 0.85, 0.028 KINDS = ['ring_in', 'wipe_up', 'ring_out', 'ring_in'] def tab(d, smooth=0.6): """keyframes {tick: value} -> function of time (linear, slightly smoothed so camera moves have no kinks)""" x = np.array(sorted(d), float); y = np.array([d[k] for k in sorted(d)], np.float32) if y.ndim == 2: return lambda f: np.array([np.interp(f, x, y[:, c]) for c in range(3)], np.float32) return lambda f: float(np.interp([f - smooth, f, f + smooth], x, y).mean()) GRID_DY = tab({0: 130, 1: 129, 2: 124, 3: 115, 4: 102, 5: 90, 6: 80, 7: 69, 8: 62, 9: 54, 10: 48, 12: 38, 14: 28, 16: 22, 18: 16, 20: 10, 22: 7, 24: 3, 28: 0}) GRID_S = tab({32: 1, 34: .996, 36: .988, 40: .971, 44: .945, 48: .926, 52: .913, 56: .907, 62: .9, 90: .89}) CARD_S = tab({28: 1, 30: .995, 32: .985, 34: .971, 36: .956, 38: .931, 40: .907, 42: .891, 44: .876, 48: .861, 52: .851, 56: .846, 62: .8415, 90: .833}) CARD_CY = tab({28: 748.5, 40: 763.5, 62: 765}) CARD_DY = tab({5: 360, 6: 322, 7: 308, 8: 258, 9: 225, 10: 202, 11: 171, 12: 147, 13: 120, 14: 105, 15: 90, 16: 75, 18: 45, 20: 30, 22: 18, 24: 9, 26: 3, 28: 0}) REVEAL = tab({6.5: 0, 8: .04, 10: .09, 12: .22, 14: .36, 16: .47, 18: .58, 20: .72, 22: .83, 24: .89, 26: .945, 28: .975, 30: 1, 31: 1.02}, 0.3) CARD_GLOW = tab({6: 0, 7: 1, 9: 1, 11: .8, 12: .5, 14: .15, 16: 0}) RING = tab({0: .80, 2: .72, 4: .62, 6: .50, 8: .42, 10: .36, 12: .28, 14: .20, 16: .12, 18: .06, 20: .02, 21: -.06}, 0.2) # radius, card widths RIM = tab({40: .15, 46: .7}) # title light: r = ticks since the title started. It rises fast, is a grey blur inside a yellow glow, snaps sharp at r = 8. L_DY = tab({-1: 156, 0: 150, 1: 142, 2: 117, 3: 84, 4: 22, 5: 18, 6: 10, 7: 7, 8: 2, 10: 0}, 0.3) L_BLUR = tab({0: 15, 3: 13.5, 4: 12, 5: 10.5, 6: 9, 7: 4.5, 8: 0}, 0) L_OP = tab({0: 0, 1: .2, 2: .45, 3: .7, 4: .95, 5: 1}, 0) L_COL = tab({1: (52, 52, 54), 3: (70, 70, 74), 4: (118, 118, 128), 6: (135, 135, 148), 7: (200, 200, 195), 8: (205, 200, 140), 10: (238, 230, 150), 12: CREAM}) L_HAZE = tab({2: 0, 3: .12, 4: .6, 5: .8, 6: 1, 7: 1, 8: .08, 10: .05}, 0) L_RIM = tab({3: 0, 4: .2, 5: .6, 6: .9, 7: 1, 8: 0}, 0) F_LIFT = tab({61: 0, 62: 6, 63: 92, 64: 146, 65: 172, 66: 222, 67: 252, 68: 255, 69: 210, 71: 120, 74: 40, 78: 6, 82: 0}, 0.2) # flash at the end def blur(a, sigma, ds=1): """Gaussian blur of a float array; ds > 1 = blur a smaller copy (fast, for glows).""" if sigma < 0.3: return a if a.ndim == 3: return np.dstack([blur(a[..., c], sigma, ds) for c in range(a.shape[2])]) h, w = a.shape; a = np.ascontiguousarray(a, np.float32) if ds > 1: a = np.asarray(Image.fromarray(a).resize((max(1, w // ds), max(1, h // ds)), Image.BOX)); sigma /= ds r = max(1, int(sigma * 3)); k = np.exp(-0.5 * (np.arange(-r, r + 1) / sigma) ** 2).astype(np.float32); k /= k.sum() for ax in (0, 1): # separable: rows, then columns p = np.pad(a, [(r, r) if i == ax else (0, 0) for i in (0, 1)], mode='edge'); n = a.shape[ax] a = sum(k[j] * (p[j:j + n] if ax == 0 else p[:, j:j + n]) for j in range(2 * r + 1)) if ds > 1: a = np.asarray(Image.fromarray(np.ascontiguousarray(a, np.float32)).resize((w, h), Image.BILINEAR)) return a def halftone(w, h, pitch, strength): # fine print dots at 45 degrees yy, xx = np.mgrid[0:h, 0:w].astype(np.float32); q = math.pi / pitch * 0.7071 d = np.sin((xx + yy) * q) ** 2 * np.sin((xx - yy) * q) ** 2 return (1.0 - strength * (1 - np.clip((d - 0.18) / 0.22, 0, 1))).astype(np.float32) def rounded(w, h, r): im = Image.new('L', (w * 2, h * 2), 0); ImageDraw.Draw(im).rounded_rectangle((0, 0, w * 2 - 1, h * 2 - 1), r * 2, fill=255) return np.asarray(im.resize((w, h), Image.LANCZOS), np.float32) / 255 def clump_noise(nb, seed): """per-block noise for the first reveal: white noise + sideways clumps, pushed towards the middle (bell shape)""" r = np.random.default_rng(seed); rs = lambda a: np.asarray(Image.fromarray(a.astype(np.float32)).resize((nb, nb), Image.BICUBIC)) n = 0.38 * r.random((nb, nb)) + 0.40 * rs(r.random((nb // 2 + 2, nb // 5 + 2))) + 0.22 * rs(r.random((nb // 6 + 2, nb // 9 + 2))) u = n.ravel().argsort().argsort().reshape(nb, nb) / (nb * nb - 1) * 2 - 1 return (0.5 + 0.5 * np.sign(u) * np.abs(u) ** 2.2).astype(np.float32) def find_ffmpeg(): exe = shutil.which('ffmpeg') if not exe: try: import imageio_ffmpeg; exe = imageio_ffmpeg.get_ffmpeg_exe() except Exception: exe = None return exe def find_font(pats): dirs = ['~/Library/Fonts', '/Library/Fonts', '/System/Library/Fonts', '/usr/share/fonts', '/usr/local/share/fonts', 'C:/Windows/Fonts'] dirs += [os.path.join(p, 'matplotlib', 'mpl-data', 'fonts', 'ttf') for p in sys.path if p] for pat in pats: for d in dirs: hit = sorted(glob.glob(os.path.join(os.path.expanduser(d), '**', pat), recursive=True)) if hit: return hit[0] return None def load_font(path, size, bold): try: if path: return ImageFont.truetype(path, size, index=1 if (bold and path.lower().endswith('.ttc')) else 0) except Exception: pass return ImageFont.load_default(size) # Pillow >= 10.1 class Line: """one title line: mask + its wide glow haze, at a fixed place on the frame""" def __init__(s, text, path, bold, cap, max_w, x, base, right=False, shear=0.0): size = 200.0 for _ in range(2): # size from the wanted capital-letter height, then fit the width f = load_font(path, int(size), bold); bb = f.getbbox('H', anchor='ls'); size *= cap / max(1, bb[3] - bb[1]) f = load_font(path, int(size), bold); tw = f.getlength(text) + size * shear if tw > max_w: f = load_font(path, int(size * max_w / tw), bold) P = 70; bb = f.getbbox(text, anchor='ls'); tw, up, dn = int(bb[2]) + 2, int(-bb[1]) + 2, int(bb[3]) + 2 im = Image.new('L', (tw + 2 * P + int(shear * (up + dn)), up + dn + 2 * P), 0) ImageDraw.Draw(im).text((P, P + up), text, font=f, fill=255, anchor='ls') if shear: im = im.transform(im.size, Image.AFFINE, (1, shear, -shear * (P + up), 0, 1, 0), Image.BICUBIC) # fake italic s.m = np.asarray(im, np.float32) / 255 ink = np.nonzero(s.m.max(0) > 0.1)[0]; x0, x1 = (ink[0], ink[-1]) if len(ink) else (P, P) s.x = int(x - x1) if right else int(x - x0); s.y = int(base - P - up) Q = 290; big = np.pad(s.m, Q); s.haze = np.clip(blur(big, 93, 8) * 5.2 + blur(big, 33, 8) * 1.3, 0, 1.15); s.hx, s.hy = s.x - Q, s.y - Q def clip(x0, y0, a): """part of array a that lands inside the frame when its top-left is at (x0, y0) -> (frame slice, cropped array)""" xa, ya, xb, yb = max(0, x0), max(0, y0), min(W, x0 + a.shape[1]), min(H, y0 + a.shape[0]) if xb <= xa or yb <= ya: return None, None return (slice(ya, yb), slice(xa, xb)), a[ya - y0:yb - y0, xa - x0:xb - x0] VID = ('.mp4', '.mov', '.m4v', '.webm', '.mkv', '.avi', '.gif') class Src: """a picture or a clip, cropped to the card. A clip starts when it is first shown, keeps playing and loops.""" def __init__(s, path, ax=0.5, ay=0.5): s.path, s.ax, s.ay, s.video, s.p, s.cap, s.last, s.stamp, s.t, s.n = path, ax, ay, path.lower().endswith(VID), None, None, None, -1, 0.0, 0 if not s.video: s.last = s.fit(ImageOps.exif_transpose(Image.open(path)).convert('RGB')) def fit(s, im): k = max(CW / im.width, CH / im.height); im = im.resize((math.ceil(im.width * k), math.ceil(im.height * k)), Image.LANCZOS) x, y = int((im.width - CW) * s.ax), int((im.height - CH) * s.ay) return np.asarray(im.crop((x, y, x + CW, y + CH)), np.float32) * HT def frame(s, i): if not s.video or s.stamp == i: return s.last s.stamp = i if FFMPEG: if s.p is None: vf = f'fps={FPS},scale={CW}:{CH}:force_original_aspect_ratio=increase:flags=lanczos,crop={CW}:{CH}:(iw-{CW})*{s.ax}:(ih-{CH})*{s.ay}' s.p = subprocess.Popen([FFMPEG, '-v', 'error', '-stream_loop', '-1', '-i', s.path, '-vf', vf, '-an', '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-'], stdout=subprocess.PIPE) b = s.p.stdout.read(CW * CH * 3) if len(b) == CW * CH * 3: s.last = np.frombuffer(b, np.uint8).reshape(CH, CW, 3).astype(np.float32) * HT else: # OpenCV reader import cv2 if s.cap is None: s.cap = cv2.VideoCapture(s.path); s.step = (s.cap.get(cv2.CAP_PROP_FPS) or 30) / FPS s.t += s.step while s.n < max(1, int(s.t)): ok, fr = s.cap.read(); s.n += 1 if not ok: s.cap.set(cv2.CAP_PROP_POS_FRAMES, 0); s.t = s.n = 0; continue s.raw = fr s.last = s.fit(Image.fromarray(s.raw[..., ::-1])) return s.last def make_sound(path, ev, dur): """soft bells and ticks made in code, C major pentatonic, no music. ev = [(seconds, kind, value)]""" SR = 44100; mix = np.zeros(int((dur + 1.5) * SR), np.float32); rng = np.random.default_rng(4) def put(a, t, g): i = max(0, int(t * SR)); a = a[:len(mix) - i]; mix[i:i + len(a)] += a * 10 ** (g / 20) def bell(st, length=0.5): f = 523.25 * 2 ** (st / 12); t = np.arange(int(length * SR)) / SR return ((np.sin(6.2832 * f * t) + .30 * np.sin(6.2832 * 2.76 * f * t) * np.exp(-t * 14) + .12 * np.sin(6.2832 * 5.4 * f * t) * np.exp(-t * 30)) * np.exp(-t * 4.5 / length) * np.minimum(1, t / .004)).astype(np.float32) def tick(): n = rng.standard_normal(700).astype(np.float32); return np.diff(n) * np.exp(-np.arange(699) / 90.0) def air(length, lo, hi): # soft breath of filtered noise that swells and fades n = int(length * SR); sp = np.fft.rfft(rng.standard_normal(n)); fr = np.fft.rfftfreq(n, 1 / SR) a = np.fft.irfft(sp * ((fr > lo) & (fr < hi)), n); return (a / np.abs(a).max() * np.sin(np.linspace(0, math.pi, n)) ** 2).astype(np.float32) for t, kind, v in ev: if kind == 'reveal': # blocks climb: rising arpeggio, notes spaced by reveal progress put(air(0.9, 500, 5000), t - 0.25, -24) for k, st in enumerate([0, 2, 4, 7, 9, 12, 14, 16, 19]): put(bell(st, .42), t + v[k], -19 + k * .25) elif kind == 'snap': # a title snaps sharp: small chord + tick for st, g in ((v, -12), (v + 7, -17), (v + 16, -20)): put(bell(st, .9), t, g) put(tick(), t, -14); put(air(0.3, 2000, 9000), t - 0.3, -27) elif kind == 'wipe_up': for k, st in enumerate([7, 9, 12, 14, 16, 19]): put(bell(st, .36), t + v * (.12 + .13 * k), -20) elif kind == 'ring_out': put(air(v, 800, 7000), t, -22) for k, st in enumerate([24, 21, 19, 16, 12]): put(bell(st, .26), t + v * (.1 + .15 * k), -21) elif kind == 'ring_in': put(air(v, 300, 3000), t, -22) for k, st in enumerate([12, 14, 16, 19, 21, 24]): put(bell(st, .2), t + v * (.08 + .13 * k), -23 + .6 * k) put(bell(12, .5), t + v, -13); put(tick(), t + v, -15) elif kind == 'flash': put(air(0.5, 1500, 9000), t - 0.35, -18); tt = np.arange(int(.8 * SR)) / SR put((np.sin(6.2832 * 58 * tt) * np.exp(-tt * 6)).astype(np.float32), t, -12) for st, g in ((12, -14), (16, -17), (19, -18), (24, -20)): put(bell(st, .7), t, g) if kind in KINDS: # a few quiet cube ticks along the transition for k in range(10): put(tick(), t + v * rng.uniform(.05, .95), -27) mix = np.tanh(mix / max(1e-6, np.abs(mix).max()) * 2.2) * 0.85; mix = mix[:int(dur * SR)] # gentle soft limit so the quiet bells are heard with wave.open(path, 'wb') as wv: wv.setnchannels(1); wv.setsampwidth(2); wv.setframerate(SR); wv.writeframes((mix * 32767).astype('<i2').tobytes()) def main(): global FFMPEG, HT ap = argparse.ArgumentParser(description='Pixel reveal video from pictures and/or clips') ap.add_argument('files', nargs='+'); ap.add_argument('-o', '--out', default='pixel_reveal.mp4') ap.add_argument('--title', action='append', default=[], help='"small line|BIG LINE|small line", one per file, in order') ap.add_argument('--center', action='append', default=[], help='"x,y" (0-1) of the main subject of each file: rings close / open there') ap.add_argument('--speed', type=float, default=1.0, help='1 = default; 0.8 = slower transitions and longer holds') ap.add_argument('--kinds', default=','.join(KINDS)); ap.add_argument('--end', default='flash', choices=['flash', 'hold']) ap.add_argument('--no-sound', action='store_true'); ap.add_argument('--stills', action='store_true') ap.add_argument('--font-bold'); ap.add_argument('--font-script'); ap.add_argument('--preset', default='medium') A = ap.parse_args() FFMPEG = find_ffmpeg(); HT = halftone(CW, CH, 5.6, 0.20)[..., None] cents = [tuple(float(v) for v in c.split(',')) for c in A.center] cen = lambda k: cents[k] if k < len(cents) else (0.5, 0.45) S = [Src(p, ay=min(0.5, cen(k)[1])) for k, p in enumerate(A.files)]; N = len(S) kinds = A.kinds.split(','); tn, step = TN / A.speed, STEP / A.speed TS = [T0 + step * k for k in range(N - 1)] # start tick of every transition last = TS[-1] + tn if TS else 90.0 FO = last - 61 + 10 * A.speed ** -1 # the flash starts about 11 ticks after the last transition ticks = 84 + FO if A.end == 'flash' else last + 45 nfr = int(round(ticks * FPS / 30)) # ---- block mattes noise1 = clump_noise(NB1, 3); ramp1 = (1 - (np.arange(NB1) + 0.5) / NB1)[:, None].astype(np.float32) ramp2 = (1 - (np.arange(NB2) + 0.5) / NB2)[:, None] * np.ones((1, NB2)); by, bx = np.mgrid[0:NB2, 0:NB2] dist = lambda c: np.hypot((bx + 0.5) / NB2 - c[0], ((by + 0.5) / NB2 - c[1]) * CH / CW) # in card widths NZ = [np.random.default_rng(14 + 7 * k).random((NB2, NB2)) for k in range(N - 1)] # scatter: flip order of the cubes SPK = [0.30 + 0.70 * np.random.default_rng(90 + k).random((NB2, NB2)) ** 1.5 for k in range(N - 1)] # shine strength per cube up1 = (np.arange(CH) * NB1 // CH, np.arange(CW) * NB1 // CW); up2 = (np.arange(CH) * NB2 // CH, np.arange(CW) * NB2 // CW) up = lambda m, ix: m[ix[0]][:, ix[1]] # blocks -> card pixels, hard edges rmask = rounded(CW, CH, 18); inner = np.zeros((CH, CW), np.float32); inner[6:-6, 6:-6] = rounded(CW - 12, CH - 12, 12) rim = np.clip(rmask - inner, 0, 1)[..., None]; rmask_im = Image.fromarray((rmask * 255).astype(np.uint8)) def tmask(k, f): """which cubes already show the NEXT picture in transition k at tick f""" u = (f - TS[k]) / tn; nz = NZ[k] - 0.5; kind = kinds[k % len(kinds)] if u <= 0: return np.zeros((NB2, NB2), bool) if u >= 1: return np.ones((NB2, NB2), bool) if kind == 'ring_in': # the new picture closes in from the corners onto the old subject return dist(cen(k)) + AMP2 * nz > RING(u * 21) * (1 + AMP2) - AMP2 / 2 if kind == 'ring_out': # the new picture opens from its own subject outwards return dist(cen(k + 1)) + AMP2 * nz < (1.12 + AMP2) * (1 - (1 - u) ** 1.8) - 0.06 - AMP2 / 2 e = u * u * (3 - 2 * u) # wipe_up: cubes climb from the bottom return ramp2 + AMP2 * nz < -AMP2 / 2 + e * (1 + AMP2) def card_at(f, i): k = max([j for j, s in enumerate(TS) if f >= s], default=-1) if k < 0: return S[0].frame(i) if f >= TS[k] + tn + 4.5: return S[k + 1].frame(i) m = tmask(k, f); older = sum(tmask(k, f - j * 0.5).astype(np.float32) for j in range(1, 9)) / 8 glow = m * (1 - older) ** 1.5 * SPK[k] * SHINE # each cube lights up as it flips, gone 4 ticks later card = np.where(up(m, up2)[..., None], S[k + 1].frame(i), S[k].frame(i)) if glow.max() > 0.01: sh = up(glow, up2).astype(np.float32)[..., None] lit = card * (1 + 1.9 * sh) + 14 * sh # the cube's OWN colour pushed bright ... lit *= np.minimum(1.0, 250.0 / np.maximum(lit.max(axis=2, keepdims=True), 1.0)) # ... hue kept, never white mean = lit.mean(axis=2, keepdims=True); card = np.clip(mean + (lit - mean) * (1 + 0.45 * sh), 0, 255) # a bit more saturated card += blur(card * sh, 10, 4) * 0.55 # soft glow in the same colour return card # ---- titles bold_p = A.font_bold or find_font(['HelveticaNeue.ttc', 'Arial Bold.ttf', 'arialbd.ttf', 'LiberationSans-Bold.ttf', 'DejaVuSans-Bold.ttf']) # script lines: a handwriting font if there is one, else an italic, else an upright font slanted in code (shear) scr = [(A.font_script, 0.0, 1.0)] if A.font_script else [] scr += [(find_font([p]), sh, k) for p, sh, k in (('Caveat*.ttf', .12, 1), ('Yellowtail*.ttf', 0, 1), ('Brush Script.ttf', 0, 1), ('DejaVuSerif-Italic.ttf', .08, .7), ('LiberationSerif-Italic.ttf', .08, .7), ('Georgia Italic.ttf', .08, .7), ('georgiai.ttf', .08, .7), ('DejaVuSans-Oblique.ttf', .08, .7), ('DejaVuSerif.ttf', .26, .7), ('DejaVuSans.ttf', .26, .7))] script_p, shear, sk = next(((p, sh, k) for p, sh, k in scr if p), (None, 0.26, 0.7)) def auto_title(k): w = re.sub(r'[\W_\d]+', ' ', os.path.splitext(os.path.basename(A.files[k]))[0]).title().split() return ['No. %d' % (k + 1), ' '.join(w[:2]) or 'Picture', 'of %d' % N] TL = [] for k in range(N): t = (A.title[k].split('|') + ['', '', ''])[:3] if k < len(A.title) else auto_title(k) TL.append([Line(t[1].strip() or ' ', bold_p, True, 104, 843, 118, 1480), # big bold line, fitted to the card width Line(t[0].strip() or ' ', script_p, False, 100 * sk, 600, 150, 1326, shear=shear), # small script line over the card's bottom-left Line(t[2].strip() or ' ', script_p, False, 104 * sk, 560, 966, 1645, right=True, shear=shear)]) # small script line, right, under it t_start = lambda k: 12.0 if k == 0 else TS[k - 1] + 0.45 * tn # title k starts at 45 % of its transition PARTS = ((1.0, 0.0, 1.0, 1.0, 1.0), (2.0, 0.0, 0.34, 0.25, 0.0), (8 / 6.0, 6.0, 0.5, 1.3, 1.0)) # per line: speed, delay, rise, haze, rim tex = (1 - 0.20 * np.clip(np.hypot((np.arange(W)[None] - W / 2) / (W * .75), (np.arange(H)[:, None] - H / 2) / (H * .75)) ** 2, 0, 1)) * halftone(W, H, 5.6, 0.15) tex = tex.astype(np.float32); tex2 = tex ** 2; rng = np.random.default_rng(5) grain = [(rng.standard_normal((H, W)) * GRAIN * 255 * (1 if FFMPEG else 0.3)).astype(np.float32) for _ in range(6)] def cover(n, pos, lw, a): # 1-D coverage of anti-aliased grid lines i = np.arange(n, dtype=np.float32)[:, None]; pos = pos[(pos > -4) & (pos < n + 4)][None] return np.clip(np.minimum(i + 1, pos + lw / 2) - np.maximum(i, pos - lw / 2), 0, 1).max(axis=1) * a if pos.size else np.zeros(n, np.float32) def render(i): f = i * 30.0 / FPS; g = f - FO if A.end == 'flash' else 0.0 lift = F_LIFT(g); fl = min(1.0, lift / 120.0); fl2 = min(1.0, max(0.0, (lift - 60.0) / 160.0)) show = A.end != 'flash' or g < 68 # ---- stage + grid: slides up, then the camera slowly pulls back and never fully stops s = GRID_S(f) * (1 - 0.03 * (1 - math.exp(-max(0.0, f - 62) / 220))); dy = GRID_DY(f); tx, ty = 1.0, 1.0 for pitch, a, lw in ((29.36, 0.07 * max(0.0, 1 - 2 * fl), 1.5), (234.9, min(1.0, 0.8 * (1 + 2.5 * fl)), 3.0)): ks = np.arange(-90, 91) * pitch tx = tx * (1 - cover(W, 540 + (606 + ks - 540) * s, lw, a)); ty = ty * (1 - cover(H, 885 + (54 + dy + ks - 885) * s, lw, a)) Tm = np.outer(ty, tx).astype(np.float32); img = np.empty((H, W, 3), np.float32) for c in range(3): lc = GRIDC[c] * (1 - fl) + 255 * fl; img[..., c] = ((STAGE[c] - lc) * Tm + lc) * tex if lift > 0.5: img = img * (1 + 0.6 * fl) + min(lift, 175.0) # ---- card if show and f >= 6: card = card_at(f, i); rq = RIM(f) + 0.5 * fl card = card * (1 - rim * rq) + np.array([165, 205, 255], np.float32) * rim * rq # thin light-blue glass rim if fl > 0.02: card = card * (1 + 1.35 * fl) + np.clip(card - 120, 0, None) * (1.6 * fl) p = REVEAL(f); kk = min(1.0, p / 0.06) alpha = rmask if p >= 1 else up(ramp1 + AMP1 * (noise1 - 0.5) < p + AMP1 / 2 * (2 * kk - 1), up1) * rmask # the first block reveal rgba = np.dstack([np.clip(card, 0, 255) * alpha[..., None], alpha * 255]).astype(np.uint8) sc = CARD_S(f) * (1 - 0.06 * (1 - math.exp(-max(0.0, f - 62) / 220))) # card shrinks more than the grid = parallax ox, oy = W / 2 - CW * sc / 2, CARD_CY(f) + CARD_DY(f) - CH * sc / 2; gl = CARD_GLOW(f); pad = 200 if gl > 0.01 else 12 x0, y0 = math.floor(ox) - pad, math.floor(oy) - pad; size = (math.ceil(CW * sc) + 2 * pad + 2, math.ceil(CH * sc) + 2 * pad + 2) warp = lambda im, ex, ey: np.asarray(im.transform(size, Image.AFFINE, (1 / sc, 0, (x0 - ox - ex) / sc, 0, 1 / sc, (y0 - oy - ey) / sc), Image.BILINEAR), np.float32) sl, cl = clip(x0, y0, warp(Image.fromarray(rgba), 0, 0)) if sl is not None: gq = min(1.0, max(0.0, (f - 26) / 6.0)) if gq > 0: # faint "glass echo" of the card, shifted up-right _, e = clip(x0, y0, warp(rmask_im, 7 * sc, -7 * sc)); e = e[..., None] * (0.20 / 255 * gq) img[sl] = img[sl] * (1 - e) + np.array([120, 160, 215], np.float32) * e al = cl[..., 3:] / 255 if gl > 0.01: # warm bloom around the first strip of blocks img[sl] += blur(cl[..., :3], 34, 8) * np.array([1.15, 1.10, 0.74], np.float32) * (1.05 * gl) + blur(al[..., 0], 60, 8)[..., None] * np.array([58, 54, 28], np.float32) * gl img[sl] = img[sl] * (1 - al) + cl[..., :3] # ---- titles: one set per picture; the old one blurs away when the next transition starts for k, lines in enumerate(TL if show else []): r0 = f - t_start(k); o = min(1.0, max(0.0, (f - (TS[k] + 3)) / 7.0)) if k < N - 1 else 0.0 if r0 < -1 or o >= 1: continue for L, (spd, dly, kdy, khz, krm) in zip(lines, PARTS): r = (r0 - dly) * spd; op = L_OP(r) * (1 - o) if op <= 0.005: continue dyp = int(round(L_DY(r) * kdy)); bl = L_BLUR(r) + 13.5 * o * (1.0 if khz >= 1 else 0.55) col = (L_COL(r) if khz >= 1 else np.array(CREAM, np.float32)) * (1 - fl) + np.array([255, 255, 236], np.float32) * fl hz = (L_HAZE(r) * khz) * (1 - o) + 0.35 * fl + 1.5 * fl2 sl, hm = clip(L.hx, L.hy + dyp, L.haze) if hz > 0.01 and sl is not None: img[sl] += (hm * tex2[sl])[..., None] * np.array(HAZEC, np.float32) * hz # wide soft haze sl, m = clip(L.x, L.y + dyp, L.m) if sl is None: continue body = blur(m, bl, 2) if bl > 0.4 else m; rv = L_RIM(r) * krm * (1 - o) + 0.8 * fl2 if rv > 0.01: # pale rim hugging the letter edges = wider blur minus the fill img[sl] += np.clip(blur(m, bl * 0.5 + 6.75, 2) * 1.7 - body * 0.9, 0, 1)[..., None] * np.array(RIMC, np.float32) * (0.98 * rv) ab = np.clip(body * op * (1.3 if bl > 0.4 else 1.0), 0, 1)[..., None] img[sl] = img[sl] * (1 - ab) + col * ab if lift > 175: img += (lift - 175.0) * 3.2 img += grain[i % 6][::(1 if i % 2 else -1), ::(1 if (i // 2) % 2 else -1), None] return np.clip(img, 0, 255).astype(np.uint8) if A.stills: # 3 check frames: title glow, first transition, last transition picks = [18.0, (TS[0] + 0.55 * tn) if TS else 30.0, (TS[-1] + 0.5 * tn) if TS else 60.0] for n_, f in enumerate(picks): Image.fromarray(render(int(f * FPS / 30))).save('still_%d.jpg' % (n_ + 1), quality=92) print('wrote still_1.jpg still_2.jpg still_3.jpg (look at them before the full render)'); return wav = None if not A.no_sound and FFMPEG: rp = np.array([.02, .136, .252, .369, .485, .601, .717, .834, .95]); rv_ = [REVEAL(x) for x in np.arange(6.5, 31, .25)] ev = [(7 / 30, 'reveal', np.interp(rp, rv_, np.arange(6.5, 31, .25)) / 30 - 7 / 30)] ev += [((t_start(k) + 8) / 30, 'snap', [0, 4, 7, 9, 12][k % 5]) for k in range(N)] ev += [(TS[k] / 30, kinds[k % len(kinds)], tn / 30) for k in range(N - 1)] if A.end == 'flash': ev.append(((66 + FO) / 30, 'flash', 0)) wav = os.path.splitext(A.out)[0] + '_sound.wav'; make_sound(wav, ev, nfr / FPS) t0 = time.time() if FFMPEG: cmd = [FFMPEG, '-v', 'error', '-y', '-f', 'rawvideo', '-pix_fmt', 'rgb24', '-s', f'{W}x{H}', '-r', str(FPS), '-i', '-'] + (['-i', wav] if wav else []) cmd += ['-c:v', 'libx264', '-preset', A.preset, '-crf', '20', '-maxrate', '16M', '-bufsize', '32M', '-pix_fmt', 'yuv420p'] + (['-c:a', 'aac', '-b:a', '192k'] if wav else []) pe = subprocess.Popen(cmd + ['-movflags', '+faststart', A.out], stdin=subprocess.PIPE); write = pe.stdin.write else: import cv2 # last resort: no sound, codec mp4v (not H.264), big file, so less grain vw = cv2.VideoWriter(A.out, cv2.VideoWriter_fourcc(*'mp4v'), FPS, (W, H)); write = lambda b: vw.write(np.frombuffer(b, np.uint8).reshape(H, W, 3)[..., ::-1]) for i in range(nfr): write(render(i).tobytes()) if i % 30 == 0: print(f'frame {i}/{nfr} {time.time() - t0:.0f}s', flush=True) if FFMPEG: pe.stdin.close(); pe.wait() else: vw.release() for s in S: if s.p: s.p.kill() print(f'DONE {A.out} {nfr} frames = {nfr / FPS:.1f}s video, rendered in {time.time() - t0:.0f}s') if __name__ == '__main__': main() ```
  4. Wait a few minutes

    You get a 1080x1920 mp4 with the pixel reveal effect and soft sounds.

  5. Ask for changes

    Ask for new titles, a new order, or a slower or faster video.

free newsletter

Get new guides first

Daily AI news and the newest copy-paste guides in your inbox. No spam.

Free. Unsubscribe anytime. Form not showing?