ClawMotion is a high-precision, programmatic video motion engine designed for AI Agents. Create complex video sequences using declarative blueprints and render with 100% parity between browser preview and server export.
- ποΈ Isomorphic Core: Same Blueprint logic runs in browser and Node.js
- π― 100% Parity: Browser-based export ensures identical preview and output
- π§ AI-Optimized: Declarative manifests easy for LLMs to generate. See LLM.md
- π² Deterministic Math: Seeded RNG and easing for frame-perfect reproducibility
- β‘ GPU-Native: WebCodecs (VideoEncoder) for hardware-accelerated encoding
- π΅ Audio-Reactive: FFT-analyzed audio drives visual animations
- π¦ Modular Exports:
@johnesleyer/clawmotion/core,client,server,blueprints - ποΈ Fast Rendering: Skia Canvas + FFmpeg for server-side production
# Ubuntu/Debian
sudo apt-get install -y ffmpeg- FFmpeg: Video encoding (included in server pipeline)
npm install @johnesleyer/clawmotion
npm run buildimport { ClawEngine, Clip } from '@johnesleyer/clawmotion/core';
import { MotionFactory } from '@johnesleyer/clawmotion/server';
import { ProBlueprints } from '@johnesleyer/clawmotion/blueprints';
const config = {
width: 1280,
height: 720,
fps: 30,
duration: 5
};
const clips: Clip[] = [
{
id: 'my-clip',
blueprintId: 'gradient-bg', // Built-in blueprint
startTick: 0,
durationTicks: 150,
props: { color1: '#1a2a6c', color2: '#b21f1f' }
}
];
const factory = new MotionFactory();
await factory.render(config, clips, './output.mp4');npx ts-node examples/hello-world.ts
npx ts-node examples/transitions.ts
npx ts-node examples/keyframes.ts# From any folder - that folder becomes your workspace
clawmotion studio
# Or with explicit workspace
CLAWMOTION_WORKSPACE=/path/to/folder npm run studioβββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β ClawMotion β
βββββββββββββββββββββββββ¬ββββββββββββββββββββββββββββββββββββββββββ€
β Browser (Preview) β Server (Node.js) β
βββββββββββββββββββββββββΌββββββββββββββββββββββββββββββββββββββββββ€
β β’ ClawEngine β β’ MotionFactory β
β β’ ClawPlayer β β’ Skia Canvas β
β β’ OffscreenCanvas β β’ FFmpeg Pipeline β
β β’ VideoEncoder β β’ Fast rendering β
β (100% parity) β β
βββββββββββββββββββββββββ΄ββββββββββββββββββββββββββββββββββββββββββ
β
Shared Core
(Blueprints, Math, Animator)
| Mode | Parity | Speed | Use Case |
|---|---|---|---|
| Browser (WebCodecs) | 100% | Fast | Production, exact replica |
| Server (Skia) | ~99% | Fastest | Quick previews |
Blueprints are pure functions that define "how" to draw:
import { BlueprintContext } from '@johnesleyer/clawmotion/core';
export const NeonPulse = (ctx: BlueprintContext) => {
const { width, height, localTime, props, utils } = ctx;
const jitter = utils.range(-5, 5); // Deterministic
ctx.ctx.fillStyle = props.color || 'cyan';
ctx.ctx.fillRect(width/2 - 50 + jitter, height/2 - 50, 100, 100);
};gradient-bg- Animated gradient backgroundstext-hero- Premium typographyfloaty-blobs- Deterministic particlesglass-card- Glassmorphism UIvignette- Cinematic cornersvideo- Video overlays
const clip = {
id: 'my-clip',
blueprintId: 'gradient-bg',
startTick: 0,
durationTicks: 150,
props: { color1: '#1a2a6c', color2: '#b21f1f' },
entry: { type: 'fade', durationTicks: 30 },
exit: { type: 'zoom', durationTicks: 30 },
layer: 0,
blendMode: 'normal'
};Built-in transitions: fade, slide, zoom
const clip = {
// ...
animations: {
x: [
{ tick: 0, value: 0, easing: 'easeOutQuad' },
{ tick: 60, value: 500 }
],
opacity: [
{ tick: 0, value: 0 },
{ tick: 30, value: 1 }
]
}
};- TypeScript - Type-safe core
- OffscreenCanvas - Browser rendering
- WebCodecs - Hardware-accelerated encoding
- Skia Canvas - Node.js rendering
- FFmpeg - Video encoding
- esbuild - Fast bundling
clawmotion/
βββ src/
β βββ core/ # Engine, Math, Animator, Blueprint types
β βββ client/ # Player, Compositor, WebCodecs encoder
β βββ server/ # Factory, NodeEncoder, FFmpeg
β βββ blueprints/ # ProBlueprints library
β βββ cli/ # clawmotion CLI
βββ examples/ # Usage examples
βββ studio/ # ClawStudio visual editor
See LLM.md for AI agent context, code snippets, and best practices.
ISC License. See LICENSE file.