Make a looping explainer video with Claude
This is how the CPU vs GPU reel was made. There was no video editor and no AI video model. Claude wrote one web page that draws every frame, and a small script that records it. The prompt below sets that up for any topic you want to teach.
How to use it
- Install Claude Code and ffmpeg, then open Claude Code in an empty folder. It will install the browser tool (Playwright) itself when it needs it.
- Copy the prompt, fill in the two lines in square brackets, and paste it in.
- Read the plan it shows you and change anything you don’t like before it writes code. That is the cheapest moment to steer it.
- When it shows you the contact sheet, point at what looks wrong in plain words. It took me one round of notes to get from the first draft to the reel.
The prompt
Make a short looping explainer video, entirely in code. No video editor and no AI video model. Topic: [WHAT YOU WANT TO EXPLAIN, for example "CPU vs GPU"] The one idea to show: [ONE SENTENCE, for example "a GPU wins when a job splits into many small parts, a CPU wins when each step waits for the last"] How to build it: 1. Plan first, and show me the plan before you write any code: the one idea, two or three scenes that prove it by showing it happen (a race, a before and after, a counter), the few words on screen, and the length (10 to 15 seconds). Wait for my OK. 2. Write one HTML page with a 1080x1920 canvas. A single function draw(t) paints the whole frame for the time t in seconds. Nothing else moves: no CSS animations, no timers, no randomness without a fixed seed. Expose it as window.__seek(t). Keep every timing in one object at the top of the file. 3. Make the last half second fold back into the first frame, so the video loops without a jump. 4. Keep everything that matters inside x 110 to 930 and y 210 to 1560, so the Instagram interface does not cover it. No text smaller than 26 px. 5. Write a render script: open the page in headless Chromium with Playwright at 1080x1920, call window.__seek(frame / 60) for every frame, save each as a PNG, then encode them with ffmpeg as H.264, 60 fps, yuv420p. 6. Before the full render, save six still frames spread across the video into one contact sheet and look at it yourself. Fix anything that overlaps, is cut off or is hard to read, then show me the sheet. 7. Render the video. Tell me the file path, the length and the frame rate. Style: a dark background, two or three colours, rounded cards with a soft top-to-bottom gradient, and one glow on whatever is winning or active. Draw every picture in code, from shapes or a 32x32 pixel grid. Do not download images. Sound: leave it silent unless I give you a music file. If I do, mix it in at -14 LUFS.
Why it is written this way
- One function draws everything. Because each frame depends only on the time, frame 300 looks the same every time you render it. That is what lets a script record the page frame by frame, at a steady 60 frames a second, on any computer.
- Claude checks its own stills. It can’t watch a video, but it can look at pictures. Six frames on one sheet is how it catches text that overlaps or runs off the edge before you do.
- The plan comes before the code. A 12 second video only has room for one idea. Agreeing on that idea first saves you from a pretty video that explains nothing.
What the reel shows
Painting a picture is 1,024 small jobs, and none of them depends on another. A GPU has thousands of small cores, so it can paint every pixel in one round. A CPU has a few fast cores, so it needs hundreds of rounds.
Then the job changes to nine steps, where each one waits for the step before it. Now only one core can work at a time, and a single CPU core is faster than a single GPU core, so the CPU finishes first.
Running an AI model is billions of small sums that can happen at the same time. That is the first kind of job, which is why AI runs on GPUs. The times in the reel come from the demo itself and are not a benchmark.
What to expect
The first draft is rarely the final one. Plan on two or three rounds of notes. Code is good at charts, counters, grids and simple shapes, and poor at realistic people, so pick an idea you can show with shapes.