Communitygithub.com

remotion-pv-video

Use when making Remotion promo videos (PV/宣传片/成片).

remotion-pv-video 是什么?

remotion-pv-video is a Claude Code agent skill that use when making Remotion promo videos (PV/宣传片/成片).

兼容平台~Claude Code~Codex CLI~Cursor
npx skills add https://github.com/Slime00V/hermes-skills/tree/HEAD/creative/remotion-pv-video

在你喜欢的 AI 中提问

打开一个已预加载此 Agent Skill 的新对话。

文档

Remotion PV Production (React-rendered Videos)

The overarching guidelines (engine routing / launch video workflow / QA gate / delivery standards) are found in pv-production. This skill covers deep dives into the Remotion engine.

When to Use

Use this when the user wants to create a promotional video / PV / final cut / React-rendered video, or wishes to preview, modify, or re-render the D:/AI/Hermes GD/remotion-pv project.

Reference implementation: D:/AI/Hermes GD/remotion-pv — 15s / 450f / 1920×1080@30fps, Chinese+neon style (particles, glassmorphism, glow, synthwave); final artifact out/pv.mp4.

Workflow

  1. Plain JS (.jsx) is fine: Write components as .jsx files (no TypeScript syntax, no type annotations). Remotion's bundler can handle them directly; just add "allowJs": true to tsconfig.json to prevent editor/TS parsing errors (rendering itself never performs type checking). Verified: src/loopbg/FireworksBg.jsx works normally for stills/render.
  2. Manual scaffolding (faster than create-video): package.json with [email protected] + @remotion/cli + react@19 + typescript; src/index.ts with registerRoot; remotion.config.ts (Config.setVideoImageFormat('jpeg')); tsconfig.json with jsx: react-jsx. Running npm install on this machine takes ~8-10 minutes (the compositor binary is large).
  3. Assets —
    • NASA Image Library (public domain): Search https://images-api.nasa.gov/search?q=<term>&media_type=image, then fetch https://images-assets.nasa.gov/image/<id>/<id>~large.jpg. Not all assets have ~large—check <id>/collection.json first (variants: ~orig, ~large, ~medium). A 403 error means the variant is missing, not blocked.
    • Google Fonts: Use curl -A "Mozilla/5.0 Chrome/120" "https://fonts.googleapis.com/css2?family=...&text=<urlencoded CJK>" to obtain subset URLs. The text= subset returns TTF files (not woff2) and downloads may occasionally truncate—validate before use.
  4. Music: Use a pure-Python stdlib synthesizer (see scripts/gen_music.py in the project). Align beats to integer frames (120BPM @30fps = 15 frames/beat; 15s = 30 beats). Verify with per-second RMS—intro < drop > outro.
  5. Scenes: One component per scene; cut points via <Sequence from= durationInFrames=> with ~6-frame overlaps; a white flash at the start of the incoming scene hides the cut. All motion uses useCurrentFrame().
  6. QA loop: Run npx remotion still src/index.ts Main out/f120.png --frame=120 → inspect the PNG (vision_analyze) → fix → repeat → then npx remotion render src/index.ts Main out/pv.mp4 --crf=17 (~2-3 minutes for 450 frames). Final check from the MP4 itself: ffmpeg -ss 10.55 -i out/pv.mp4 -frames:v 1 out/x.png.

Camera System (character PV, verified in src/sherry/Camera.tsx)

  • Keyframed virtual camera: camAt(frame, keys[], shakes[], {handheld})—keys carry {f, x, y, z, rot, blur} + per-key easing; carries values forward, adds subtle handheld drift plus decaying impact shakes.
  • Parallax layers: <Layer cam depth> where depth 1 = character plane, 0.15-0.6 = backdrops; scale/translate/rotate multiply by depth, and cam.blur defocuses only the far layers (focus rack).
  • Focus formula: To center a world point on screen, use cam.y = worldY - 540 (and cam.x = worldX - 960) at the current zoom; layer scale pivots on the frame center, so edge-anchored UI gets pushed out of frame as z grows—position with the maximum scale in mind.
  • Impact = shake event + white flash + floor rings; whip cut = speed lines + brief blur/scaleX smear on the character layer.
  • 60 fps for camera-move shots (600 frames ≈ 2-3 min render).

Character Art Sourcing (fan PV)

  • moegirl archive serves official transparent character PNGs: https://storage.moegirl.org.cn/moegirl/commons/<x>/<xx>/<urlencoded-name>.png—grab the file list by curling the article HTML and grepping image URLs.
  • Spoiler/blood caution: Story CGs may contain deaths or spoilers—always eyeball every downloaded asset (vision check) before using it in the video.
  • Big name text behind the character gets its middle glyph blocked by the body—place it in the front/lower third instead.

Transparent Video (alpha) — Verified Recipe

  • WebM VP9: --codec=vp9 --pixel-format=yuva420p --image-format=png --crf=20
  • ProRes 4444 MOV (editing software friendly): --codec=prores --prores-profile=4444 --pixel-format=yuva444p10le --image-format=png
  • --image-format=png is mandatory or the render throws "Pixel format was set to 'yuva420p' but the image format is not PNG" (the remotion.config.ts default of jpeg breaks it).
  • Component side: No background color anywhere (no AbsoluteFill background fill, no Atmosphere/film layers); use backgroundColor: 'transparent'.
  • Verify alpha on the ENCODED file: ffprobe reports pix_fmt=yuv420p for a VP9-alpha webm (alpha lives in the container, TAG:alpha_mode=1) — decode explicitly: ffmpeg -c:v libvpx-vp9 -i x.webm -frames:v 1 f.png, then check PNG alpha extrema with PIL. The default decoder can silently drop alpha and make the file look opaque.
  • Transparent GIF from the MOV (not the webm): -vf "fps=<fps>,scale=<w>:<h>:flags=neighbor,split[s0][s1];[s0]palettegen=reserve_transparent=1:max_colors=64[p];[s1][p]paletteuse=alpha_threshold=128:dither=none" -loop 0.

Music-Driven PV (Beat Sync) — Verified on a 115s song

  • Analyze the track before designing (script pattern in work/analyze_music.py of the remotion-pv project): decode with ffmpeg -i in.mp3 -ac 1 -ar 22050 out.wav, then compute per-10ms RMS + spectral-flux onsets; BPM via autocorrelation + comb refinement (fast tracks may land at double-time—check both); beat phase via max mean flux on the grid; section boundaries via flux contrast per 1s. Output music_map.json and build a beat→frame helper (bf(beat) = round(beat * 60/BPM * fps)) so every cut/slam lands on a grid line.
  • Beat-snap the section table before writing scenes (measured shape: cold open → title → N character reveals on equal block grids → wheel → seal → flurry → mid acts → climax → percussion title → outro fade).
  • Monochrome-vector beast sigils: PhyloPic API (api.phylopic.org/nodes?build=<n>&filter_name=<common name> → _links.items[0], then images?filter_node=<uuid>) gives CC0 silhouette SVGs (black fills) — recolor any way with CSS mask-image: url(svg) + gradient background (no SVG editing needed). The API needs build=558 (root 307-redirects to it); raster files need exact sizes from _links.rasterFiles; license/contributor info lives on /images/<uuid> _links.
  • Flags: https://flagcdn.com/w1280/<cc>.png works where upload.wikimedia.org is blocked; dim plain <img> flags with brightness(.6) saturate(.78) + multiply gradients or they look flat next to dark-fantasy grading.
  • Edge-safety: For a 5-in-a-row arc, keep outer items' bounding boxes ≥64px from frame edges AND above bottom letterbox bars (~86px @1080p); check a still at the fullest layout frame before the full render.
  • BeatPump: Wrap the entire scene stack in a component that applies scale(1 + 0.006*e1 + 0.011*e2 + 0.007*e4) where eN = 1-on-the-beat decaying saw over N-beat periods (beatEnv(f, beats*60/BPM*fps)), plus a low-opacity radial gold flash on bar lines. One wrapper makes every scene feel beat-locked; combine with per-scene reveals on beat frames for the fast beat-matching feel—no re-cutting needed.
  • AI-generated sigils when no public silhouette exists (e.g., a Chinese dragon): Local ComfyUI/SD3.5 with a "pure black silhouette on pure white background, no shading, no ink splatter" prompt → mask pipeline: threshold L<0.62 → scipy.ndimage.binary_closing → keep connected components ≥6% of the largest → gaussian feather (σ1.2, re-contrast alpha) → crop to bbox → RGBA PNG → feeds the same mask-image sigil component as SVG.
  • 素材去重(用户说"素材不够/不要反复使用"时): (1) generate alt poses of the same subjects (second-form sigils used only in the climax) + scene-specific atmosphere plates (hall/storm/embers/ink-texture) through the same ComfyUI pipeline; (2) remap every asset to exactly ONE hero scene (pose1 = parade only, pose2 = climax only, flags = one scene, rocket = one scene; wheel/medallions become procedural orbs/rings); (3) where an asset must reappear, differentiate the treatment (gold vs silver silhouette, different size/context) — and count pure textures (one ink plate rotated/scaled per block) as textures, not 素材.

Seamless Loops (verified)

  • Make every motion periodic over N frames: scroll/rotation distances = integer tiles per loop, sin(2π·k·t) with integer k, blink & mouth cycles that divide N. Never fade a joint.
  • Prove it numerically: Extract frame N-1 and frame 0 from the rendered file, ffmpeg -i a.png -i b.png -lavfi psnr -f null -; seam PSNR within ~2-3 dB of adjacent-frame PSNR = seamless.
  • Pixel-art characters: Draw per-pixel on a 64×64 offscreen canvas (fillRect, 3-4 tone palette, 1px dark outline, deterministic hash() dithering), then drawImage at ×8 with imageSmoothingEnabled=false + CSS image-rendering: pixelated. Squash/stretch = modulate the ellipse semi-axes; talking mouth = cycle through (w,h) rect list every ~5 frames; blink = 2-frame eye-height table.
  • CJK text/fonts: Fetch a Google Fonts text= subset for exactly the glyphs used, inline as base64, register a dedicated family (loadData('SlimeSans', B64, '900')).

Pitfalls (all hit for real)

  • Flash/decay components must gate t < 0. interpolate + clamp returns the FIRST value (peak) for inputs before the range—a start: 68 flash renders full-peak white from frame 0 over the whole shot. Use const t = f - start; if (t < 0 || t > out) return null;.

  • interpolate default extrapolation is extend. An opacity ramp [0,9]→[1,0] keeps going past frame 9; with an easing function it yields opacity ≫1 → the whole scene renders pure white. ALWAYS pass extrapolateLeft: 'clamp', extrapolateRight: 'clamp' on flashes/opacity/anything that must stay in range.

  • Font loading: @remotion/fonts loadFont assumes woff2; a TTF gives "Invalid font data" and its internal cancelRender() kills the entire render (a .catch() cannot save it). Use manual new FontFace(family, url) with NO format hint + try/catch + delayRender()/continueRender() — see project src/fonts.ts.

  • Truncated font downloads: A 2KB "CJK subset" was actually a cut-off transfer (glyf table out of file range) → Chrome FontFace throws NetworkError. Validate sfnt table ranges; retry downloads (Google sometimes drops the connection mid-transfer).

  • Inline CJK subsets as base64 data URIs — scoped to the ~20 glyphs actually used, ~10KB each, immune to static-server issues. Generate src/fontData.ts with a small Python base64 script.

  • Ghost/echo layers need the same timing gate as the main element — static-opacity chromatic copies of a word appear long before the word "slams in", ruining the reveal.

  • Letterbox & safe-area collisions: Scenes render BEHIND the 86px black letterbox bars (drawn last over the stack). An element at bottom: 86 inside an inset: -80 camera wrapper lands exactly inside the bottom bar and becomes invisible—keep ≥ ~200px clearance; and check long letter-spaced EN strings (fontSize × char count) fit 1920 before rendering. Corner stamps can collide with multi-line text (a red 印章 overlapped the tail of "VETO POWER")—verify every text element + stamp with a still at its exact reveal frame.

  • Canvas particles: Pre-render one sprite per color (createRadialGradient on a 64px offscreen canvas), then drawImage per particle with globalAlpha + globalCompositeOperation='lighter'; use seeded mulberry32 for determinism; draw inside useEffect keyed on frame.

  • Windows paths: Work in git-bash with cd "/d/AI/..." then run npx remotion ...; native node tools inherit the bash cwd correctly.

相关技能