Type that the person on camera physically touches: pressed flat by a palm, shoved off
screen, lifted, swatted. Everything is local and free: hand tracking and the hand matte
are numpy/Pillow, the titles are PNGs animated by box/x/scale keyframes in an
hn4a-compositor spec (format and commands in hn4a-compositor).
1. Cut and find the gestures
- Trim to the take first (frame-accurate re-encode:
-ss A -to B -c:v libx264 -crf 16). - 2 fps contact sheet of the whole source to find takes, then a 6 fps sheet of the chosen one to find each gesture's first and last frame. Write the cue frames down.
- One gesture per title. A push-down needs a few frames of the hand held still at the top so the title can land before the push starts.
2. Track the hand (free)
By default, python-track-face-and-hands on the trimmed take: both hands' palms and
lowest points, the face, the person matte and a hands-only cutout, per frame, in
track.json. The moves in section 5 read it. The skin threshold below is the fallback
with no model, for one hand against a plain background.
Pull every frame at 640 px wide (ffmpeg -vf scale=640:-1 f_%03d.jpg) and threshold skin:
skin=(R-G>28)&(R>110)&(R-B>35)&(G>60)
- Mask out anything skin-coloured that isn't the hand (posters, wood, the face) by rectangle, and limit to the side of frame the hand works in.
- Per frame, per hand region: use percentiles, not min/max (98th pct of y for a palm's lower edge, 99th pct of x for a palm's leading edge, 2nd-98th pct of x for its centre).
- Smooth: 5-frame moving average on the edge, 9 on the centre, and
np.maximum.accumulatefor a push that only goes one way. - Contact sheet with the numbers drawn on before trusting them. Lighting changes and a camera reframe mid-take break the threshold: re-check after any reframe.
3. Hand matte, so the hand stays in front
With the tracker, hands_cutout.webm is this matte already (the hand landmarks' hull,
dilated 31 px, inside the person matte). With the skin threshold: full-res frames for the span the title is near the hand, the same skin mask,
MedianFilter(5), MaxFilter(5), GaussianBlur(1.5), put on the frame as alpha, then
ffmpeg -framerate 30 -i hand/f_%03d.png -c:v libvpx-vp9 -pix_fmt yuva420p -crf 18 -auto-alt-ref 0 -g 6 hand_cutout.webm.
Layer order: footage, title, hand cutout (same start, trim 0, fit: cover). Look at a
masked frame on magenta before using it. Pay for birefnet-matte only if the skin mask
fails (sleeves the colour of skin, busy backgrounds).
4. Titles as PNGs
Render each title to a transparent PNG at 3x (Pillow), cropped to its content, and give
the image layer fit: fill so box keyframes stretch it: that is what makes a squash.
Equal-width lines: render each line, resize to the same width, stack.
5. Motion
Squash under a push-down. Per tracked frame: top sits just below the palm
(top = hand_bottom + gap*(1-p)**0.5, gap ~28 px at 1080p, closing to contact as it
flattens), height falls from its natural height to ~22 px, width grows a little as it
flattens (squash and stretch, w = W*(1+0.32*q**2), so the flat strip shows past the
palm). Let the squash run ahead of the hand: q = min(1, p/0.6) flattens it with 40% of
the push left. Linear keys, one per frame. Pop in with scale 0.88 to 1.03 to 1 over
0.24 s as the hand settles at the top; fade out over ~0.12 s the frame the hand lands.
Shove off. Place the title just past the palm's leading edge before the push. From
the contact frame: x keys that keep the title ahead of the palm (match the palm's
measured speed for the first 2-4 frames), then in ease off screen (~1400 px over
0.34 s), with rotate to ~12-16 deg, scale to ~1.3, y lifting ~100 px, blur to ~8 px.
transformOrigin at the side being pushed.
Moves read from the tracker. Write references/moves.md's module into the job's
scripts/ as moves.py, as is; it turns track.json into per-frame keys:
- Hero word squashed to the floor by both hands (
squash_under_hands): contact = the mean of the hands' lowest points, top = max(the word's top, contact), p = its progress to the floor, q = min(1, p / 0.65), h = h0(1 − q) + 22·q, w = w0(1 + 0.38q²), the bottom held. Start it at the top of the downward push, not before: hands resting low at the start flatten it at once. When the hands blur out of tracking mid-push it carries on at their last speed. Exit with a splat about 0.1 s after it is flat; squash, stamp and splat sounds. - A title glued to the side of the head (
follow_face): its x and y ride the face centre every frame; it flies off the way the hand sweeps at the frame the palm crosses its edge. - A title stretched between both palms (
stretch_between_palms): its box runs from one palm's x to the other's, its height scaled to keep its area. - Words dropped onto the head, bouncing, landing on
head_top; things rising out of the mouth from thenose/chinpoints. - Objects popping from each hand, then converging where the next title bursts out; a brand character riding a palm or hopping onto a title.
- Opening: one big word in the centre over the speaker, then the first phrase stacked on one side of the head and the next on the other, both flying out sideways before the hero word.
Titles over the face sit under the hands cutout; everything behind the person passes
python-check-title-occlusion. Type that lies on a surface (a word on the desk the
hands slam, a title on the wall behind) goes in a plane group
(hn4a-compositor-perspective-planes), keyed from the tracked surface, with the
person cutout over it.
6. Look
What tends to land, and what doesn't:
- One bold typeface (a heavy display weight, tight caps), one flat colour, one solid hard offset shadow in a brand accent. Small kicker line above a big line, same width.
- Don't stack effects (textured display fonts plus outlines plus offset strokes reads as busy), don't put titles in boxes or cards, avoid stretched type and thick sticker outlines, and avoid plain clean type with no treatment (reads as boring).
- Take the palette from the brand's site, not just its logo folder: read computed styles in the browser for fonts and colours.
- Show two looks at most, on the real footage.
7. Review and render
- Stills at landing, mid-squash, flat, before the shove, at contact and mid-flight: check the title isn't covering the hand and the shove keeps the title ahead of the palm.
- Put the looks to the person with
review_choose, each look's.jsonspec an option's file, played live; add its rendered MP4 to the same option when you have one. - Render with
hn4a-compositor render; check frame count and a contact sheet. - If hn4a goes offline mid-review, the review's live players stop; render a preview another way and say so.
Related
python-synth-sfx-for-motion-graphics for pops, squashes and whooshes cued to these
moves.


