A motion design studio on your own machine: Claude makes the video step by step, you approve every stage. Bring your own Claude Code or API key.
// A small PNG reader/writer (8-bit grey, grey+alpha, RGB, RGBA; not interlaced) so the studio can measure the pixels of a
// rendered still without any dependency. Kinetograph's stills are 8-bit RGBA.
import { inflateSync, deflateSync } from 'node:zlib';
const SIG = Buffer.from([0x89, 0x50, 0x4e, 0x47, 0x0d, 0x0a, 0x1a, 0x0a]);
const CRC = (() => { const t = new Uint32Array(256); for (let n = 0; n < 256; n++) { let c = n; for (let k = 0; k < 8; k++) c = c & 1 ? 0xedb88320 ^ (c >>> 1) : c >>> 1; t[n] = c >>> 0; } return t; })();
const crc32 = (buf) => { let c = 0xffffffff; for (const b of buf) c = CRC[(c ^ b) & 0xff] ^ (c >>> 8); return (c ^ 0xffffffff) >>> 0; };
const chunk = (type, data) => { const t = Buffer.from(type, 'ascii'); const len = Buffer.alloc(4); len.writeUInt32BE(data.length); const c = Buffer.alloc(4); c.writeUInt32BE(crc32(Buffer.concat([t, data]))); return Buffer.concat([len, t, data, c]); };
// {w, h, data: Uint8Array RGBA}
export function decodePng(buf) {
if (buf.length < 33 || !buf.subarray(0, 8).equals(SIG)) throw new Error('not a PNG');
let p = 8, w = 0, h = 0, depth = 0, ct = 0, interlace = 0;
const idat = [];
while (p + 8 <= buf.length) {
const len = buf.readUInt32BE(p), type = buf.toString('ascii', p + 4, p + 8), d = buf.subarray(p + 8, p + 8 + len);
if (type === 'IHDR') { w = d.readUInt32BE(0); h = d.readUInt32BE(4); depth = d[8]; ct = d[9]; interlace = d[12]; }
else if (type === 'IDAT') idat.push(d);
else if (type === 'IEND') break;
p += 12 + len;
}
if (depth !== 8 || ![0, 2, 4, 6].includes(ct) || interlace) throw new Error(`unsupported PNG (depth ${depth}, type ${ct}, interlace ${interlace})`);
const ch = { 0: 1, 2: 3, 4: 2, 6: 4 }[ct];
const raw = inflateSync(Buffer.concat(idat));
const stride = w * ch;
const out = new Uint8Array(w * h * 4);
let prev = new Uint8Array(stride), cur = new Uint8Array(stride);
for (let y = 0; y < h; y++) {
const f = raw[y * (stride + 1)];
const line = raw.subarray(y * (stride + 1) + 1, (y + 1) * (stride + 1));
for (let i = 0; i < stride; i++) {
const a = i >= ch ? cur[i - ch] : 0, b = prev[i], c = i >= ch ? prev[i - ch] : 0;
let v = line[i];
if (f === 1) v += a; else if (f === 2) v += b; else if (f === 3) v += (a + b) >> 1;
else if (f === 4) { const pa = Math.abs(b - c), pb = Math.abs(a - c), pc = Math.abs(a + b - 2 * c); v += pa <= pb && pa <= pc ? a : pb <= pc ? b : c; }
cur[i] = v & 255;
}
for (let x = 0; x < w; x++) {
const o = (y * w + x) * 4;
if (ch === 1) { out[o] = out[o + 1] = out[o + 2] = cur[x]; out[o + 3] = 255; }
else if (ch === 2) { out[o] = out[o + 1] = out[o + 2] = cur[x * 2]; out[o + 3] = cur[x * 2 + 1]; }
else { out[o] = cur[x * ch]; out[o + 1] = cur[x * ch + 1]; out[o + 2] = cur[x * ch + 2]; out[o + 3] = ch === 4 ? cur[x * ch + 3] : 255; }
}
[prev, cur] = [cur, prev];
}
return { w, h, data: out };
}
// RGBA bytes -> PNG.
export function encodePng(w, h, rgba) {
const raw = Buffer.alloc(h * (w * 4 + 1));
for (let y = 0; y < h; y++) { raw[y * (w * 4 + 1)] = 0; Buffer.from(rgba.buffer, rgba.byteOffset + y * w * 4, w * 4).copy(raw, y * (w * 4 + 1) + 1); }
const ihdr = Buffer.alloc(13); ihdr.writeUInt32BE(w, 0); ihdr.writeUInt32BE(h, 4); ihdr[8] = 8; ihdr[9] = 6;
return Buffer.concat([SIG, chunk('IHDR', ihdr), chunk('IDAT', deflateSync(raw)), chunk('IEND', Buffer.alloc(0))]);
}