Skip to content

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.

Notifications You must be signed in to change notification settings

JohnEsleyer/clawmotion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

48 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸ¦€ ClawMotion (v1.0.0)

License: ISC Agent-First

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.


✨ Key Features

  • πŸ—οΈ 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

πŸ“‹ Requirements

# Ubuntu/Debian
sudo apt-get install -y ffmpeg
  • FFmpeg: Video encoding (included in server pipeline)

πŸš€ Quick Start

Installation

npm install @johnesleyer/clawmotion
npm run build

Use in Node.js

import { 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');

Run Examples

npx ts-node examples/hello-world.ts
npx ts-node examples/transitions.ts
npx ts-node examples/keyframes.ts

ClawStudio (Visual Editor)

# From any folder - that folder becomes your workspace
clawmotion studio

# Or with explicit workspace
CLAWMOTION_WORKSPACE=/path/to/folder npm run studio

πŸ—οΈ Architecture

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚                        ClawMotion                                β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚    Browser (Preview)  β”‚           Server (Node.js)              β”‚
β”œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”Όβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€
β”‚  β€’ ClawEngine         β”‚  β€’ MotionFactory                        β”‚
β”‚  β€’ ClawPlayer        β”‚  β€’ Skia Canvas                          β”‚
β”‚  β€’ OffscreenCanvas   β”‚  β€’ FFmpeg Pipeline                     β”‚
β”‚  β€’ VideoEncoder      β”‚  β€’ Fast rendering                       β”‚
β”‚  (100% parity)       β”‚                                         β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”΄β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                          β”‚
                   Shared Core
          (Blueprints, Math, Animator)

Render Modes

Mode Parity Speed Use Case
Browser (WebCodecs) 100% Fast Production, exact replica
Server (Skia) ~99% Fastest Quick previews

🎨 The Blueprint Pattern

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);
};

Built-in Blueprints

  • gradient-bg - Animated gradient backgrounds
  • text-hero - Premium typography
  • floaty-blobs - Deterministic particles
  • glass-card - Glassmorphism UI
  • vignette - Cinematic corners
  • video - Video overlays

πŸ“œ Clip Definition

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'
};

Transitions

Built-in transitions: fade, slide, zoom

Animations

const clip = {
    // ...
    animations: {
        x: [
            { tick: 0, value: 0, easing: 'easeOutQuad' },
            { tick: 60, value: 500 }
        ],
        opacity: [
            { tick: 0, value: 0 },
            { tick: 30, value: 1 }
        ]
    }
};

πŸ› οΈ Tech Stack

  • TypeScript - Type-safe core
  • OffscreenCanvas - Browser rendering
  • WebCodecs - Hardware-accelerated encoding
  • Skia Canvas - Node.js rendering
  • FFmpeg - Video encoding
  • esbuild - Fast bundling

πŸ“ Project Structure

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

πŸ€– AI Integration

See LLM.md for AI agent context, code snippets, and best practices.


βš–οΈ License

ISC License. See LICENSE file.

About

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.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published