DEV Community

Cover image for Ticktoon – Canvas + WebCodecs video renderer for AI
shidongdi
shidongdi

Posted on

Ticktoon – Canvas + WebCodecs video renderer for AI

Programmatic video, rendered in the browser. No FFmpeg, no per-frame screenshots.

One function tick(t): give it a time, synchronously get that frame. Preview and export call the same function.

Ticktoon is open source, in two repositories:

First, the category. Ticktoon is neither a video editor nor a video generation model. It does code-generated video: frames are described by code and rendered frame by frame by an engine. Plenty of projects compete on style count or how good the model's output looks. Ticktoon bets on the layer underneath — the render kernel. Styles can be stacked and models will keep improving, but the kernel decides how well and how fast developers can build on top of it. This article is about why that layer needed to be built from scratch.


Three attempts, two dead ends

The first version was a multi-track editor along the lines of CapCut: cut clips, apply hand-built templates, one-click remakes, re-edit. It served humans, and for humans a timeline is natural — you see tracks, you drag things, what you see is what you get. But the whole flow depended on people: templates were made by hand, remakes copied those templates, and there was no AI generalization. Change the topic and the workflow fell apart.

The second version added an AI content-orchestration workflow on top of templates. AI no longer started from an empty timeline; it filled content into existing templates and swapped components. New capability, new problems. Multiple tracks and components brought messy spatiotemporal constraints — position, size, overlap — and AI would get them wrong in ways that were hard to spot. What feels intuitive to a person is a burden to a machine. More fundamentally, every new style meant building another template by hand, so the product's ceiling was the size of its template library.

The third version started over. Instead of asking AI to operate a timeline designed for humans, tracks and clips were collapsed into an ordered sequence of scenes. AI writes scene code directly. Styling, TTS and the finished-video workflow all moved up into the skill layer and stopped being engine primitives.

The through line is simple: strip away human-centric interaction models step by step, let AI write the frame code, and keep the engine's job to turning time into frames.


The engine does one thing: time in, frame out

tick(t)  // give it a time, synchronously get that frame
Enter fullscreen mode Exit fullscreen mode

That is the whole API. Preview calls it. Export calls it.

Ticktoon demo: playback and export in the examples page

The practical consequence: the frame you see in preview is the frame that reaches the encoder. There is no "one renderer for preview, another for export", and no surprises that only show up at export time.

Three principles follow from that. Lightweight: no FFmpeg, no platform binaries, one browser environment is enough. Pure: the engine only maps time to a frame; styles, narration and the full video workflow live above it — the preview studio is just a viewer on top of the protocol. Efficient: one call per frame, rendered pixels go straight into the encoder; no screenshots, no process hops, no intermediate transcoding. Export time is mostly encoding time.

The second principle is the one that matters most. Once an engine starts "helping" with other things, the boundary does not hold.

Getting started takes one line:

npm install ticktoon
Enter fullscreen mode Exit fullscreen mode
import { exportComposition } from 'ticktoon/io';

const mp4 = await exportComposition(composition);
// returns ReadableStream<Uint8Array>
Enter fullscreen mode Exit fullscreen mode

How it compares

Remotion HyperFrames Ticktoon
Scene model React component tree HTML + CSS Canvas scene code
Preview Player + React runtime Studio Same tick(t) as export
Export path Headless Chromium screenshots + FFmpeg by default; WebCodecs also available in newer versions Headless Chromium screenshots + FFmpeg Same tick(t) + WebCodecs
Per-OS external artifacts A compositor package per architecture FFmpeg binary None

Three routes in one line each:

  • Remotion: React component tree → headless browser screenshots → FFmpeg assembly
  • HyperFrames: HTML + CSS → headless browser screenshots → FFmpeg assembly
  • Ticktoon: Canvas scene code → tick(t) fed straight to WebCodecs → MP4 muxed in the browser

The middle hop is the difference. Remotion and HyperFrames hand rendering to a browser page, then recover pixels via screenshots. Ticktoon makes the page itself the encoder's data source: pixels never pass through a screenshot and go straight into the encoder. That is why preview and export are the same function, why there is no FFmpeg, and why nothing has to be shipped per operating system.

Worth noting: newer Remotion versions also offer a WebCodecs path, but the scene input is still React / DOM. Ticktoon emits Canvas pixels, and its scene contract was designed from day one around "give it a time, synchronously return a frame".

This table describes architecture, not a permanent ranking; implementations evolve, so check each project's current docs.


The protocol: two arrays, no tracks

Some background first. In editors like CapCut or Premiere, the picture is organized around tracks: video, audio, text and sticker tracks stacked on top of each other, with each clip placed at a point on a track. Layering and keyframes hang off that system. It is the standard shape of video software — and Ticktoon's first two versions used it too.

The composition protocol has only two top-level structures:

Structure Order Rule
scenes ordered, contiguous each scene draws a full frame at its relative time
audio unordered a flat event list on the absolute timeline

No tracks.

Why remove them? Tracks exist to express layering, but neither picture nor sound has layering in that sense. The picture is a sequence where later strokes cover earlier ones; sound is a sum, with overlapping events added together in the mixer.

Titles, subtitles and stickers look like layers, but they are compiled into the scene that displays them. There are no extra layer types at runtime.

Scenes also carry no absolute start time. The compositor accumulates durations in array order, so changing one scene's duration cannot leave a gap or overlap elsewhere, and the author never has to do time arithmetic by hand.

For AI, this compresses the mental model from "tracks / clips / layers / keyframes" to "ordered scenes plus a piece of code that draws this frame". Tracks are intuitive for people; for a model they mean constantly computing time offsets and stacking relationships. Two arrays make the model's job much smaller — anyone who has built AI timeline orchestration knows how much that matters.


2D and 3D mixed, but one WebGLRenderer for the whole film

Rendering defaults to Canvas 2D. A scene receives the context and draws the current frame at api.t — charts, text, transitions, infographics all live here.

The entire sequence shares one scene canvas. Since determinism requires redrawing from scratch every frame, and the compositor copies the result into the output canvas within the same tick, there is no reason for each scene to hold its own. The arithmetic is worth doing: at 1920×1080 with the export pipeline's 2× scale, one canvas is about 33 MB; twenty scenes with their own canvases is 660 MB minimum. Sharing one means one allocation.

Three.js is not bundled into the main package. The host injects it only when a scene explicitly declares needs: ['three']. In this design 3D is a layer inside a Canvas scene: api.three({ rect }) returns a scene, a camera and a draw(ctx) that composites into that rectangle in paint order. Mixing 2D and 3D needs no extra tracks — draw order decides what is on top.

One easy-to-miss engineering detail: Chrome limits the number of WebGL contexts per page — 16, or 8 on Android — and force-reclaims older ones beyond that. Ticktoon uses a single WebGLRenderer for the whole compositor and renders each 3D layer into it via viewport and scissor. A scene can contain as many 3D panels as needed without hitting the browser limit, and scenes never receive the renderer instance, so cross-clip state pollution is impossible by construction.

New rendering capabilities face one gate: if existing ones can do the job, no new concept is added. WebGPU, when it lands, will reuse the same Three entry point rather than spawning a parallel system.


Export: WebCodecs encoding, Mediabunny muxing, all in the browser

Export uses no FFmpeg and no extra transcode. WebCodecs encodes; Mediabunny writes the MP4 container.

Encoding is quality-first by default: quantization parameter 20, with bitrate as a fallback that floats with the content. Static explainer frames save space automatically; motion-heavy sections get the bitrate they need. A fixed bitrate cannot serve both ends — it wastes bytes on simple frames and smears text on complex ones.

Audio is uniformly AAC-LC, 48 kHz, stereo, 128 kbps. The exact native AudioEncoder configuration is validated first; a WASM encoder is loaded dynamically only if native is unavailable, so the native path never downloads a WASM chunk. There is no Opus fallback and no external FFmpeg CLI call.

MP4 uses fastStart: 'reserve' to reserve the moov atom up front, writing to OPFS where possible; only a missing API or restricted permissions falls back to 1 MiB paged memory. Quota errors fail the export loudly instead of quietly eating memory.

The composition is schema-validated before export. An invalid composition raises an error rather than producing a broken video for someone to debug later.

There is also a set of export callbacks: progress, per-frame draw time, video encoder info, audio backend, storage backend, and the reason for any degradation. When something goes wrong, you can locate the exact stage instead of receiving a vague bad file.


Above the engine: how the skill layer is designed

The engine answers exactly one question: "what should the frame look like at time t?" Styles, TTS, word-level subtitles and the complete production workflow live in the companion repository, ticktoon-skill. It compiles an AI's structured output into a protocol-compliant composition, injects overlays like subtitles into their scenes at compile time, and hosts preview and export.

The core idea of the skill layer is controlling how much knowledge the agent has to load at each step. It is split into four layers, read on demand:

Layer Contents When it is read
SKILL.md Operating contract, recipe routing, red lines Every task
recipes/<id>/ Rules and skeleton for one kind of film After a recipe is chosen
references/ API manual and shared kits (pen strokes, charts, transitions) Whichever page is needed
storyboard.json This film's content The only file written by hand

The agent does not make films while holding a thick manual in its head. It loads only what the current step needs — less context, fewer mistakes.

Recipes: two implementation paths

The skill layer currently offers nine recipes: whiteboard handwriting, blackboard teaching, flash cut, flat motion graphics, crayon explainer, paper chronicle, breaking news, GDP race chart, and live-action footage montage. Each has its own layout language, pacing conventions and checks. The agent picks a recipe first, then writes the storyboard against its skeleton.

Inside recipes there are two implementation paths.

Params mode: a fixed template with fillable fields. Layout, colors and motion are locked; only content is editable. Breaking-news cards and footage montages fall here, with very stable output and little room to go wrong. In the footage montage below, shots, color grading and subtitle styling all live in the template — the agent fills in search intents and short on-screen lines:

12-frame QA contact sheet of a footage montage

Code mode: the agent writes the frame code at runtime. Paper chronicle and whiteboard explainers belong here. Each scene's picture is drawn live in scene.code — a map or a seal, just write it. The freedom is high and it leans on the model's ability.

The two paths serve two needs: choose params for stability, code for flexibility. The recipe sets the overall shape; the path decides how much freedom is left open.

These nine recipes are only examples. The recipe structure is open, and writing your own against the skeleton is not hard — what to draw and in what style is left to your own creativity.

The compile chain has six fixed stages: schema → resolve → plan → emit → check → assemble. The output is a single composition.json. Preview, frame annotation, frame extraction, determinism checks and MP4 export all start from it.


What it feels like in practice

A whiteboard explainer made with the whiteboard recipe; the image below is its pre-export QA contact sheet:

12-frame QA contact sheet of a whiteboard knowledge explainer

Seven complete films are on the showcase page, each with its storyboard source available for comparison — a paper-chronicle story, a whiteboard derivation, a breaking-news card, a flash-cut piece, a Pexels footage montage, a health explainer and a province GDP race. Every cover is a 12-frame QA contact sheet, so you can see what was checked, not just the finished film.

See them at ticktoon.github.io/ticktoon-skill/showcase/.


Try it

For anyone building AI video, the Ticktoon engine's advantages are concrete: change one line of code and preview instantly, with true WYSIWYG; no need to regenerate the whole video just to try an idea, so tokens go where they matter; a short render pipeline means fast export. Letting an agent try fast and converge fast is the rhythm AI creation actually needs.

Stars and issues are welcome, and the engine can be bundled straight into your own product.

Both repositories are Apache-2.0: commercial use, closed-source derivatives and redistribution inside your own products need no extra permission.

Top comments (1)

Collapse
 
shidongdi profile image
shidongdi •

Feedback, stars, and issues are all welcome — and if you try it, I'd love to hear how it goes.