Rendering Video From Code With Claude Opus 5.5: A 480-Frame Verification Checklist

2026-11-25来源 dev.toEnglish
Rendering Video From Code With Claude Opus 5.5: A 480-Frame Verification Checklist

There is a way to make video with an LLM that never generates a single frame of footage. The model writes one HTML file. A browser draws the frame at whatever timestamp you hand it. Playwright screenshots each one. FFmpeg stitches them together. The pixels are computed, not sampled.

I ran this end to end on claude-opus-5-5 with a 20-second explainer of a DNS lookup: two API calls, 480 frames, roughly eight and a half minutes to a playable MP4. All six automated checks passed. One frame was still broken.

That gap is the interesting part. What follows is verification: what the contract looks like, what to measure, what the measurements cannot tell you.

Computed frames versus generated frames

With a video generator, the output arrives as one indivisible artifact. A caption with a typo means re-rolling, and the camera move comes back different. There's no way to request that a phrase hold for exactly two seconds, or that an arrow shift 30px left at second three.

For mood and abstract transitions, those models are excellent. For something with structure — steps, labels, fixed ordering — you need an edit that touches exactly one thing.

Code changes the premise. The frame becomes a function of time. Element positions sit in f(t), playback is t from 0 to 20, and editing becomes recomputation instead of redo. Everything below is a consequence of that one property.

The interface: one HTML file, one time function

The whole pipeline rests on a single interface. The page must expose something like seek(t): given any moment, draw the frame for that moment.

This is where models fail by default. Left unconstrained, they hand back a page animated with CSS transitions. It looks right in a browser and it is useless for rendering, because the page never sits at a determinate time. Screenshots then either repeat or drift.

Everything else is plumbing:

Playwright walks the timeline. At 24fps, push every 41.7ms, capture a PNG each time.

FFmpeg encodes the sequence. 480 PNGs in, one MP4 out.

If React is more your register than raw canvas, Remotion's renderer runs the same loop — the Remotion repository is the reference implementation.

Frame 12 of the finished DNS explainer

Frame 12. Bottom right: the live time parameter. The four hops of a DNS query sit on one continuous timeline rather than four edited shots.

The same skeleton handles a different subject. This is a frame from a 46-second explainer of the twin paradox, drawn in canvas with no image assets at all.

A frame from a fully canvas-drawn relativity explainer

Paper grain, torn edges and the slight jitter are computed. No footage sits behind this frame.

Six constraints to put in the prompt

These came out of two calls. Drop any one and you rerun.

  • Pin canvas and rhythm up front. 1920×1080, 24fps, total duration. Give all three numbers; don't let the model choose.
  • Expose seek(t), ban browser-driven motion. No CSS animation, no requestAnimationFrame, no Date.now, no Math.random. Each frame must be uniquely determined by the value passed in.
  • Lock fonts. System fonts or base64-embedded only. A CDN font lands late and the first frame renders blank.
  • Variable-ize styling. Colors, sizes, spacing into one config object so a palette change is one edit.
  • Enumerate transition timestamps. Write the start and end second of each transition. Skip it and the model guesses, and the guessed rhythm is usually unusable.
  • Zero external assets. Nothing loaded from a URL. Draw it in canvas or SVG.

All six enforce one idea: time belongs to the code, not the browser. The counterintuitive part is that the model doesn't need richer description here — it needs tighter boundaries. The closer your prompt reads to an acceptance test, the likelier one pass is enough.

Budgeting for reasoning, not output

The first call returned after 164 seconds with finish_reason: length. 16,000 tokens spent, 3,636 characters out, 70 lines, cut inside a function called seg(). The <script> tag was never closed, so the file wouldn't open.

Here's what I got wrong. Of those 16,000 tokens, only about 3,600 characters reached the code. The rest went to reasoning. This kind of task can't be budgeted by output length; it has to be budgeted by thinking plus writing.

Raising max_tokens to 32,000 was the only change for the second call. Same prompt, same constraints. It came back in 211.4 seconds with finish_reason: stop, 251 lines, 11,022 characters, 22,218 tokens. The first attempt didn't fail on capability. It failed on my budget.

Two calls totaled roughly 38,000 tokens. On commercial API pricing that's noise; the expensive input is your attention.

Six checks before trusting a render

Every number below is from this run, not an estimate.

  • Frame count matches duration. 20s × 24fps = 480 exactly. One short and the tail flickers.
  • Resolution is the requested size. Canvas measured 1920×1080.
  • The contract is actually there. typeof window.seek returned function, not undefined.
  • No external dependencies. Queries for img, link and script[src] all returned empty arrays. The page renders with the network off.
  • Rendering is deterministic. Render the same timestamp twice, compare MD5 hashes. Identical frames mean the output is reproducible, which is what makes any of this debuggable.
  • No console errors, no failed requests. Clean log on the full 480-frame pass.

Timing, for calibration: rendering took 118.5 seconds, an average of 0.247 seconds per frame. Encoding took 14.4 seconds and produced 1.0 MB. Page load was 0.69 seconds.

Six green checks, and the file passed every automated standard I could think of. Then I watched all 480 frames.

The blind spot in all six checks

At second 8, two labels were printed on top of each other.

Two labels overlapping at the moment of a cross-fade

Left: second 8. Right: second 12. "Asking the root server" and "asking the authoritative server" were cross-faded in the same spot without clearing the first string.

The cause is mundane: the text swap used an opacity fade and never cleared the previous string from that region. The reason it matters is what it implies about the toolchain. No frame count, no error log, no pixel-hash comparison catches this. Each frame was correctly rendering a wrong picture.

That's the boundary worth internalizing. Automation proves a pipeline is consistent. It cannot prove the output reads well. The technical bar for this workflow is low, and the taste bar hasn't moved at all.

Three failures that raise no error

All three are silent — no exception, no red log, just a wrong result.

The page is animated by CSS. Symptom: 480 identical frames, or 480 different ones. Cause: the page doesn't hold a determinate time and the browser advances the animation on the wall clock. Fix: strip CSS animation entirely and draw from t only; grep the file before capture.

Fonts load from a CDN. Symptom: a blank first frame, or the typeface shifting between frames. Cause: capture starts before the font resolves. Fix: await document.fonts.ready, and pin system fonts in the prompt.

Frame count doesn't match duration. Symptom: a dark tail, or one flickering frame. Cause: 20s at 24fps is exactly 480. Fix: compute duration × fps and diff it against the file count in frames/ before encoding.

Where this workflow fits

Use it when you can decompose the subject into quantities on a timeline: a process, a mechanism, a product surface, a data story. You also need to read a stack trace, change one line, re-run, and accept that the first cut looks amateur.

Don't use it for live action, realistic footage, or anything carried by atmosphere. It's strong on structure and indifferent to texture.

One test settles it: strip the narration and see whether the visuals still make sense. If yes, structure is carrying the piece and this workflow serves it. If no, mood is carrying it, and a generator is the better tool.

Access is a one-line change. Point the client at a compatible endpoint instead of the vendor's:

https://api.crazyrouter.com/v1 

The model ID is claude-opus-5-5. CLI tools read it from an environment variable, SDKs take it as base_url at client construction. Either way it's one place. If you want the same endpoint to switch between Claude, GPT and DeepSeek without per-vendor billing and reconciliation, the pricing page carries the model catalog and current per-token tiers, and docs.crazyrouter.com/llms.txt has the endpoint plus the model IDs.

Making video used to be a craft gate: learn to cut, learn motion, learn sound, or don't ship. The gate moved. It now sits at whether you can turn an idea into quantities along a timeline, which is what people who write code do all day. The taste gate didn't move. The renderer will draw exactly what you specify — including the frame where two words print on top of each other.

The six repositories, in the order they appear

  • lemo-opuscar, 39 film styles: github.com/lemomo-ai/lemo-opuscar
  • awesome-opus5-5-videos, 301 clips plus the full prompt set: github.com/yihui-dev/awesome-opus5-5-videos
  • opus-video-prompts, working backwards from finished clips: github.com/joeseesun/opus-video-prompts
  • onetake, teardown of one-take product films: github.com/feitangyuan/onetake
  • HyperFrames, HTML animation to video rendering: github.com/heygen-com/hyperframes
  • Remotion Agent Skills: github.com/remotion-dev/skills

The first four are starting points you can copy. The last two are infrastructure, and most of the style libraries above run on top of them.

原文:https://www.a8q9.cn/en/article/rendering-video-from-code-with-claude-opus-5-5-a-480-frame-verification-checklis-0f6295.html

相关文章