Prompt pronto: monte um estúdio de motion design com Claude Code e gere seu primeiro vídeo

Vídeos de motion design não precisam de After Effects. Neste artigo está um prompt em inglês que você copia, cola no Claude Code e recebe de volta um estúdio de animação inteiro funcionando no seu computador, mais o vídeo abaixo renderizado do zero: 16 segundos, vertical, com trilha e efeitos sonoros gerados por código.
Como funciona
Um modelo de linguagem não gera arquivos de vídeo, mas escreve programas muito bem. O truque é pedir um programa em que cada quadro é uma função do tempo: uma página HTML com window.seek(t), que desenha exatamente o instante t. Um Chrome invisível chama essa função 30 vezes por segundo, tira um print de cada quadro e o ffmpeg junta tudo em MP4. Como nada depende de relógio ou sorteio, o vídeo sai igual em toda renderização, e mudar algo é editar uma linha e renderizar de novo.
O som segue a mesma ideia: batida, baixo, cliques e “whooshes” são sintetizados em código, na mesma linha do tempo da imagem, e normalizados para o volume padrão das redes (-14 LUFS).
O que você precisa
- Claude Code instalado, de preferência com esforço alto (
/model→ Opus, esforço high ou xhigh). - Node.js 22 ou mais novo e ffmpeg. Se faltar algum, o próprio prompt instrui o Claude a instalar.
- Google Chrome ou Microsoft Edge, que você provavelmente já tem. O estúdio usa o navegador instalado e não baixa outro.
- Menos de 1 GB livre. O estúdio em si ocupa cerca de 20 MB.
Passo a passo
- Crie uma pasta vazia e abra o Claude Code dentro dela.
- Clique em Copiar prompt abaixo e cole tudo na conversa.
- Espere. O Claude confere os requisitos, cria os arquivos, renderiza (de 40 segundos a 2 minutos), olha os próprios quadros para conferir o resultado e devolve o caminho do
final.mp4.
You are Claude Code. Set up a code-only motion design studio on this machine and render its first test video. Work autonomously from start to finish. Only stop to ask me if something is truly impossible (for example, no permission to install software).
# GOAL
Create a folder named motion-studio that turns an HTML page exposing window.seek(t) into an MP4:
- headless Chrome paints every frame (a pure function of time, so every render is identical),
- ffmpeg encodes the frames,
- the sound (beat, bass, clicks, pops, whooshes) is synthesized in code on the same timeline.
The first film is a 16-second vertical video (1080x1920) in Portuguese called "MONTE SEU STUDIO DE MOTION", a tutorial in 4 steps: install, rules, seek(t), render.
# STEP 1 - Check the requirements (install only what is missing; keep total disk use under 1 GB)
1. Node.js 22 or newer: `node -v`.
2. ffmpeg on the PATH: `ffmpeg -version`. If missing: Windows `winget install Gyan.FFmpeg` (then open a new terminal so the PATH refreshes), macOS `brew install ffmpeg`, Debian/Ubuntu `sudo apt install -y ffmpeg`.
3. Google Chrome or Microsoft Edge installed. If neither exists, run `npx playwright install chromium` after step 2 (about 300 MB).
4. Fonts: the look uses Arial Black and Consolas (both ship with Windows). On Linux install ttf-mscorefonts-installer for the identical look; without them the browser falls back to Arial and Courier New and the video still renders.
5. Optional, only needed later to measure a music track you supply: Python 3 with `pip install --no-cache-dir librosa soundfile`. Do not install it for this first test.
# STEP 2 - Create the project
```
mkdir motion-studio
cd motion-studio
npm init -y
npm i -D playwright-core
```
playwright-core downloads no browser: it drives the Chrome or Edge already installed.
# STEP 3 - Create the files
Create each file below with EXACTLY the content between its markers, byte for byte. Keep the Portuguese text and comments as they are: the Portuguese text is what appears on screen. Do not refactor, rename or "improve" anything before the first render. Create the folders lib/ and .claude/skills/motion-reel/ as needed. Do not include the marker lines themselves.
=== FILE: motion-studio/CLAUDE.md ===
# Regras do motion studio
## Contrato de render
- Todo filme é função pura do tempo: `window.seek(t)` pinta o frame t.
- Proibido em modo render: transições CSS, setTimeout, requestAnimationFrame, estado
carregado entre frames. Ruído só com seed (`rng()` de lib/motion.js), nunca Math.random.
- O filme exporta `window.DUR` (segundos) e `window.CUES` (sons na mesma linha do tempo).
- Build completo: `node build.mjs` → out/final.mp4 (H.264 yuv420p, CRF 16, áudio -14 LUFS).
Teste rápido: `--fps 30 --sub 2` (padrão). Final: `--fps 60 --sub 4`.
- Navegador: Chrome instalado via playwright-core (sem baixar Chromium, economiza disco).
## Visual
- Proibido: título centralizado em gradiente, tudo entrando com fade, labels em canto,
molduras, glow em UI, explosão genérica de partículas.
- Uma fonte display, uma fonte UI. Uma cor de destaque, salvo se o brief disser outra coisa.
- A cada 2 a 4 segundos algo novo acontece na tela.
- Movimento só com molas de lib/motion.js. Valor com vários alvos usa `track()`.
## Som
- Trilha e SFX sintetizados em código (sfx.mjs) salvo se vier uma faixa.
- Faixa fornecida: medir com `python beats.py faixa.wav > beats.json` e cortar na grade.
## Loop antes de mostrar qualquer coisa
1. Gerar out/contact.png (o build já gera) e OLHAR.
2. Nota 1-10: gancho nos 2s iniciais, leitura em tela de celular, qualidade do movimento,
variedade, fidelidade à marca, sincronia do som.
3. Corrigir os 3 piores problemas. Repetir até tudo 8+.
4. Só então o render final.
=== END FILE ===
=== FILE: motion-studio/lib/motion.js ===
// Biblioteca de movimento do studio. Tudo aqui é função pura do tempo,
// então seek(t) pinta qualquer frame sem simular os anteriores.
// Script clássico (não módulo) para funcionar via file:// no Chrome.
const clamp = (x, a = 0, b = 1) => Math.min(b, Math.max(a, x));
const lerp = (a, b, x) => a + (b - a) * x;
// Mola amortecida de forma fechada, 0 → 1.
// Rápida (UI) 320/30 · padrão 170/26 · pesada (tipo grande) 120/24 · brincalhona 200/10
function spring(t, k = 170, d = 26) {
if (t <= 0) return 0;
const w0 = Math.sqrt(k), z = d / (2 * w0);
if (z < 1) {
const wd = w0 * Math.sqrt(1 - z * z);
return 1 - Math.exp(-z * w0 * t) * (Math.cos(wd * t) + (z * w0 / wd) * Math.sin(wd * t));
}
return 1 - Math.exp(-w0 * t) * (1 + w0 * t);
}
// Valor que muda de alvo várias vezes: soma uma mola por mudança, sem reiniciar.
// keys: [[tempo, valor], ...] em ordem de tempo.
function track(t, keys, k = 170, d = 26) {
let v = keys[0][1];
for (let i = 1; i < keys.length; i++)
v += (keys[i][1] - keys[i - 1][1]) * spring(t - keys[i][0], k, d);
return v;
}
// Indicador que estica: borda da frente mais dura que a de trás.
function indicator(t, stops, width = 120) {
const lead = track(t, stops, 320, 30), trail = track(t, stops, 140, 22);
return { left: Math.min(lead, trail), right: Math.max(lead, trail) + width };
}
// Texto dentro de container que muda: entra depois da mudança, sai antes da próxima.
function swapAlpha(t, tIn, tOut) {
return Math.min(clamp((t - tIn - 0.08) / 0.12), clamp((tOut - 0.1 - t) / 0.1));
}
const loopT = (t, dur) => ((t % dur) + dur) % dur;
// Ruído com seed (mulberry32). Nunca Math.random: o render tem que ser idêntico sempre.
function rng(seed) {
return () => {
seed |= 0; seed = seed + 0x6D2B79F5 | 0;
let t = Math.imul(seed ^ seed >>> 15, 1 | seed);
t = t + Math.imul(t ^ t >>> 7, 61 | t) ^ t;
return ((t ^ t >>> 14) >>> 0) / 4294967296;
};
}
=== END FILE ===
=== FILE: motion-studio/render.mjs ===
// node render.mjs [--fps 30] [--sub 2] [--dur <s>] [--page index.html]
// Chama window.seek(t) frame a frame no Chrome headless e envia os PNGs ao ffmpeg.
// --sub N renderiza N subframes por frame e mistura (motion blur).
import { chromium } from 'playwright-core';
import { spawn } from 'node:child_process';
import { mkdirSync, writeFileSync } from 'node:fs';
import { pathToFileURL } from 'node:url';
import { resolve } from 'node:path';
const argv = process.argv;
const arg = (k, d) => { const i = argv.indexOf('--' + k); return i > 0 ? argv[i + 1] : d; };
const FPS = Number(arg('fps', 30)), SUB = Number(arg('sub', 2));
const PAGE = arg('page', 'index.html');
mkdirSync('out', { recursive: true });
// Usa o Chrome já instalado; depois o Edge; por último o Chromium do Playwright
// (só existe se alguém rodou `npx playwright install chromium`)
async function launch() {
for (const channel of ['chrome', 'msedge', undefined]) {
try { return await chromium.launch(channel ? { channel } : {}); } catch {}
}
throw new Error('Nenhum navegador. Instale o Chrome ou rode: npx playwright install chromium');
}
const browser = await launch();
const page = await browser.newPage({ deviceScaleFactor: 1 });
await page.goto(pathToFileURL(resolve(PAGE)).href);
await page.evaluate(() => document.fonts.ready);
const { w, h, dur, cues } = await page.evaluate(() => {
const c = document.querySelector('canvas');
return { w: c.width, h: c.height, dur: window.DUR, cues: window.CUES || [] };
});
const DUR = Number(arg('dur', dur));
writeFileSync('out/cues.json', JSON.stringify(cues));
// tmix mistura SUB subframes seguidos; select fica com o último de cada grupo
const vf = SUB > 1
? `tmix=frames=${SUB},select='eq(mod(n\\,${SUB})\\,${SUB - 1})',setpts=N/${FPS}/TB`
: 'null';
const ff = spawn('ffmpeg', ['-y', '-v', 'error', '-f', 'image2pipe', '-framerate', String(FPS * SUB), '-i', '-',
'-vf', vf, '-r', String(FPS), '-c:v', 'libx264', '-crf', '16', '-preset', 'medium',
'-pix_fmt', 'yuv420p', 'out/silent.mp4'], { stdio: ['pipe', 'inherit', 'inherit'] });
const total = Math.round(DUR * FPS * SUB);
const t0 = Date.now();
for (let i = 0; i < total; i++) {
const b64 = await page.evaluate((t) => {
window.seek(t);
return document.querySelector('canvas').toDataURL('image/png').slice(22);
}, i / (FPS * SUB));
if (!ff.stdin.write(Buffer.from(b64, 'base64'))) await new Promise((r) => ff.stdin.once('drain', r));
if (i % (FPS * SUB) === 0) console.log(`frame ${(i / (FPS * SUB)).toFixed(0)}s / ${DUR}s`);
}
ff.stdin.end();
await new Promise((r) => ff.on('close', r));
await browser.close();
console.log(`${w}x${h} ${FPS}fps sub${SUB} → out/silent.mp4 em ${((Date.now() - t0) / 1000).toFixed(0)}s`);
=== END FILE ===
=== FILE: motion-studio/sfx.mjs ===
// node sfx.mjs out/cues.json out/sfx.wav
// cues: [{"t":0.5,"type":"kick"}, {"t":2,"type":"bass","f":55}, ...]
// Sintetiza cada som em código. Ruído com seed: o áudio é idêntico a cada render.
import { readFileSync, writeFileSync } from 'node:fs';
const SR = 48000, cues = JSON.parse(readFileSync(process.argv[2], 'utf8'));
const buf = new Float32Array(Math.ceil((Math.max(0, ...cues.map((c) => c.t)) + 3) * SR));
let seed = 42;
const noise = () => (seed = (seed * 1664525 + 1013904223) >>> 0) / 2147483648 - 1;
const TAU = 2 * Math.PI;
// [duração em s, (t, cue) => amostra]
const VOICES = {
kick: [0.45, (t) => Math.sin(TAU * (48 * t + 110 * (1 - Math.exp(-t * 28)) / 28)) * Math.exp(-t * 7) * 0.9],
hat: [0.08, (t) => noise() * Math.exp(-t * 60) * 0.18],
click: [0.04, (t) => Math.sin(TAU * 2200 * t) * Math.exp(-t * 120) * 0.35],
pop: [0.18, (t) => Math.sin(TAU * (500 * t + 900 * t * t)) * Math.exp(-t * 26) * 0.45],
thump: [0.70, (t) => (Math.sin(TAU * (40 * t + 90 * (1 - Math.exp(-t * 12)) / 12)) * 0.9 + noise() * 0.15 * Math.exp(-t * 30)) * Math.exp(-t * 5)],
whoosh: [0.40, (t) => noise() * Math.sin(Math.PI * Math.min(1, t / 0.4)) ** 2 * 0.22],
bass: [1.90, (t, c) => {
const f = c.f || 55, env = Math.min(1, t * 80) * Math.exp(-t * 1.4);
return (Math.sin(TAU * f * t) * 0.7 + Math.sin(TAU * 2 * f * t) * 0.18 + Math.sin(TAU * 3 * f * t) * 0.07) * env * 0.55;
}],
};
for (const c of cues) {
const v = VOICES[c.type];
if (!v) { console.warn('som desconhecido:', c.type); continue; }
const [len, fn] = v, start = Math.floor(c.t * SR), gain = c.gain ?? 1;
for (let i = 0; i < len * SR && start + i < buf.length; i++) buf[start + i] += fn(i / SR, c) * gain;
}
const n = buf.length, b = Buffer.alloc(44 + n * 2); // WAV 16-bit mono
b.write('RIFF', 0); b.writeUInt32LE(36 + n * 2, 4); b.write('WAVEfmt ', 8);
b.writeUInt32LE(16, 16); b.writeUInt16LE(1, 20); b.writeUInt16LE(1, 22);
b.writeUInt32LE(SR, 24); b.writeUInt32LE(SR * 2, 28); b.writeUInt16LE(2, 32); b.writeUInt16LE(16, 34);
b.write('data', 36); b.writeUInt32LE(n * 2, 40);
for (let i = 0; i < n; i++) b.writeInt16LE(Math.round(Math.max(-1, Math.min(1, buf[i])) * 32767), 44 + i * 2);
writeFileSync(process.argv[3], b);
console.log(`${cues.length} sons → ${process.argv[3]}`);
=== END FILE ===
=== FILE: motion-studio/build.mjs ===
// node build.mjs [--fps 30 --sub 2 --page index.html]
// render → som → mix -14 LUFS → out/final.mp4 + folhas de revisão (contact/phone).
import { spawnSync } from 'node:child_process';
const run = (cmd, args) => {
const r = spawnSync(cmd, args, { stdio: 'inherit' });
if (r.status !== 0) { console.error(`falhou: ${cmd} ${args.join(' ')}`); process.exit(1); }
};
const ff = (...a) => run('ffmpeg', ['-y', '-v', 'error', ...a]);
run('node', ['render.mjs', ...process.argv.slice(2)]);
run('node', ['sfx.mjs', 'out/cues.json', 'out/sfx.wav']);
ff('-i', 'out/silent.mp4', '-i', 'out/sfx.wav', '-map', '0:v', '-map', '1:a', '-c:v', 'copy',
'-af', 'loudnorm=I=-14:TP=-1.5:LRA=11', '-ar', '48000', '-c:a', 'aac', '-b:a', '192k',
'-shortest', '-movflags', '+faststart', 'out/final.mp4');
// Folhas para o loop de crítica: 2 frames/s e teste de leitura a 360px
ff('-i', 'out/final.mp4', '-vf', 'fps=2,scale=270:-1,tile=8x4', '-frames:v', '1', 'out/contact.png');
ff('-i', 'out/final.mp4', '-vf', 'fps=1,scale=360:-1,tile=8x2', '-frames:v', '1', 'out/phone.png');
ff('-ss', '1', '-i', 'out/final.mp4', '-frames:v', '1', 'out/poster.png');
console.log('pronto: out/final.mp4 · out/contact.png · out/phone.png · out/poster.png');
=== END FILE ===
=== FILE: motion-studio/beats.py ===
# python beats.py faixa.wav > beats.json
# Mede a grade de batidas de uma faixa fornecida. O filme lê beats.json
# e coloca mudanças nas batidas, momentos grandes nos tempos fortes e SFX nos picos.
import json
import sys
import librosa
import numpy as np
def medir(caminho):
audio, taxa = librosa.load(caminho, sr=None, mono=True)
andamento, quadros = librosa.beat.beat_track(y=audio, sr=taxa, units="frames")
batidas = [round(float(x), 3) for x in librosa.frames_to_time(quadros, sr=taxa)]
forca = librosa.onset.onset_strength(y=audio, sr=taxa)
picos = librosa.onset.onset_detect(onset_envelope=forca, sr=taxa, units="time")
return {
"bpm": round(float(np.atleast_1d(andamento)[0]), 2),
"beats": batidas,
"downbeats": batidas[::4],
"hits": [round(float(x), 3) for x in picos],
}
if __name__ == "__main__":
json.dump(medir(sys.argv[1]), sys.stdout, indent=1)
=== END FILE ===
=== FILE: motion-studio/index.html ===
<!doctype html>
<meta charset="utf-8">
<title>Teste 01 · Como montar o studio</title>
<style>html,body{margin:0;background:#15130F}canvas{display:block;height:100vh;width:auto;margin:auto}</style>
<canvas id="c" width="1080" height="1920"></canvas>
<script src="lib/motion.js"></script>
<script>
const W = 1080, H = 1920, DUR = 16, BPM = 120, BEAT = 60 / BPM;
const g = document.getElementById('c').getContext('2d');
const C = { bg: '#15130F', card: '#221F1A', paper: '#F2EDE4', muted: '#857D70', accent: '#FF5A1F' };
const DISPLAY = '"Arial Black", Arial, sans-serif', MONO = 'Consolas, "Courier New", monospace';
const CUTS = [2, 5, 8, 11, 14];
// ---------- primitivas ----------
function txt(s, x, y, size, color, font = DISPLAY, align = 'left') {
g.font = `${size}px ${font}`; g.fillStyle = color; g.textAlign = align; g.textBaseline = 'alphabetic';
g.fillText(s, x, y);
}
function rrect(x, y, w, h, r) { g.beginPath(); g.roundRect(x, y, w, h, r); }
// Palavra sobe de dentro de uma máscara (sem fade)
function slam(s, x, y, size, color, t0, t, font = DISPLAY) {
const p = spring(t - t0, 220, 24);
if (p <= 0) return;
g.save();
g.beginPath(); g.rect(0, y - size * 0.92, W, size * 1.12); g.clip();
txt(s, x, y + (1 - p) * size * 1.05, size, color, font);
g.restore();
}
function backdrop(t) {
g.fillStyle = C.bg; g.fillRect(0, 0, W, H);
g.fillStyle = 'rgba(242,237,228,0.06)';
const off = (t * 24) % 60;
for (let y = -60 + off; y < H; y += 60) for (let x = 30; x < W; x += 60) g.fillRect(x, y, 3, 3);
}
// Painel de destaque sobe e limpa a tela em cada corte; bordas em molas diferentes esticam o painel
function wipe(t) {
for (const T of CUTS) {
const a = spring(t - (T - 0.34), 420, 40), b = spring(t - T, 300, 34);
if (a <= 0.001 || b >= 0.999) continue;
g.fillStyle = C.accent; g.fillRect(0, H * (1 - a), W, H * (a - b));
}
}
function stepHead(n, label, t) {
slam(n, 90, 420, 230, C.accent, 0.05, t);
slam(label, 470, 410, 92, C.paper, 0.2, t);
g.fillStyle = C.paper; g.fillRect(470, 440, 520 * spring(t - 0.3, 260, 26), 8);
}
// bola quicando como função de "tempo do filme" ph: o mesmo t dá sempre o mesmo quadro
function bounce(ph) { const s = spring(ph, 150, 7); return s <= 1 ? s : 2 - s; }
// ---------- cenas (t local) ----------
function s0(t) {
slam('MONTE', 90, 760, 190, C.paper, 0.0, t);
slam('SEU', 90, 960, 190, C.paper, 0.25, t);
slam('STUDIO', 90, 1160, 190, C.accent, 0.5, t);
slam('DE MOTION', 90, 1350, 140, C.paper, 0.75, t);
g.fillStyle = C.accent; g.fillRect(90, 1410, 900 * spring(t - 0.9, 260, 26), 14);
slam('com Claude Code. Só código.', 90, 1510, 46, C.muted, 1.0, t, MONO);
}
const INSTALL = [
{ t: 0.4, cmd: 'node -v', out: 'v22 ✓' },
{ t: 0.75, cmd: 'ffmpeg -version', out: '8.1 ✓' },
{ t: 1.1, cmd: 'pip install librosa', out: 'ok ✓' },
{ t: 1.45, cmd: 'npm i -D playwright-core', out: 'usa o Chrome que você já tem ✓' },
];
function s1(t) {
stepHead('01', 'INSTALE', t);
const s = spring(t - 0.2, 200, 24);
if (s <= 0) return;
g.save();
rrect(90, 560, 900, 860 * s, 28); g.fillStyle = C.card; g.fill(); g.clip();
for (let i = 0; i < 3; i++) { g.beginPath(); g.arc(140 + i * 40, 610, 11, 0, 7); g.fillStyle = '#3A352D'; g.fill(); }
INSTALL.forEach((l, i) => {
const lt = t - l.t, y = 730 + i * 160;
if (lt < 0) return;
const n = Math.floor(clamp(lt / 0.22) * l.cmd.length);
txt('$', 140, y, 46, C.accent, MONO);
txt(l.cmd.slice(0, n), 190, y, 46, C.paper, MONO);
const typing = n < l.cmd.length || (i === INSTALL.length - 1 && t < 2.0) || (INSTALL[i + 1] && t < INSTALL[i + 1].t);
if (typing && Math.floor(t * 4) % 2 === 0) { g.font = `46px ${MONO}`; g.fillStyle = C.paper; g.fillRect(194 + g.measureText(l.cmd.slice(0, n)).width, y - 38, 24, 46); }
if (lt > 0.28) txt(l.out, 190, y + 58, 34, C.muted, MONO);
});
g.restore();
// selo final dentro do quadro
const p = spring(t - 1.95, 240, 16);
if (p > 0) {
g.save(); g.translate(540, 1530); g.scale(p, p);
rrect(-330, -70, 660, 120, 60); g.fillStyle = C.accent; g.fill();
txt('STUDIO < 1 GB', 0, 18, 58, C.bg, DISPLAY, 'center');
g.restore();
}
}
const RULES = ['seek(t) puro', 'sem Math.random', 'molas, não easing', 'olhar os frames'];
function s2(t) {
stepHead('02', 'REGRAS', t);
const s = spring(t - 0.15, 170, 20);
g.save();
g.translate(540, 1030 + (1 - s) * 1100); g.rotate((-2.5 + (1 - s) * 10) * Math.PI / 180);
rrect(-450, -420, 900, 840, 26); g.fillStyle = C.paper; g.fill();
txt('CLAUDE.md', -380, -300, 64, C.bg, MONO);
g.fillStyle = C.muted; g.fillRect(-380, -265, 760, 4);
RULES.forEach((r, i) => {
const y = -130 + i * 150, tc = 0.75 + i * 0.5;
g.lineWidth = 6; g.strokeStyle = C.bg; rrect(-380, y - 52, 62, 62, 10); g.stroke();
txt(r, -280, y, 52, C.bg);
const p = clamp((t - tc) / 0.16);
if (p > 0) {
const pts = [[-368, y - 24], [-352, y - 6], [-322, y - 48]];
const l1 = Math.hypot(16, 18), l2 = Math.hypot(30, 42), d = p * (l1 + l2);
g.beginPath(); g.moveTo(...pts[0]);
if (d <= l1) g.lineTo(lerp(pts[0][0], pts[1][0], d / l1), lerp(pts[0][1], pts[1][1], d / l1));
else { g.lineTo(...pts[1]); const q = (d - l1) / l2; g.lineTo(lerp(pts[1][0], pts[2][0], q), lerp(pts[1][1], pts[2][1], q)); }
g.lineCap = 'round'; g.lineJoin = 'round'; g.lineWidth = 12; g.strokeStyle = C.accent; g.stroke();
}
});
g.restore();
}
function s3(t) {
stepHead('03', 'seek(t)', t);
slam('window.seek(t)', 90, 590, 64, C.accent, 0.25, t, MONO);
const ph = track(t, [[0, 0], [0.35, 1.2], [1.35, 0.3], [2.1, 1.2]], 90, 18);
const grow = spring(t - 0.15, 260, 18);
const top = 720, range = 560, bx = (p) => 200 + 680 * clamp(p / 1.2);
// chão
g.fillStyle = C.card; g.fillRect(90, top + range + 70, 900 * grow, 10);
// onion skin: frames vizinhos
for (let i = 5; i >= 1; i--) {
const p = ph - i * 0.07;
g.beginPath(); g.arc(bx(p), top + range * bounce(p), 70 * grow, 0, 7);
g.fillStyle = `rgba(255,90,31,${0.05 + 0.03 * (5 - i)})`; g.fill();
}
g.beginPath(); g.arc(bx(ph), top + range * bounce(ph), 70 * grow, 0, 7); g.fillStyle = C.accent; g.fill();
// linha do tempo
const ty = 1560;
g.fillStyle = C.card; g.fillRect(90, ty, 900 * grow, 12);
for (let i = 0; i <= 12; i++) { g.fillStyle = C.muted; g.fillRect(90 + i * 75, ty + 22, 3, i % 4 ? 16 : 30); }
const px = 90 + 900 * clamp(ph / 1.2);
if (grow > 0.2) {
g.fillStyle = C.paper; g.fillRect(px - 3, ty - 70, 6, 120);
txt(`t = ${ph.toFixed(2)}s`, clamp(px, 210, 870), ty - 90, 40, C.paper, MONO, 'center');
}
slam('qualquer t → o frame exato', 90, 1760, 54, C.paper, 0.6, t);
}
function s4(t) {
stepHead('04', 'RENDER', t);
for (let i = 0; i < 12; i++) {
const s = spring(t - 0.15 - i * 0.06, 240, 22);
if (s <= 0) continue;
const tx = 90 + (i % 4) * 230, ty = 560 + Math.floor(i / 4) * 300;
g.save(); g.translate(lerp(W + 150, tx, s), ty); g.rotate((1 - s) * 0.5);
rrect(0, 0, 200, 260, 16); g.fillStyle = C.card; g.fill();
const p = (i / 11) * 1.2;
g.beginPath(); g.arc(30 + 140 * clamp(p / 1.2), 40 + 150 * bounce(p), 18, 0, 7); g.fillStyle = C.accent; g.fill();
txt('f' + String(i * 40).padStart(3, '0'), 18, 244, 28, C.muted, MONO);
g.restore();
}
const p = clamp((t - 0.9) / 0.8);
if (t > 0.8) {
rrect(90, 1560, 900, 36, 18); g.fillStyle = C.card; g.fill();
if (p > 0) { rrect(90, 1560, Math.max(36, 900 * p), 36, 18); g.fillStyle = C.accent; g.fill(); }
txt(`frame ${Math.round(480 * p)}/480`, 90, 1530, 42, C.paper, MONO);
txt('Chrome → PNG → ffmpeg', 990, 1660, 38, C.muted, MONO, 'right');
}
const st = spring(t - 1.85, 220, 11);
if (st > 0) {
g.save(); g.translate(540, 1100); g.rotate(-0.1); g.scale(st, st);
rrect(-270, -140, 540, 280, 34); g.fillStyle = C.accent; g.fill();
txt('MP4', 0, 70, 200, C.bg, DISPLAY, 'center');
g.restore();
}
}
function s5(t) {
slam('1 FUNÇÃO.', 90, 820, 150, C.paper, 0.05, t);
slam('0 AFTER', 90, 1000, 150, C.paper, 0.5, t);
slam('EFFECTS.', 90, 1180, 150, C.accent, 1.0, t);
slam('teste #1 · motion-studio', 90, 1320, 44, C.muted, 1.3, t, MONO);
}
const SCENES = [[0, s0], [2, s1], [5, s2], [8, s3], [11, s4], [14, s5]];
function draw(t) {
backdrop(t);
let cur = SCENES[0];
for (const s of SCENES) if (t >= s[0]) cur = s;
cur[1](t - cur[0]);
wipe(t);
}
// ---------- som na mesma linha do tempo ----------
const CUES = [];
const BASS = [55, 43.65, 65.41, 49]; // Lá, Fá, Dó, Sol (um por compasso)
for (let b = 0; b * BEAT < DUR - 0.01; b++) {
CUES.push({ t: b * BEAT, type: b % 2 ? 'hat' : 'kick' });
if (b % 4 === 0) CUES.push({ t: b * BEAT, type: 'bass', f: BASS[(b / 4) % 4] });
}
[0, 0.25, 0.5, 0.75].forEach((x) => CUES.push({ t: x, type: 'pop' }));
CUTS.forEach((T) => CUES.push({ t: T - 0.36, type: 'whoosh' }));
INSTALL.forEach((l) => { CUES.push({ t: 2 + l.t, type: 'click' }); CUES.push({ t: 2 + l.t + 0.28, type: 'click', gain: 0.6 }); });
CUES.push({ t: 3.95, type: 'pop' });
RULES.forEach((_, i) => CUES.push({ t: 5 + 0.75 + i * 0.5, type: 'pop' }));
CUES.push({ t: 11 + 1.85, type: 'thump' });
[14.05, 14.5, 15.0].forEach((x) => CUES.push({ t: x, type: 'thump', gain: 0.7 }));
window.DUR = DUR;
window.CUES = CUES;
window.seek = (t) => { draw(t); return true; };
// Preview ao vivo num navegador normal; desligado no render headless
if (!navigator.webdriver) {
const t0 = performance.now();
(function loop() { draw(((performance.now() - t0) / 1000) % DUR); requestAnimationFrame(loop); })();
}
</script>
=== END FILE ===
=== FILE: motion-studio/.claude/skills/motion-reel/SKILL.md ===
---
name: motion-reel
description: Faz um vídeo de motion design renderizado a partir de código neste studio. Use quando pedirem vídeo de lançamento, showreel, reel de produto, explainer animado, tutorial animado ou anúncio em motion.
---
# Motion reel
## Coletar antes
Assunto/produto (+ URL), duração, formato (9:16 / 1:1 / 16:9), cores e fontes da marca,
uma referência (frame, vídeo ou pasta de imagens), música (arquivo ou "sintetizar").
## Pipeline
1. Com URL: capturar telas e logo reais com playwright-core em ./assets. Listar o que achou.
2. Com referência: extrair frames (ffmpeg fps=2) e escrever docs/style_guide.md.
3. Faixa fornecida: `python beats.py faixa.wav > beats.json`. Sem faixa: sintetizar em CUES.
4. Escrever docs/shotlist.md na grade de batidas. Mostrar e esperar OK.
5. Criar a página (copiar index.html como base): `window.seek(t)`, `window.DUR`, `window.CUES`,
molas de lib/motion.js. Seguir CLAUDE.md.
6. `node build.mjs --page <arquivo>.html` → abrir out/contact.png e out/phone.png → nota 1-10
→ corrigir os 3 piores. Mínimo 3 rodadas.
7. Final em qualidade alta: `node build.mjs --fps 60 --sub 4`.
8. Entregar out/final.mp4, out/contact.png, out/poster.png e dizer o que melhoraria.
## Regras duras
- UI real do produto. Nunca inventar telas.
- Sem Math.random, timers ou transições CSS em modo render.
- Proibido: labels em canto, título centralizado em gradiente, tudo entrando com fade.
=== END FILE ===
=== FILE: motion-studio/README.md ===
# motion-studio
Vídeos de motion design feitos 100% em código. O Claude escreve uma página com `window.seek(t)`,
o Chrome headless pinta cada frame, o ffmpeg monta o MP4 e o som é sintetizado na mesma linha do tempo.
## Requisitos (já instalados)
Node 22+, ffmpeg, Python com numpy/librosa/soundfile, Chrome. `npm i` instala só o playwright-core.
## Uso
```
node build.mjs # teste rápido 30fps → out/final.mp4
node build.mjs --fps 60 --sub 4 # qualidade final (motion blur)
node build.mjs --page outro.html # renderizar outro filme
python beats.py faixa.wav > beats.json
```
Preview ao vivo: abrir `index.html` no navegador.
No Claude Code, dentro desta pasta: `/motion-reel` com o pedido do vídeo.
## Arquivos
- `CLAUDE.md`: regras da casa, lidas em toda sessão.
- `lib/motion.js`: molas, track, rng com seed.
- `render.mjs`: seek(t) → PNG → ffmpeg (out/silent.mp4).
- `sfx.mjs`: sintetiza `window.CUES` em out/sfx.wav.
- `build.mjs`: render + som + mix -14 LUFS + contact sheet.
- `index.html`: teste 01, tutorial "monte seu studio" (16s, 9:16).
=== END FILE ===
# STEP 4 - Render
From inside motion-studio run:
```
node build.mjs
```
Expected: the log prints "frame 0s / 16s" up to "frame 15s / 16s", then "66 sons → out/sfx.wav" and "pronto: ...". It takes roughly 40 to 120 seconds depending on the machine. Outputs:
- out/final.mp4: 16.0 s, 1080x1920, 30 fps, H.264 + AAC, audio normalized to -14 LUFS (about 2 to 3 MB)
- out/contact.png: 32 frames, 2 per second, for review
- out/phone.png: 16 frames at 360 px wide (phone readability test)
- out/poster.png: a frame at 1 s
If it fails: "ffmpeg not found" means the PATH (step 1.2); "Nenhum navegador" means no browser (step 1.3).
# STEP 5 - Verify by looking at the frames
Open out/contact.png as an image and check that you see, in order:
1. 0-2 s: the words MONTE / SEU / STUDIO (orange) / DE MOTION rising one by one from a mask, an orange underline, then the gray line "com Claude Code. Só código."
2. An orange panel wiping up the screen between every scene.
3. 2-5 s: "01 INSTALE" and a dark terminal typing node -v, ffmpeg -version, pip install librosa, npm i -D playwright-core, ending with an orange pill "STUDIO < 1 GB".
4. 5-8 s: "02 REGRAS" and a tilted cream card "CLAUDE.md" whose 4 boxes get orange check marks.
5. 8-11 s: "03 seek(t)", an orange ball bouncing with an onion-skin trail and a timeline whose playhead label reads "t = ...s".
6. 11-14 s: "04 RENDER", 12 frame cards flying into a grid, a progress bar reaching "frame 480/480", and a big orange "MP4" stamp.
7. 14-16 s: "1 FUNÇÃO." / "0 AFTER" / "EFFECTS." (orange) and the small line "teste #1 · motion-studio".
If anything is missing, clipped or overlapping, fix only that, run node build.mjs again and look again. Then score the video 1 to 10 on: hook in the first 2 s, readability at phone size, motion quality, variety, sound sync.
# STEP 6 - Report to me
Give me the absolute path of out/final.mp4, its duration, the render time and your scores. Then tell me how to make the next video:
- open Claude Code inside motion-studio and type /motion-reel followed by what I want (the project skill), or describe the video in plain words; CLAUDE.md holds the house rules;
- `node build.mjs` for a quick test, `node build.mjs --fps 60 --sub 4` for the final quality with motion blur;
- `node build.mjs --page other.html` to render another film.
O que o prompt faz
- Confere o ambiente e instala só o que falta, sem baixar navegador nem pacotes pesados.
- Cria o motor:
render.mjs(quadros → ffmpeg),sfx.mjs(síntese de som),build.mjs(tudo de uma vez),lib/motion.js(movimento com física de mola, que dá peso às animações) ebeats.py(mede a batida de uma música que você fornecer). - Escreve as regras da casa num
CLAUDE.md, que o Claude Code lê em toda sessão: nada de título centralizado em gradiente, nada de tudo entrando com fade, algo novo na tela a cada 2 a 4 segundos. - Instala uma skill,
/motion-reel, para os próximos vídeos: você descreve o que quer e ela segue o mesmo processo. - Revisa o próprio trabalho: o Claude abre uma folha com 32 quadros do vídeo, confere cena por cena e corrige o que estiver cortado ou sobreposto antes de entregar.
E depois do primeiro vídeo?
Dentro da pasta motion-studio, peça o próximo vídeo em português mesmo: “faça um vídeo de 20 segundos apresentando meu produto X, nas cores Y”. O estúdio já está pronto, então a segunda vez é mais rápida. Para a versão final, com 60 quadros por segundo e desfoque de movimento, rode node build.mjs --fps 60 --sub 4.
Dica: dar uma referência visual (um print de um vídeo que você admira) muda mais o resultado do que escrever um prompt mais longo. Diga o que aproveitar (cores, tipografia, ritmo) e o que não copiar.
A ideia de tratar o vídeo como um programa veio do guia de motion design com Claude publicado por @0xMovez no X. O estúdio, o código e o prompt deste artigo foram escritos e testados por nós.