Log in
TechniqueBy HypernaturalVersion 1, updated

Matte a talking head

hn/python-matte-a-talking-head

Cut a presenter or talking head out of their video for free on this computer with Robust Video Matting (RVM): a soft, steady alpha that follows hair and holds from frame to frame, written as a VP9 WebM with alpha that lines up frame for frame with the source, plus the grey mask. Made for one person facing the camera, such as an AI avatar's lip-synced take or a webcam read, to put them over slides, a set or graphics. For people with furniture that must stay in the cutout, or a busy shot, use birefnet-matte; for a matte with the face and hands tracked too, python-track-face-and-hands.

SKILL.md

Give it a video of one person speaking to camera; get their cutout, <name>_cutout.webm (VP9, yuva420p, short GOP so the compositor seeks it fast), frame k of which is frame k of the source, and the grey mask, <name>_mask.mp4. It runs Robust Video Matting on this computer (Apple's GPU when there is one), free. The siblings:

UseWhen
ThisOne person to camera on a plain or soft background: a presenter, an avatar take, a webcam read
birefnet-matte (paid)The cutout must keep a podium, chair or desk, or the shot is busy; type behind people in a scene
python-track-face-and-handsThe graphics react to the face and hands too: it tracks them and makes a matte in the same pass

Inputs

  • The video, the exact take that goes in the cut (an assembled talking head, or a webcam rough cut), at its own frame rate and size (ffprobe-inspect-media).
  • Matte the finished take, not its source chunks: one pass, one alpha that runs across the seams.

Run it

Write references/rvm_matte.md's script into the job's scripts/ as rvm_matte.py, as is, and run it with cwd the job folder:

exec python scripts/rvm_matte.py talking_head/talking_head.mp4 mattes/presenter

--ratio is the share of the frame the model looks at for the person's outline: 0.25 for 1080p and up, 0.4 below (the defaults); raise it toward 0.6 for a person small in the frame. The first run downloads the weights (about 15 MB) into models/.

What you get

mattes/presenter_cutout.webm (the source's own pixels with RVM's alpha) and mattes/presenter_mask.mp4 (white = the person). Keep the mask: re-merging it with a feather is the same ffmpeg merge as birefnet-matte, step 3.

Tips and traps

  • ffmpeg's native VP9 decoder drops alpha. Put -c:v libvpx-vp9 before -i in any command that reads the WebM; ffprobe shows yuv420p with alpha_mode=1, which is a cutout with alpha.
  • It keeps the person, not what they hold or lean on: a podium or a chair edge goes with the background. That is birefnet-matte's job.
  • The first frames settle: RVM carries state from frame to frame, so its first few frames can be soft. Matte from the shot's start, never from a seek into it.
  • Never colour-key a presenter instead: it eats skin and hair edges.

Check it

  • Frame count equals the source's (decode with libvpx): exec ffmpeg -v error -c:v libvpx-vp9 -i mattes/presenter_cutout.webm -map 0:v -f framemd5 -
  • One frame over a flat colour, looked at for fringes and missing hair (birefnet-matte, Check it, the same command).
  • The cutout over its own source is near identical to it (SSIM about 0.99 or better).

FAQs

Cut a presenter or talking head out of their video for free on this computer with Robust Video Matting (RVM): a soft, steady alpha that follows hair and holds from frame to frame, written as a VP9 WebM with alpha that lines up frame for frame with the source, plus the grey mask. Made for one person facing the camera, such as an AI avatar's lip-synced take or a webcam read, to put them over slides, a set or graphics. For people with furniture that must stay in the cutout, or a busy shot, use birefnet-matte; for a matte with the face and hands tracked too, python-track-face-and-hands.

Install Hypernatural Desktop, a free Mac app, and connect it to Claude Code, Codex or Claude Desktop. Then describe the video you want and your agent finds the skill itself, or paste this page's link (https://hypernatural.ai/skill/hn/python-matte-a-talking-head) and it installs hn/python-matte-a-talking-head and follows it.

Nothing. The skill is free and runs with tools on your own Mac, like python, ffmpeg and ffprobe.

Yes. Ask your agent to adjust it for your job, or to save its own version. You can publish your version under your own handle so anyone can install it.

Go make something cool.

Install the app, open your agent, describe the video. That's the whole onboarding.

Sticker HypernaturalSticker BannerSticker TVBoy