# Render Pipeline: replication prompt

Paste this into Claude Code, Cursor, Replit, Lovable or v0.

```text
Write a Node 18 ESM script render.mjs that turns HTML demos into MP4 and GIF using Playwright and ffmpeg. Mode "frames": open the page with ?record=1, wait for window.renderAt and window.TRAILER {length, fps}, loop over every frame calling renderAt(i/fps) and reading the canvas as PNG via toDataURL, stream the PNGs into ffmpeg (image2pipe, libx264, yuv420p, crf 18), then if window.exportWavBase64 exists, write the WAV and mux it as AAC. Mode "live": open the page in a Playwright context with recordVideo, measure page load time, wait window.DEMO_DURATION seconds, optionally open a composer page and call exportWavBase64({style, length, drop, cues}) for a soundtrack, then trim the load time with ffmpeg -ss, encode H.264 and mux audio. Both modes make a GIF with two-pass palettegen/paletteuse at 12 fps and 720px wide. Flags: --out, --query, --size, --fps, --duration, --music, --style, --cues, --drop, --gif-only, --gif-width, --gif-fps. Clean up the temp folder.
```

## Key code

```bash
# frame-perfect trailer with music
node render.mjs frames ../20-launch-trailer-kit/index.html --out trailer
# record a DOM demo tour and score it
node render.mjs live ../16-scripted-product-demo/index.html --query "?record=1" \
  --music ../18-cue-composer/index.html --style house --cues "1,3.5,6.5,10,14,18" --drop 3.5 --out demo
# one machine as a looping GIF
node render.mjs live ../17-ai-explainer-machines/index.html --query "?machine=3&autoplay=1" \
  --size 1100x760 --duration 5.7 --gif-only --out temperature
```
