The AI Cartoon Guide
Every tool, step and prompt I use to turn myself into a cartoon that talks, walks and dances, down to cleaning the edges around the images.
By Evan Kennedy · evanwkennedy.com/lab/dad-hat-side-quests · @dadhatsidequests
Free to use, copy and adapt. If it helps you make something, I’d love to see it.
The one idea
AI draws everything once, and code does the moving.
There’s no AI video in my videos at all. An image model draws a character, a set of faces, mouths and poses, and some backgrounds. Code picks which drawing shows on each frame and moves the camera. My walk-cycle video was over 2,000 frames made from something like 100 drawings. Even the dance video is drawn parts that code places, frame by frame, where a real dancer’s joints were.
That’s why the character stays on-model. Nothing is regenerated between frames, so nothing can drift. It’s the way 1950s TV cartoons were made: limited animation, a box of drawn parts, and good timing.
The whole process is six steps:
- The look: try a bunch of styles and pick one.
- The master: one drawing becomes the hero, and everything else is an edit of it.
- The voice: record it, clean it, and get every word’s exact timing.
- The storyboard: plan every panel and leave notes before anything is final.
- The build: final art, lip sync, then animate it in code.
- Make him move: a box of drawn parts that code assembles, for a walk or for copying a real dance.
You don’t need to write the code yourself. I describe what I want to a coding agent, and it writes the tools, runs them and measures the result.
What you need
| Tool | What it does | Cost |
|---|---|---|
| Claude Code | The coding agent that runs everything | Paid plan |
| Codex CLI | Runs ChatGPT’s image generation from the terminal, so images save straight into your project | The CLI is free. It signs in with a ChatGPT plan; I use Pro, so check what your plan includes |
| Whisper | Transcribes your voice with a time for every word | Free, runs on your computer |
| Rhubarb Lip Sync | Listens to your voice and picks a mouth shape for every moment | Free (MIT) |
| Remotion | Makes video from React code | Free for individuals and small companies, commercial use included. Bigger companies need a license, so check the terms |
| ffmpeg | Cleans audio, cuts images, mixes sound | Free |
| MediaPipe Pose | Tracks a dancer’s joints in a video (Step 6) | Free (Apache 2.0), runs on your computer |
| yt-dlp | Downloads a public video to use as a dance reference (Step 6) | Free |
The only things I pay for are Claude and ChatGPT. Any image model that edits from reference images should work; I use this one because it can save files directly into the project.
Install it
I’m on a Mac, so these use Homebrew. Your coding agent can translate them for Windows or Linux, or just do the whole setup for you.
brew install node ffmpeg uv yt-dlp
npm install -g @openai/codex
Run codex once and sign in with your ChatGPT account. Install Claude Code from claude.com/claude-code.
Rhubarb: download the latest release for your system from its GitHub page and unzip it anywhere. The Mac build I used is an Intel program, so on Apple Silicon it needs Rosetta:
softwareupdate --install-rosetta
Whisper and MediaPipe need no install if you have uv: your agent runs them with uv run --with … (see Steps 3 and 6).
Remotion: this creates the project. Pick the blank template. Then add its agent skills so your coding agent knows how Remotion works.
npx create-video@latest
npx skills add remotion-dev/skills
How to generate images
Run Codex with your reference images and the prompt, and ask it to save a named file:
codex exec --skip-git-repo-check -s workspace-write -i master.png - <<'EOF'
This is the approved character master (attached image 1). Keep EVERYTHING the same:
identical framing and crop, head size and position, outfit, background, style.
Only change the expression to: a warm happy smile, brows slightly raised.
Save the result as happy.png in this folder.
EOF
Each image takes about a minute, and four at a time works fine. Have your agent write a small batch tool that reads a list of jobs (name, reference images, prompt) and skips files that already exist. To redo one, delete it and run the batch again.
House rules that saved me a lot of pain:
- Every round gets its own folder (
drafts/v01/,drafts/v02/), with the prompts saved next to the images. - Check the pixel size after every batch. Sometimes one comes back a different size.
- Make contact sheets. Reviewing 12 images on one page is much faster than opening 12 files.
- Never send someone else’s art to the image model. If you like an artist’s look, describe it in words. My one exception is proportion guides: plain grey shapes I had drawn myself.
Step 1: Find the look
I gave Claude Code an image of myself (my Apple memoji) and had it work with ChatGPT to draw me in 14 styles, each as a head and a full body, from Cubist to ukiyo-e. Then I shortlisted, did a second round on the finalists, and picked one. I went with 1930s rubber hose.
Prompt template:
[Your description: skin, hair, facial hair, glasses, the outfit, anything that makes you you.]
Style: [the style, described as a technique: the medium, the line, the shading, what the proportions do].
Plain flat light background with no scenery, props, text, logo or signature. The character must read as the same person as the reference: [your 2 or 3 signature features] must be in every image. Commit fully to the art style: at a glance it must read unmistakably as that style, never as a generic cartoon. Likeness comes from [signature features], not from copying the reference’s construction.
The rubber hose entry, for example: “1930s rubber-hose cartoon: pie-cut eyes visible through the glasses, bendy noodle limbs without elbows, white four-finger gloves, round shoes.”
What I learned:
- Pick 2 or 3 signature features. Mine are the glasses, the beard and a plain black dad hat. If they’re in every image, the rest can go wild and it’s still you.
- Describe technique, not just a name. A weak style prompt drifts to a generic flat cartoon. Say what the medium does and what NOT to do. If your reference still wins, drop it and let the text carry the likeness.
- State proportions in head units, with named shapes: “head as tall as the body below it, bean torso, no shoulders.” Style names alone give you a normal adult body.
- When that fails, draw a guide. Have code make a plain grey proportion figure and pass it with the note “proportion guide, not a style reference.”
Step 2: One master, then only edits
Pick your best drawing and lock it. This is the hero.
Every time you ask for a new image, you literally get a new image. So from here on, nothing is a fresh generation. Everything is an edit of the master: “keep everything the same, only change this one thing.”
Faces
This is the approved character master (attached image 1). Keep EVERYTHING the same: identical 1024x1024 framing and crop, head size and position, [hat, glasses, nose, beard], sweatshirt, flat sky-blue background, the [style] with [line and shading]. The eyes stay [how they’re drawn] (they may change size or direction). The mouth stays [where it sits], drawn like the master’s. Brows may move. Only change the facial expression to: [a warm happy smile: a medium open smile with upper teeth, brows slightly raised].
I use about 9: neutral, happy, excited, surprised, skeptical, determined, frustrated, plus two held reactions (very happy, wink) that don’t talk.
Mouths
The mouths are drawn separately from the face, so one face can say anything. Draw a mouth chart: one image, all mouths at one scale.
A LIP-SYNC MOUTH CHART for this character: landscape 1536x1024, exactly 8 mouths in a 4-column x 2-row grid of equal cells, row-major order: 1 CLOSED (m/b/p: lips pressed together), 2 REST (a relaxed closed line), 3 SMALL (‘oo’ / ‘w’: a small round opening), 4 MID (‘l’ / ‘th’: half open), 5 A (‘ah’: wide open, teeth and tongue), 6 I (‘ee’ and most consonants: wide, teeth together), 7 E (‘eh’: medium open), 8 O (‘oh’: round open). Each mouth centered in its cell with plenty of empty space, nothing touching a cell edge. BACKGROUND: one perfectly flat solid [the color the mouth will sit on], no texture, gradient, face, labels, numbers or grid lines.
Two things that made a huge difference:
- One full set per attitude, not per face. In real cartoon pipelines, every sound is drawn once per attitude, because the corners of the mouth carry the mood. I started with three mouths per expression, and two-thirds of the talking sat on one mouth. Now happy and excited share a full smile set, and skeptical has a lopsided smirk set.
- Add an F/V mouth (teeth on the lower lip) for each talking face. It’s small, but you notice when it’s missing.
Putting a mouth on a face
Have the image model remove the mouth from each face, which gives you a mouthless twin:
Edit attached image 1 exactly: REMOVE THE MOUTH completely. Where the mouth (lips, teeth, tongue, its outline and any creases at its corners) was, the [beard] simply continues smoothly with its same color and shading. Keep EVERYTHING else pixel-identical. Change nothing but the mouth.
Compare the two images and code knows exactly where the mouth was. Then build every combination of face + mouth + eyes as a frame.
- Hang every mouth from one upper-lip line. Talking should only drop the jaw. When I centered the mouths, his whole mouth hopped on every sound.
- Keep the mouth under the nose, and measure its position from the nose, the same on every face. Smile creases will fool anything that looks at the difference alone.
- Draw blinks in code. A skin-colored lid over the eye, half and closed. Then one pair of blinks works with every face.
Poses
Same idea for the body. Write one shared paragraph that locks the head, framing and background for the whole set, then one line per pose:
Attached image 1 is the approved master: copy its head EXACTLY. Attached image 2 is the approved full body: use it only for the body design, ignore its pose. Frame: portrait 1024x1536, WAIST-UP, front view. The head is the same size and in the same place in every image of this set. The gloves and arms must NEVER overlap or touch the head; keep clear background between them. Background: one flat opaque color filling the whole image.
Pose: WAVE. The arm on the viewer’s right curves up and out, its open glove raised beside the head at eye height, palm facing the viewer. The other arm hangs relaxed at the side.
Then code erases the pose’s head, puts the talking head on top, and matches their size by the eye whites. Swaps are a quick pop with a 2-frame cross-fade.
Keep rules in numbers. “Thin rubber-hose arms” means something different every time, so mine are measured: arms and legs are 0.55 of his nose’s width, the same from shoulder to glove. A tool checks every drawing and fixes the ones that come back thick. Measure with something that never changes shape. I use the nose.
Walking and dancing
Poses are held drawings, which is right for talking. A body that walks or dances needs a rig: see Step 6.
Step 3: The voice
The recording drives everything, so it comes before any final art. Every cut, face and mouth is timed to it.
Record it
Just talk into your phone, close up, in a quiet room with soft stuff around you. Say the bad lines again and keep rolling. You’ll cut them later.
Check the file before you clean it. I wasted a whole recording on this:
- Don’t use AirPods. The take I recorded through them came out 24 kHz and 34 kbps with nothing above 8 kHz, and it was already denoised. It sounded pixelated, and no cleanup fixed it. Boosting the top only boosted the artifacts. I re-recorded.
- If your phone records stereo, use one channel. The two mics on mine partly cancel when summed: the mono mix lost 8 to 9 dB from 3 to 10 kHz. Use the left channel alone.
ffprobe -hide_banner memo.m4a
ffmpeg -i memo.m4a -af "pan=mono|c0=c0" -ar 48000 -c:a pcm_s16le raw.wav
Transcribe it
Whisper gives you every word with its exact timing. It runs on your computer, so your voice never leaves it.
On an Apple Silicon Mac:
uvx --from mlx-whisper mlx_whisper raw.wav --model mlx-community/whisper-large-v3-turbo --language en --word-timestamps True --output-format json --output-dir .
Anywhere else, pip install -U openai-whisper, then:
whisper raw.wav --model turbo --language en --word_timestamps True --output_format json
Cut it
Have your agent cut the bad takes using the word timings, then check it by ear.
- Whisper hears through stumbles. It read “Fourth, Claude tra… Fourth, Claude reads” as a clean sentence, so the transcript alone won’t show you a flub. My first cut got this wrong. Listen, and look for gaps in the energy.
- Whisper invents words in silence, usually repeating the last word in the room tone at the end. Delete those from the transcript.
- Cut where the word has actually died away. Whisper’s word ends can run up to 0.2 s early, and cutting there clips the word.
- Cap the pauses at about half a second.
- Fix a mouth noise with room tone. Copy a second of nothing from the same recording and lay it over the lip smack.
- Pickups: if you re-record one line, match its level and EQ to the take.
Then transcribe the final cut again, because the timings have changed, and fix that transcript by hand (names, tool names).
Clean it
This is the chain I use for a close phone recording. The boom comes down, the harshness eases, and the loudness lands at -14 LUFS, a good target for Reels and TikTok.
ffmpeg -i cut.wav -ac 1 -af "highpass=f=80:poles=2,equalizer=f=120:t=q:w=1.0:g=-6,equalizer=f=230:t=q:w=1.0:g=-8,deesser=i=0.4,acompressor=threshold=-22dB:ratio=2.5:attack=6:release=110:makeup=2dB,loudnorm=I=-14:TP=-1.5:LRA=11" -ar 48000 -c:a pcm_s16le vo.wav
For the most accurate loudness, have your agent run loudnorm in two passes: measure, then apply. If your room is noisy, add a light afftdn, but go easy. Too much denoise made one of my takes sound muffled, and I re-recorded that too.
Step 4: The storyboard
Claude reads the transcript and makes me a storyboard. I leave notes on every panel, and we go back and forth until I approve everything. This is the cheapest place to change your mind.
Prompt:
Here’s my script with word timings. Make a storyboard: split it into panels, one per idea, about 3 seconds each. Each panel gets the line, the shot (close, medium, wide, and whether the camera moves), what happens on screen, and what art we’d still need to make. It should still read with the sound off. Use only what our setup can do: held drawings, swapped poses, camera moves, stickers and sets. Make the first three seconds impossible to scroll past. Then build a review page with a still and a notes box for every panel.
- Keep the panels in one file (I use JSON) and generate the page from it, so changing a panel never means rebuilding by hand.
- Make real stills. Composite your actual draft art for each panel, even if it’s rough. You’ll catch problems you’d never catch in a text list.
- A notes box per panel is much better than one long message. A Claude Artifact works well for this: it can save your notes, and Claude can read them back.
- Budget new art here. Every panel’s “still to make” list is your shopping list for Step 5.
- Pick a world for each video, so it doesn’t look like a repeat. Mine have been a night studio, a vaudeville stage, and a frozen street.
Some real notes I’ve left, to show how specific they can be: “the neck is too long in profile,” “the sign should lean right,” “this reads as projected on the curtain, put him on stage full length.” My favorite was “he’s moonwalking,” which turned into a rule.
Step 5: The build
Once the storyboard is approved, it’s time for final art, lip sync, then animation.
Sets
Write one shared paragraph for every set so they match, and pull the palette from your character:
This is a painted BACKGROUND for a 2D cartoon. EMPTY SET: no people, no characters, no animals, no hands, no faces anywhere (characters are composited in later). Style: [your style’s background painting: outlines, shading, grain]. Lighting: [time of day, what’s lighting it]. Colors: [your palette as hex codes]. No text, no letters, no numbers, no logos, no signatures, no watermarks, no borders. Attached image 1 is our own character, given ONLY as a reference for line weight and how the painting is finished: do NOT draw him or anyone else in this image.
Portrait 1024x1536. [The set. Say where the character stands: “keep an open patch of floor in the middle of the image.”]
- Anything that goes in front of the character (a desk, a lamp post) gets painted on flat magenta and keyed out.
- For depth, split a set into layers (sky, houses, foreground props) and move them at different speeds.
- Leave out lettering. Image models misspell things. Add any text in code.
Stickers and props
Stars, sweat drops, impact bursts, question marks. A sheet of 9 at once keeps them in one style:
Square 1024x1024. A sheet of 9 separate cartoon effect stickers in a 3 by 3 grid, each centered in its own cell with lots of empty magenta between them (no two drawings touch, nothing crosses a cell edge). Row 1: [three stickers]. Row 2: [three]. Row 3: [three]. BACKGROUND: perfectly flat solid magenta #FF00FF everywhere around the drawings, no gradient, no texture, no shadow, no glow, so it can be keyed out. No faces, no borders, no signature.
Clean the edges
This is the step everyone skips, and it’s the difference between “cartoon” and “bad sticker.” It has its own section below: Cutting out images without a fringe.
Lip sync
Rhubarb listens to the voice and picks the mouth for every moment. Give it the transcript as well, which makes its timing much more accurate.
rhubarb -f json --extendedShapes GHX -d transcript.txt -o rhubarb.json vo.wav
It returns timed letters, the classic cartoon mouth shapes. Map them onto your 8 mouths plus F/V:
| Rhubarb | Sound | My mouth |
|---|---|---|
| A | m, b, p (lips shut) | closed |
| B | most consonants, teeth together | I |
| C | eh, ae | E |
| D | aa (wide) | A |
| E | ao, er | O |
| F | oo, w | small |
| G | f, v | F/V |
| H | l | mid |
| X | silence | rest |
Timing: the mouths sit right on the sound. Shift them 1 frame early and stop there. I started at 2, and it felt out of sync even though each frame looked fine.
Use phonemes for English. I first tried the anime approach of flapping the mouth to the loudness, and it measured 7.3 mouth changes a second against 4.6 syllables a second, and it never closed on m, b or p.
Cast it
The acting is plain data: a file where you say which face, pose, shot and sticker goes with which line. Everything is anchored to words, not times, so it survives a re-cut.
{
"lines": [
{ "text": "Let me teach you how I create these animations using AI.", "expression": "excited", "pose": "present" },
{ "text": "That one drawing becomes the hero.", "expression": "happy", "at": "hero" }
],
"shots": [
{ "at": "Second", "scene": "hero", "size": "close", "move": "push", "in": "whip" }
],
"fx": [
{ "at": "Whisper", "sticker": "star", "x": 800, "y": 400, "size": 160, "sound": "pop" }
]
}
- Faces snap on a word, 2 frames before it starts. “He’s got BIG eyes” goes surprised on “big,” not at the start of the line.
- Cuts land 2 frames before a word. That reads as on the word.
- A held reaction (a wink, a laugh) fills the whole pause after a line.
Animate it
The video is literally code. A Remotion composition reads the tracks and, for each frame, works out which drawings to show and where the camera is. The camera, the captions, the mob, all of it.
The layers, back to front:
- The set, with slow ambient loops: steam, flickering lamps, a ticking clock.
- The body, then the talking head on top, with a slight idle sway and a nod per phrase.
- Anything in front of him.
- The stickers.
- A color grade over the picture.
- Captions, then a little film grain over everything.
The small things that make it feel made by a person:
- Line boil. A slight wobble on the outlines, re-seeded every other frame. SVG’s
feTurbulenceplusfeDisplacementMapdoes it. - Pops. When a face or pose changes, it starts 4 % bigger and settles, with a 2-frame cross-fade.
- Whips are one continuous pan across both shots, blurred by its speed. Sliding one shot out and the next in showed black frames.
- Parallax. Each layer gets the camera’s move scaled by its distance.
- Never moonwalk. When he really walks, either the floor moves under him with the camera tracking, or he crosses a still background. Walking in place in front of a scrolling backdrop with a still floor looks like Michael Jackson.
- Captions: word by word, at most 4 words at a time, the current word in a different color, inside the app’s safe zone. Keep his face above them.
- Don’t bounce a person who’s sitting and talking. I tried a steady bounce. It made no sense.
Sound
- Voice first. Effects should peak around your voice’s peaks, not over it.
- Effects: your agent can synthesize simple ones (pop, whoosh, thud) with code. For real-world sounds like applause, use CC0 or public-domain recordings. Wikimedia Commons has plenty, and its file pages list the license.
- Whooshes get old fast. Make them soft and few.
- Music has two copyrights: the composition and the recording. Beethoven’s notes are free, but a modern orchestra’s recording of them usually isn’t. The cold open of my explainer uses the William Tell gallop from a U.S. Marine Band recording, listed as public domain. Keep a note of where every sound came from.
- Time music to the picture. That gallop’s phrase runs 1.585 s and my cold open is 1.6 s, so it fills the shot and the record scratch kills it on the next downbeat. Sometimes the numbers just line up, so go looking.
Render it
A full render of my 97-second explainer is about 14 minutes. Ask your agent to set it up like this, and you’ll rarely wait that long:
- Render one clip per shot and cache each by a fingerprint of everything that draws it. Change one face, and only those shots re-render.
- Run three browsers at once. On a heavy look, one pass took 38 minutes and three parallel took 14.
- Mix the sound separately with ffmpeg from one list of cues. A sound-only change then takes seconds. Swapping all the music in my explainer took 3 seconds.
- Add a draft mode at half size for quick checks.
Then measure it: 1080×1920, 30 fps, about -14 LUFS, peaks under -1 dB. Watch it on your actual phone with the app’s buttons over it.
Step 6: Make him move
A talking head only swaps whole drawings. A body that walks or dances needs far more frames than you can draw, and drawing every frame doesn’t work: each drawing is a new generation, so he grows and shrinks. His eye whites changed size by ±8 % across my first walk. Moving drawn parts with math kept his size, but he moved like a robot.
What works is the swap rig, the cut-out animation of old cartoons. The image model draws every part once, including a library of bent arms and legs. Code only picks, places and turns those drawings. It never draws anything itself, so his size can’t drift (±0.4 % on my walk), and the limbs look hand-drawn because they are.
I’ve used it two ways: a walk in profile, and a front-facing rig that copies a real dancer from a video.
The parts
Every rig is the same box of parts, all drawn at one scale:
- The parts that never bend: head, torso, gloves, shoes. Each one has an opening: the collar where the neck goes in, the glove’s cuff, the shoe’s ankle. A limb goes into its opening, and code draws the opening’s front rim again on top. That’s what makes the joins read as one character instead of stickers.
- A limb library: one arm and one leg, drawn bent by different amounts.
Put this paragraph at the end of every rig prompt:
STYLE: exactly the character’s style from the attached drawings, the same outline weight. BACKGROUND: one perfectly flat solid white (#FFFFFF) everywhere, no gradient, glow, shadow, ground line, text, labels or numbers. The image must be a normal opaque RGB picture on solid white: NOT a transparent background, no glow, no halo. Keep the canvas landscape 1536x1024.
The parts sheet, front view (for a walk, ask for one head, torso, glove and shoe in SIDE VIEW facing right instead):
Make a CUT-OUT ANIMATION PARTS SHEET of the character in attached image 1 (his approved full body), seen from the front, for a cut-out rig where code attaches the arms, legs, gloves and shoes. Draw 5 separate pieces in one row, each the SAME SIZE as in image 1, nothing touching:
- HEAD from the front, with a short neck under it, cut straight across at the bottom.
- The same HEAD turned three-quarters to the viewer’s right.
- TORSO from the front: no head, neck, arms or legs. Smooth rounded shoulders where code attaches the arms, the collar on top with its dark empty neck opening.
- The same TORSO turned three-quarters to the viewer’s right.
- The same TORSO in profile facing the viewer’s right.
Then a second sheet for the gloves and shoes: 6 gloves (open, fist, fist from the side, pointing, edge-on, the back of the hand), each with its cuff and dark opening at the top, and the shoe from the front and from the side, each with its dark ankle opening.
The limb library
Have code draw grey guides: a hose of fixed length, bent by a different amount in each slot. The image model redraws each guide in place as the real limb.
Attached image 1 is a PROPORTION GUIDE, not a style reference: redraw each of its 12 grey shapes EXACTLY in place (same position, length, thickness and curve) as his ARM: a THIN rubber-hose arm, no thicker than the grey shape, in [his sleeve] like the arms in attached image 2. The end at the top-left of each shape is the shoulder; the other end is the wrist, where a glove will cover it. No elbow joint: one smooth bent hose, bending exactly as much as the guide. Do NOT draw gloves, hands, a body or anything else.
Legs are the same prompt, with the hip at the top and an open trouser cuff at the bottom where the shoe goes.
- Space the drawings by bend, not by length. A fixed-length hose’s bend jumps just below straight, so make the steps small there. My walk has 14 legs and 9 arms. The dance has 12 arms, from hanging straight down to a hairpin with the hand up at the shoulder, and 7 legs.
- Make the guides thin. The model draws limbs about 25 % thicker than the guide, so I draw the guides at 72 % (legs) and 85 % (arms).
- Take each limb’s ends and bend from its guide, not by measuring the drawing. A line through a thick bent hose cuts the inner corner: bent arms measured up to 35 % short.
- Ask for 3 tries and keep the one that measures best.
Walking
Code builds a 2-step cycle. 18 frames per step at 30 fps reads as a relaxed walk.
- Lock the feet. The planted shoe pivots on its heel, then on its toe, and never slides.
- Pick the leg whose bend fits the distance from hip to ankle, eased over about 11 frames. Turn it rigidly, and allow only a tiny stretch along its length (0.94 to 1.05) so the ankle lands. Picking by length alone popped the knee 26 px every step. This got it under 7.
- Arms swing opposite their legs and bow with the swing. The far arm lags 3 frames and bows half as much. Without that, the arms mirror each other like a robot’s.
- A 3/4 head, turned toward the walk with its eyes on the camera. A front-facing head on a profile body looks pasted on.
- Never moonwalk (see Animate it). To stop, land on a frame where both feet are down, hold it, then turn him to the camera.
The rig writes one file: for every frame, the list of images to draw, each with a position and a turn. Remotion just places them.
The whole story, with every measurement, is in The Walk-Cycle Playbook.
Copying a dance
The same rig turned to face the camera, driven by a real dancer instead of a walk cycle. Pick a dance (trend dances are made to be copied) and find a video of it. The video is only a motion reference. Code reads where the dancer’s joints are; the image model never sees it.
1. Get the video. yt-dlp downloads a public post. Then convert it to a steady 30 fps so frame numbers line up with your video.
yt-dlp -f "bv*[ext=mp4]+ba/b" -o ref.mp4 "<video url>"
ffmpeg -i ref.mp4 -r 30 -c:v libx264 -crf 16 -c:a copy ref30.mp4
2. Track the dancer. Have your agent run MediaPipe’s Pose Landmarker (the heavy model) on every shot. It gives 33 body points per frame, plus a rough depth. Find the cuts first (ffmpeg’s scene detection) and track each shot fresh.
- Two dancers close together: it finds one and hops between them. Track the left and right halves of the frame separately.
- Joints it can barely see jump. Fill short gaps (up to 6 frames) from the frames around them and smooth the rest. That took the gloves’ jitter from 31 to 37 px down to 4 to 11.
- Close-ups and blurred hands don’t track. Key those by hand: a few glove positions per move, eased between.
3. Copy angles, not positions. He’s a cartoon: his head is about three times a person’s, his arms are short and his gloves are huge. So code copies how the dancer is turned and bent, onto his proportions:
- The torso leans from the hips to the shoulders. It turns front, 3/4 or side by how wide the shoulders look, against how wide they are when that dancer faces the camera in that shot.
- The head turns by where the nose sits between the ears, and tilts with the line between the ears.
- Each arm and leg is the drawing that best fits the tracked distance and bend, turned rigidly, flipped for the other side, then stretched just enough to land the glove or shoe. Rubber hose lets arms stretch from 0.7 to 1.15.
- Hands near the head land on his head. Measure them from the dancer’s head, not the shoulder. Otherwise hands on a cap land on his face.
- One size per shot. Following the tracked body shrank him 9 % every time the dancer bent forward. Stand his feet where the dancer’s feet are.
4. Layer the arms.
- Each arm is drawn right under its own glove. When a glove comes in front of his face, its arm comes in front too. A glove in front with its arm behind the head is the mistake to look for.
- When an arm crosses his face, try every arm drawing and keep the one whose hose stays off the head.
- The glove turns with the end of the hose, at most about 7° off it. The cuff’s opening is barely wider than the hose, so any more shows the hose’s edge outside the cuff.
- An arm goes in front of the body or behind it by the wrist’s tracked depth.
5. Hold the background still. The original camera pushes in and pans. Copying that made the set swim, so keep the set still and his position steady on it.
6. Two of you? Drive both from the same dancer, so they move identically, each in his own spot.
7. Check it side by side with the original, at full and half speed. Mistakes that hide in one clip are obvious next to the original.
Post it with the song from the app’s music library, not baked into your file. If you add an intro, start the song that much earlier so the beat still lands on the dance.
A starter prompt for your agent. Attach your parts sheets:
I want my cartoon to copy the dance in ref30.mp4, frame for frame, with a front-facing swap rig. The attached sheets are drawn once, and code must never redraw them: heads (front, 3/4), torsos (front, 3/4, side) with a collar opening, gloves and shoes with openings, and a library of arms and legs from straight to fully bent, each drawn over a guide whose ends and bend are in guides.json.
- Find the cuts and track the dancer with MediaPipe Pose Landmarker (heavy), shot by shot. Fill gaps of up to 6 frames, smooth the rest, and print each joint’s jitter.
- Cut the sheets: key the white, split the pieces, take each limb’s ends from its guide, find each opening.
- Every frame, copy the dancer’s angles onto my proportions: lean, torso turn, head turn and tilt, and for each arm and leg the drawing that fits its distance and bend, turned rigidly and stretched to land the glove or shoe. One size per shot, feet on the ground. Hands near the head are placed on my head.
- Layering: each arm just under its own glove, then the cuff’s front rim on top. Route arms around my face. Gloves within 0.12 radians of the hose’s end.
- Write the frames as JSON (images and transforms) for Remotion, keep the background still, and render my version side by side with the original.
Measure what you change, and show me stills before any long render.
Cutting out images without a fringe
You can draw the best character in the world, and if it has a blue outline on a dark set, it looks cheap.
Why it happens. Image models smooth their edges: the pixels around a drawing are a blend of the drawing and the background. A normal key only asks “is this pixel the background color?” The blended pixels say no, so they stay, still carrying the background’s color. My character came out of a sky-blue background with 2,000 to 3,700 bluish pixels around him per drawing, invisible until he stood on a night set.
The fix has three parts:
- Key on a color that isn’t in your drawing. Flat magenta (
#FF00FF) unless your character is pink. - Throw away specks, the tiny islands of leftover background.
- Un-mix the rim. For each edge pixel, work out how much of it is drawing and how much is background, make it that transparent, and subtract the background from its color.
Ask for the right image. Put this in every prompt, because the model loves to add a soft glow:
The background is ONE flat opaque magenta color (#FF00FF), edge to edge: no gradient, no floor, no cast shadow, no glow (it will be keyed out). The image must be a normal opaque RGB picture, NOT a transparent background.
The script. Save this as clean_edges.py:
# clean_edges.py: cut a drawing off a flat background and clean its edge.
# Usage: uv run --with numpy --with scipy --with pillow clean_edges.py in.png out.png [background hex, default ff00ff]
import sys
import numpy as np
from PIL import Image
from scipy import ndimage as ndi
src, out = sys.argv[1], sys.argv[2]
hex_ = sys.argv[3] if len(sys.argv) > 3 else 'ff00ff'
key = np.array([int(hex_[i:i + 2], 16) for i in (0, 2, 4)], float)
TOLERANCE = 110 # how close to the background color counts as background
SPECK = 150 # smaller islands than this many pixels are noise
RIM = 3 # how many pixels in from the edge get repaired
rgb = np.asarray(Image.open(src).convert('RGB')).astype(float)
# 1. the key: everything close to the background color is clear
solid = np.sqrt(((rgb - key) ** 2).sum(-1)) > TOLERANCE
# 2. specks: drop tiny islands of leftover pixels
labels, n = ndi.label(solid)
sizes = ndi.sum(solid, labels, range(1, n + 1))
solid = np.isin(labels, 1 + np.nonzero(sizes >= SPECK)[0])
# 3. the rim: pixels near the edge are a blend of the drawing and the background.
# For each one, work out how much of it is drawing (t), then remove the background from its color.
depth = ndi.distance_transform_edt(solid)
rim = solid & (depth <= RIM)
inner = solid & (depth > RIM)
_, (fy, fx) = ndi.distance_transform_edt(~inner, return_indices=True) # the nearest clean pixel of the drawing
fg, c = rgb[fy, fx][rim], rgb[rim]
v = fg - key
t = (((c - key) * v).sum(-1) / np.maximum((v * v).sum(-1), 1)).clip(0, 1)
un = (c - (1 - t)[:, None] * key) / np.maximum(t, 0.05)[:, None]
w = ((t - 0.6) / 0.3).clip(0, 1)[:, None] # thin slivers go wrong when un-mixed: use the clean color there
rgb[rim] = (w * un + (1 - w) * fg).clip(0, 255)
alpha = np.where(solid, 255.0, 0.0)
alpha[rim] = 255 * t
alpha[alpha < 8] = 0
Image.fromarray(np.dstack([rgb, alpha]).round().astype(np.uint8), 'RGBA').save(out)
print(f'{out}: {int(solid.sum())} solid pixels, {int(rim.sum())} on the rim repaired')
Run it:
uv run --with numpy --with scipy --with pillow clean_edges.py drawing.png drawing_clean.png
Test it on your darkest set, zoomed in. A plain key left 2,816 magenta-tinted pixels around one of my figures. This script left 0. If your drawing has a very soft or fuzzy edge, try a larger RIM.
Problems I ran into:
- The model ignores your background. One sticker came back on black, twice, with magenta requested both times. Cut those by shape instead: find the drawing’s outer outline, fill it in, and use that as the mask.
- It returns a transparent image with a glow. The sentence about “a normal opaque RGB picture” in the prompt above stopped most of these.
- Keyed images that aren’t really clear. One came back “keyed” but with pixels at alpha 253, which show as a faint box. Check for it.
- White background, white gloves. A global key punches holes in them. Fill from the image’s edges instead, so enclosed white stays. Better yet, use magenta.
- Sticker sheets split badly. The dot of a question mark is a separate shape. Assign each shape to the grid cell its middle is in, instead of keeping the largest shape.
- ffmpeg
colorkeytwice in a row keeps only the last alpha. Doing two keys in code avoids this. - Mouth charts go on the color they’ll sit on. Mine are drawn on the beard’s exact brown, so any leftover edge blend just matches the beard.
Hand this to your coding agent
A starter prompt for the whole pipeline. Attach your master drawing, and change the details:
I’m making short vertical videos (1080×1920, 30 fps) hosted by a cartoon version of me, in my own voice. The rule: AI draws everything once, and code does the moving. No AI video. Set up a project with Remotion and these tools, using
codex execfor image generation (always as edits of the approved master), Whisper for word timings, Rhubarb for lip sync and ffmpeg for audio:
- A batch image tool: a JSON list of jobs (name, reference images, prompt). Skips existing files, runs 4 at a time, saves each round in its own
drafts/vNN/folder.- A chart cutter: splits a mouth chart into separate mouths at one scale.
- An edge cleaner: keys a flat background, drops specks, un-mixes the rim pixels so there’s no color fringe.
- A frame builder: every face + mouth + blink combination, with each mouth hung from that face’s upper-lip line and blinks drawn in code.
- Lip sync: takes
vo.wavand its transcript, runs Rhubarb, writes a per-frame mouth track with mouths 1 frame early.- A cast file (
expressions.json): lines with a face, pose and trigger word; shots; stickers. Everything anchored to words and resolved to frames.- A Remotion composition that plays all of it: set, body, talking head, foreground, stickers, grade, word-by-word captions, grain. Camera moves: drift, push, pull, snap, and whip as one continuous pan. Slight idle sway, a nod per phrase, a line boil, and a 4 % pop on swaps.
- A render command: one cached clip per shot, 3 browsers at once, sound mixed separately by ffmpeg from one cue list, plus a half-size draft mode.
Later, when he needs to walk or dance: a swap rig (Step 6 has its own starter prompt).
Measure what you can: image sizes after each batch, mouth changes per second, final loudness (-14 LUFS). Show me stills before any long render. Don’t make anything final until I approve it.
Rules I work by
- Nothing is final until you approve it. Your agent will happily move on. Review every round.
- Draw it once. If something could drift, it shouldn’t be regenerated.
- Measure instead of squinting. “Thinner arms” is a guess. “0.55 nose widths” is checkable.
- Turn every note into a rule. When something’s wrong once, write it down in a file your agent reads every session, so it’s never wrong twice. Mine is called
AGENTS.mdand it’s the most valuable file in the project. - Listen to the audio yourself. Your agent can measure it, but it can’t hear it.
- Keep your raw recordings private. Mine stay on my machine, out of the code repository.
Made by Evan Kennedy. More builds in the Lab: evanwkennedy.com/lab.

