Object Separation

Separates a person, product or hand from the background of a video on your own computer, with a mask saved for every frame.

Video & Audiovideobackground removalrotoscopingmasksby Barty-Bart1.1kGitHub

What it is

Object Separation is for video creators who need to cut one subject, such as themselves, a product or a hand, away from the background of a clip. It uses SAM 2.1 (Segment Anything, a free model from Meta) and runs entirely on your own computer, so your footage is never uploaded. You tell the agent which video to use and what to separate, and it handles the setup, the choice of model and the processing.

Instead of improvising, the agent follows a tested recipe. It first checks your machine and picks one of three model sizes: the largest for an NVIDIA graphics card with 12 GB or more, a middle size for smaller NVIDIA cards and Apple Silicon Macs, and the smallest for computers with no graphics card. It marks the subject by placing points on a gridded still of the first frame, including points on things to leave out, tests about 20 frames, then works through the clip in 60-frame chunks to keep memory use low.

You get a copy of your video with the subject tinted green and outlined, keeping the original sound, so you can see exactly what was picked up, plus a folder of black-and-white masks, one per frame. The masks are what you build on for later edits, such as a new background. Edges are hard, so soft hair comes out less clean than objects and hands. Without a graphics card it is slow, about 5 seconds per frame, so a 10-second clip takes around half an hour.

What it can do

  • Checks your computer's graphics hardware and picks a matching model size, telling you the download size and expected speed.
  • Separates one subject, such as a person, product or hand, across the range of frames you choose.
  • Leaves out things touching the subject, like fingers holding a product or packaging, when marked as excluded.
  • Saves a black-and-white mask image for every frame, white where the subject is.
  • Outputs a preview video with the subject tinted green and outlined, keeping the original audio.
  • Installs everything into one project folder and explains how to delete it and the downloaded model afterwards.

When to use it

  • You filmed yourself talking to camera in a messy room and want to separate yourself before adding a new background.
  • You have a clip of a product held in your hand and need the product isolated without your fingers.
  • You want frame-by-frame masks of a hand gesture so you can build a motion graphics effect around it.
  • Your footage is private and you would rather not upload it to an online background remover.

How it works

  1. 1Installs the Python packages it needs, including PyTorch and Hugging Face Transformers, into a separate folder inside your project.
  2. 2Scans your computer for an NVIDIA card or Apple Silicon chip, picks a model size and downloads it on the first run.
  3. 3Saves the first frame with a coordinate grid, looks at it, and places points on the subject and on anything to exclude.
  4. 4Runs a short test of about 20 frames, checks it, then separates the full range in chunks.
  5. 5Uses FFmpeg to write the green-highlighted video with the original sound, and saves the masks to a folder.
  6. 6Reviews frames at the start, the middle and any tricky moment, adding points and rerunning if green spills over or parts are missing.

Try asking

“Separate me from the background in clip.mp4.”
“Cut out the bottle in product-shot.mp4 but leave out my hand holding it.”
“Rotoscope the hand in the first 10 seconds of this video.”
“Isolate the dog in this clip and give me a mask for every frame.”

How to install

Install with the skills CLI (recommended)

Works with Claude Code, Codex, Cursor, OpenCode and other agents, and asks which ones to install to. Needs Node.js 22.20+. Add -g to make it available in every project.

npm
npx skills add https://github.com/Barty-Bart/motion-graphics/tree/main/skills/object-separation
pnpm
pnpm dlx skills add https://github.com/Barty-Bart/motion-graphics/tree/main/skills/object-separation

Install manually

Copies the skill folder into Claude Code's personal skills directory. For claude.ai, zip the object-separation folder and upload it in the Skills section of Settings.

Terminal
git clone --depth 1 https://github.com/Barty-Bart/motion-graphics.git
mkdir -p ~/.claude/skills
cp -r motion-graphics/skills/object-separation ~/.claude/skills/object-separation

Then just ask in plain language, for example: “Separate me from the background in clip.mp4.”