Skip to content

ojassingh/json-motion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

229 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Motion

Motion is a deterministic, agent-native video engine built on Next.js. A render request describes scenes, nodes, transforms, and animations as plain data. The server resolves each frame with a pure animation layer, rasterizes it through skia-canvas, and streams raw RGBA frames into ffmpeg to produce an MP4.

json-motion

Prerequisites

  • Bun
  • A local ffmpeg binary available on your PATH
  • macOS Metal support if you want the default h264_videotoolbox hardware encoder

You can verify ffmpeg is installed with:

ffmpeg -version

Development

bun install
bun run dev

For the prompt-to-video flow, set:

AI_GATEWAY_API_KEY=your_key_here

Render API

POST /api/render

Example request body:

{
  "width": 640,
  "height": 360,
  "fps": 12,
  "background": "#07111f",
  "scenes": [
    {
      "id": "intro",
      "startFrame": 0,
      "durationInFrames": 24,
      "background": "#07111f",
      "nodes": [
        {
          "id": "card",
          "type": "rect",
          "width": 544,
          "height": 220,
          "radius": 24,
          "fill": "#0f172a",
          "transform": {
            "x": 48,
            "y": 72
          }
        },
        {
          "id": "headline",
          "type": "text",
          "text": "Deterministic video",
          "fontSize": 42,
          "transform": {
            "x": 88,
            "y": 112
          },
          "animations": [
            {
              "type": "effect",
              "name": "fade-in",
              "startFrame": 0,
              "endFrame": 10
            }
          ]
        }
      ]
    }
  ]
}

Example curl:

curl -X POST http://localhost:3000/api/render \
  -H "Content-Type: application/json" \
  -d @request.json

Successful responses return a job id, output metadata, and a URL such as /renders/<job-id>.mp4.

Local fixture

A sample render request lives at lib/video/fixtures/sample-video-description.ts.

Render it locally:

bun run render:fixture

Prompt-to-video smoke test

Run a live prompt generation plus render with the sample prompt:

bun run prompt:smoke

Tests and checks

bun test
bun run typecheck
bun x ultracite check

About

The Generative Animation Engine

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors