Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
feat: switch to mp4, render script overhaul (webm → mp4)
nirholas420db7be7a3b
diff --git a/scripts/render-launch-video.mjs b/scripts/render-launch-video.mjsindex ff3da829d..75afac985 100644--- a/scripts/render-launch-video.mjs+++ b/scripts/render-launch-video.mjs@@ -1,13 +1,16 @@#!/usr/bin/env node// Render launch-week.html as a smooth-scroll video.+// Uses a deterministic frame-by-frame approach (decoupled from real time) so+// the output is perfectly smooth regardless of how slow the screenshots are.//// Output: scroll.mp4 at the repo root.//// Prereqs: dev server running at http://localhost:3000 (`npm run dev`)// Usage: node scripts/render-launch-video.mjs-// node scripts/render-launch-video.mjs --duration 120 # 120-second scroll+// node scripts/render-launch-video.mjs --duration 120 --fps 30// node scripts/render-launch-video.mjs --width 1920 --height 1080+import fs from 'node:fs/promises';import path from 'node:path';import { spawn } from 'node:child_process';import puppeteer from 'puppeteer';@@ -21,21 +24,37 @@ const args = Object.fromEntries();const PAGE_URL = args.url || 'http://localhost:3000/launch-week.html';-const SCROLL_SECONDS = parseFloat(args.duration || '90');+const DURATION = parseFloat(args.duration || '90');+const FPS = parseInt(args.fps || '24', 10);const WIDTH = parseInt(args.width || '1280', 10);const HEIGHT = parseInt(args.height || '800', 10);-const SCROLL_WEBM = path.join(ROOT, 'scroll.webm');-const SCROLL_MP4 = path.join(ROOT, 'scroll.mp4');+const DPR = parseFloat(args.dpr || '1');+const HEAD_PAD = parseFloat(args['head-pad'] || '1.5');+const TAIL_PAD = parseFloat(args['tail-pad'] || '2');+const FRAMES_DIR = path.join(ROOT, '.video-frames');+const SCROLL_MP4 = path.join(ROOT, 'scroll.mp4');const EMBED_WAIT_MS = 12_000;-const HEAD_PAD_MS = 1_500;-const TAIL_PAD_MS = 2_000;++async function rmrf(p) {+ await fs.rm(p, { recursive: true, force: true });+}async function main() {- console.log(`Page: ${PAGE_URL}`);- console.log(`Viewport: ${WIDTH}x${HEIGHT} @ 2x DPR`);- console.log(`Scroll: ${SCROLL_SECONDS}s (+ ${HEAD_PAD_MS / 1000}s head pad, ${TAIL_PAD_MS / 1000}s tail pad)`);+ console.log(`Page: ${PAGE_URL}`);+ console.log(`Viewport: ${WIDTH}x${HEIGHT} @ 2x DPR`);+ console.log(`Duration: ${DURATION}s scroll · ${HEAD_PAD}s head · ${TAIL_PAD}s tail`);+ console.log(`Framerate: ${FPS}fps`);++ const totalFrames = Math.round((HEAD_PAD + DURATION + TAIL_PAD) * FPS);+ const headFrames = Math.round(HEAD_PAD * FPS);+ const tailFrames = Math.round(TAIL_PAD * FPS);+ const scrollFrames = totalFrames - headFrames - tailFrames;+ console.log(`Frames: ${totalFrames} total (${scrollFrames} scrolling, ${headFrames} head pad, ${tailFrames} tail pad)`);- console.log('Launching headless browser...');+ await rmrf(FRAMES_DIR);+ await fs.mkdir(FRAMES_DIR, { recursive: true });++ console.log('\nLaunching headless browser...');const browser = await puppeteer.launch({headless: 'new',args: [@@ -44,9 +63,9 @@ async function main() {'--disable-dev-shm-usage',`--window-size=${WIDTH},${HEIGHT}`,'--font-render-hinting=none',- '--force-device-scale-factor=2',+ `--force-device-scale-factor=${DPR}`,],- defaultViewport: { width: WIDTH, height: HEIGHT, deviceScaleFactor: 2 },+ defaultViewport: { width: WIDTH, height: HEIGHT, deviceScaleFactor: DPR },});const page = await browser.newPage();page.on('console', (m) => {@@ -59,45 +78,53 @@ async function main() {console.log(`Waiting ${EMBED_WAIT_MS / 1000}s for tweet embeds to render...`);await new Promise((r) => setTimeout(r, EMBED_WAIT_MS));+ // Compute scroll bounds+ const distance = await page.evaluate(() =>+ Math.max(0, document.documentElement.scrollHeight - window.innerHeight)+ );+ console.log(`Page height: scrollable distance ${distance}px`);+await page.evaluate(() => window.scrollTo(0, 0));await new Promise((r) => setTimeout(r, 500));- console.log('Starting screencast...');- const recorder = await page.screencast({- path: SCROLL_WEBM,- crop: { x: 0, y: 0, width: WIDTH, height: HEIGHT },- speed: 1,- });-- await new Promise((r) => setTimeout(r, HEAD_PAD_MS));-- console.log('Animating scroll...');- await page.evaluate((durationMs) => {- return new Promise((resolve) => {- const distance = document.documentElement.scrollHeight - window.innerHeight;- const start = performance.now();- function step(now) {- const t = Math.min(1, (now - start) / durationMs);- const eased = 0.5 - 0.5 * Math.cos(Math.PI * t);- window.scrollTo(0, eased * distance);- if (t < 1) requestAnimationFrame(step);- else resolve();- }- requestAnimationFrame(step);+ console.log('\nCapturing frames...');+ const frameStart = Date.now();+ const pad = (n, w) => String(n).padStart(w, '0');++ for (let i = 0; i < totalFrames; i++) {+ let scrollY;+ if (i < headFrames) {+ scrollY = 0;+ } else if (i < headFrames + scrollFrames) {+ const t = (i - headFrames) / Math.max(1, scrollFrames - 1);+ const eased = 0.5 - 0.5 * Math.cos(Math.PI * t); // smooth in/out+ scrollY = eased * distance;+ } else {+ scrollY = distance;+ }+ await page.evaluate((y) => window.scrollTo(0, y), scrollY);+ await page.screenshot({+ path: path.join(FRAMES_DIR, `frame-${pad(i, 5)}.jpg`),+ type: 'jpeg',+ quality: 92,+ captureBeyondViewport: false,});- }, SCROLL_SECONDS * 1000);-- await new Promise((r) => setTimeout(r, TAIL_PAD_MS));-- console.log('Stopping screencast...');- await recorder.stop();+ if (i % 30 === 0 || i === totalFrames - 1) {+ const pct = ((i + 1) / totalFrames * 100).toFixed(1);+ const elapsed = ((Date.now() - frameStart) / 1000).toFixed(1);+ process.stdout.write(`\r frame ${i + 1}/${totalFrames} (${pct}%) · ${elapsed}s elapsed `);+ }+ }+ process.stdout.write('\n');await browser.close();+ console.log(`Captured ${totalFrames} frames in ${((Date.now() - frameStart) / 1000).toFixed(1)}s`);- console.log('Transcoding webm → mp4...');+ console.log('\nEncoding mp4...');await new Promise((resolve, reject) => {const ffArgs = ['-y',- '-i', SCROLL_WEBM,+ '-framerate', String(FPS),+ '-i', path.join(FRAMES_DIR, 'frame-%05d.jpg'),'-c:v', 'libx264','-preset', 'medium','-crf', '18',@@ -109,11 +136,15 @@ async function main() {p.on('exit', (code) => (code === 0 ? resolve() : reject(new Error(`ffmpeg exit ${code}`))));});- console.log(`\n✓ Wrote ${path.relative(ROOT, SCROLL_MP4)}`);+ // Cleanup PNGs but keep the mp4+ await rmrf(FRAMES_DIR);++ const stat = await fs.stat(SCROLL_MP4);+ console.log(`\n✓ Wrote ${path.relative(ROOT, SCROLL_MP4)} (${(stat.size / 1024 / 1024).toFixed(1)} MB · ${WIDTH * 2}x${HEIGHT * 2})`);console.log(' Drop this into your editor and overlay the ElevenLabs voice.\n');}main().catch((e) => {- console.error('FAILED:', e);+ console.error('\nFAILED:', e);process.exit(1);});diff --git a/scroll.mp4 b/scroll.mp4new file mode 100644index 000000000..9ee5a6603Binary files /dev/null and b/scroll.mp4 differdiff --git a/scroll.webm b/scroll.webmdeleted file mode 100644index 850740a44..000000000Binary files a/scroll.webm and /dev/null differ