Video Mask
Describe a subject in plain words and get a black-and-white mask video that tracks it through the clip, with SAM 3.1 or SAM 3, for clips up to 5 minutes.
The Video Mask node tracks a subject that you describe in plain words through a video, and returns a black-and-white mask video. The mask has the same length and frame rate as the clip. It is white on every pixel of the subject in every frame, and black everywhere else. The node runs SAM 3.1 or SAM 3.
The mask is an ordinary video, so you can connect it anywhere a video goes. Its main partner is Mask Composite, which uses the mask to place the subject from one video over another video. The mask also feeds the Mask video input of Relight & Switch in Custom mode.
When to use it
- Move a subject into a new scene, for example a dancer onto a beach, together with Mask Composite.
- Replace the background behind a product or a person in a clip.
- Make a frame-accurate matte video for the Custom mode of Relight & Switch.
- Keep everything except one subject, with Invert mask on Mask Composite.
- Pixelate or blur faces, number plates or screens, with Fill set to Pixelate or Blur on Mask Composite.
Quick start
Add the node
Press Tab on the canvas and choose Video › Continue & Restyle › Video Mask.
Connect the video
Wire the clip into the Video input, for example from an Upload Video node.
Describe the subject
Open the settings panel. Under Describe what to mask, write a short noun phrase, such as the dancer or the red car.
Run it
Click Run on the node. The mask video appears on the node. Wire its Mask output into the Mask input of a Mask Composite node.
Inputs
| Input | Accepts | What it does |
|---|---|---|
| Video | Video nodes, such as Upload Video, Generate Video and Trim Video | The clip to mask. Required. |
| Prompt | Text nodes, such as Text or a list item | A description of the subject. A wired prompt replaces the description in the settings panel. Optional. |
A video link must point at an ordinary video file, not a streaming playlist (HLS or DASH). Such a link is refused before anything is charged. See Media links.
Outputs
| Output | What it carries |
|---|---|
| Mask | The mask video, an MP4 of the same length and frame rate as the clip. White is the subject, black is everything else. |
White means the subject. Generate Mask, the node that masks a still image, uses the same rule, and Mask Composite expects it.
A rotated phone clip, a clip with a variable frame rate, or a clip larger than 1920 pixels on its long side is first converted upright, at a constant frame rate and at most 1920 pixels. The mask has that size. Mask Composite stretches the mask over the full-size footage, so you do not need to do anything.
The mask is never watermarked, on any plan.
Settings
| Setting | What it does |
|---|---|
| Describe what to mask | What to track, up to 500 characters. A short noun phrase works best, such as the woman in the red coat or the skateboard. Separate several subjects with commas, for example person, dog: the mask is white wherever any of them is. Required, unless a text node is wired into Prompt. |
| Detection threshold | How sure the model must be before it marks a region, from 0.05 to 0.95 in steps of 0.05. The default is 0.5. A lower value finds more regions, with less precision. Try 0.3 when nothing matches. |
| Model | SAM 3.1, the default, tracks several objects in one pass and runs faster. SAM 3 costs half the price. |
| Hold mask when the subject is lost | When the model loses the subject for a few frames, for example behind a hand, each of those frames repeats the most recent mask that was not empty. A mask that hides the subject then never uncovers it. A mask is held for at most 1 second. If the subject is still missing after that, the next frames stay empty until the model finds it again, so a mask never stays where the subject no longer is. Frames before the first detection stay empty. Off by default. |
| Ignore subjects smaller than (% of frame height) | Drops, on every frame, each separate white region whose height is less than this share of the frame height, for example extras' faces behind the main person. On a 540-pixel-tall shot, 15 keeps faces 81 pixels tall or more. Bigger regions are kept exactly. Off (0) by default. |
| Ignore subjects larger than (% of frame height) | Drops each region taller than this share of the frame height, for example to keep only the small faces in the background. Off (0) by default. With both set, a region is kept when its height is between the two values. A smaller-than value above the larger-than value is refused, and the panel warns you. |
| Zone | Four margins, in % of the frame: left, right, top and bottom. Only the regions whose center is inside the frame minus these margins are kept, for example to drop the faces at the edges of the picture. Each margin is from 0 to 49 %. A region that crosses the line is kept or dropped as a whole, by its center. The zone runs on every frame after the two size filters. Off (all four at 0) by default. |
| Detect again after every cut | For an edited clip. The node finds the scene cuts first and masks each shot on its own, so the subject is found again in each shot. A new face or object after a cut is masked too, and Hold mask when the subject is lost never carries a mask across a cut. A dissolve or a fade counts as one shot, and a camera flash is usually not a cut. A cut into fast motion, such as a swing, a hit or a whip pan, still counts as a cut. A piece shorter than 8 frames joins the shot next to it. The mask keeps the clip's frame count, and every cut stays where it is. The price does not change. Off by default. |
| Detect again every (seconds) | The model finds its subjects near the start of each request it receives. A subject that first appears partway through, such as someone who walks in or a face that turns to the camera, can stay unmasked for the rest of that request. Set this slider to a value from 1 to 10, and the clip is sent in pieces of at most that many seconds. The subjects are detected again at the start of each piece, so a face that appears mid-shot is masked from the next piece on. With Detect again after every cut on, the pieces are counted from the start of each shot. A last piece shorter than 8 frames joins the one before it. These boundaries are not cuts: Hold mask when the subject is lost carries a mask across them. Each piece is one more request to the model, so the run takes longer. For example, a 10-second clip at 1 takes about four rounds of requests instead of one. The price does not change. Off (0) by default. |
| Pre & post text | Text that is always added before and after the description. It is hidden from people who use your workflow as an app. See Prompt pre and post text. |
Limits
- Length: clips up to 5 minutes at 30 fps.
- Frame rate: a faster clip counts proportionally longer, because the model works frame by frame. A 60 fps clip counts as twice its length, so it can be up to 2.5 minutes long.
- Long clips: a clip longer than 60 seconds at 30 fps is processed in 60-second pieces, and the pieces are joined frame by frame. Tracking starts again at the start of each piece. The mask holds everything the description matches, so this rarely shows. With Detect again after every cut on, every cut also starts a new piece, and a shot longer than 60 seconds at 30 fps is split the same way. With Detect again every (seconds) set, the pieces are that many seconds long instead, and tracking starts again at each of them on purpose.
A clip that Nodaro cannot read, or a clip over the limit, is refused before anything is charged. Cut a long clip with Trim Video first.
Credits
The price follows the length of the clip, counted at 30 fps, and the model. The length is rounded up to a whole second, after ignoring up to 0.05 seconds past one, and the run is charged the first row that covers it. For example, a 5-second cut at 29.97 fps is 5.005 seconds long and is charged as 5 seconds.
| Clip length (at 30 fps) | SAM 3.1 | SAM 3 |
|---|---|---|
| Up to 5 seconds | 55 | 28 |
| Up to 10 seconds | 105 | 53 |
| Up to 15 seconds | 160 | 81 |
| Up to 30 seconds | 314 | 158 |
| Up to 60 seconds | 622 | 312 |
| Up to 90 seconds | 935 | 468 |
| Up to 2 minutes | 1,243 | 622 |
| Up to 3 minutes | 1,865 | 933 |
| Up to 4 minutes | 2,486 | 1,243 |
| Up to 5 minutes | 3,108 | 1,555 |
A clip faster than 30 fps counts proportionally longer. For example, a 12-second clip at 24 fps counts as 12 seconds, so on SAM 3.1 it costs 160 credits. A 10-second clip at 60 fps counts as 20 seconds, so on SAM 3.1 it costs 314 credits.
Before a run, the node's price, its Run button and the workflow's estimate read the same length for the incoming clip. This is true in the editor, in POST /v1/credits/estimate-workflow, in MCP and in a published app's listed price.
- A video that another node makes in this run is read at the length that node will produce at its settings. A generation counts the length its model renders, and Auto counts its longest clip. An Extend Video counts its source plus the seconds it adds. A Trim Video, Loop Video or Combine Videos counts the length it passes on.
- Each clip made on the way adds about a tenth of a second. A made clip runs a frame or an audio track a little past its planned length, and the run measures the whole file. For example, a generation set to 5 seconds is quoted at the 10-second row, 105 credits on SAM 3.1, because a clip measured past 5.05 seconds is charged that row. A Dubbing, a Voice Extractor or a PixVerse V6 extension adds a quarter second instead, because their files run further past their planned length.
- A node that does not run in this run, such as Video Mask run on its own or a frozen node, hands on the result it already holds. That result is read at the length recorded for it. A video generation whose result recorded no length is read at its Duration, like a clip made in this run.
- An uploaded clip, or a clip added from your own uploads in the Library, is read at the length measured when it was uploaded.
- A length that the upstream node only stores, such as an earlier result of a node that runs again, is never read.
- A rendered video is read at the render's estimated length.
When the clip is an upload that also declares its frame rate, the node shows the price for its frame-rate-counted length, the same rule the run is charged by. This works when the upload is wired straight in, or through Trim Video, Loop Video, or a Combine Videos whose clips all declare the same rate. For example, a 10-second upload at 60 fps is quoted as 20 seconds. With no declared rate, the node shows the price of that length at 30 fps. When the length is not known, the node shows a range, from 55 to 3,108 credits on SAM 3.1, and from 28 to 1,555 credits on SAM 3. A workflow estimate counts the longest row. The run itself always measures the clip, including its real frame rate, and is charged that row.
Tips
- Use a short noun phrase.
the dancerworks better than a long sentence about the dancer. - Lower the threshold when nothing matches. Try 0.3 before you rewrite the description.
- Trim before you mask. The price follows the clip's length, so cut the clip to the moment you need with Trim Video.
- Choose SAM 3 to save credits. SAM 3 costs half the price of SAM 3.1. SAM 3.1 tracks several objects in one pass and runs faster.
- A subject that leaves the frame is found again. When the subject comes back, the mask follows it again. The frames where it is absent are black, unless Hold mask when the subject is lost is on.
- Size filters and the zone run before the hold. A frame left with only small regions, or with nothing inside the zone, counts as empty, so the hold repeats the last frame that kept a subject. If no region on any frame passes the size filters and the zone, the result is an all-black mask, and the run is charged as usual.
- Mask an edited clip shot by shot. Turn on Detect again after every cut when the clip has cuts and a new subject appears after a cut.
- Catch a subject that appears mid-shot. Set Detect again every (seconds) to 1 or 2 when someone walks into the shot or turns to the camera partway through.
Troubleshooting
The run fails with "No region matched the mask prompt on any frame". Nothing in the video matched your description. Your credits are refunded. Shorten the description to a plain noun phrase, or lower the Detection threshold.
The clip is refused as too long. The clip is longer than 5 minutes at 30 fps, or a faster clip counts as longer than that. Cut it with Trim Video and run again.
The run fails on a self-hosted install. On a self-hosted install, Video Mask needs a key for the provider that runs its models. Without the key, the run fails with a message that says so. See Provider keys.
From the API
POST /v1/video-mask takes videoUrl, prompt (up to 500 characters; commas track several subjects), an optional threshold from 0.05 to 0.95 (default 0.5) and an optional provider, sam-3.1 (the default) or sam-3. It also takes optional holdLastMask (default false), minSubjectHeightPct and maxSubjectHeightPct (0 to 100, default 0, off), zone and perShot (default false). redetectEverySec is 0, the default, which is off, or 1 to 10. Any other value is refused with a 400 error. zone is { leftPct, rightPct, topPct, bottomPct }, each from 0 to 49. A margin left out is 0, and null or all four at 0 turns the zone off. A minimum above the maximum is refused with a 400 error. It returns a job. The finished job's output carries videoUrl (the mask), thumbnailUrl, width, height, frames, chunks, shots (1 when perShot is off), coverage, kept and recipe, plus heldFrames when holdLastMask is on and droppedRegions when a size filter or a zone is on. chunks counts the requests sent to the model. recipe is the version of the masking method that made the mask. It changes whenever the same clip and settings would give a different mask, so a mask you keep for reuse can tell that it is out of date. coverage is rounded to 4 decimals. To tell an empty mask from a very small one, read kept: it is false only when the size filters and the zone left nothing on any frame. A clip that cannot be read, or a clip over the limit, is refused with a 400 error before anything is charged.
- SDK:
videoMask({ videoUrl, prompt, threshold, provider, holdLastMask, minSubjectHeightPct, maxSubjectHeightPct, zone, perShot }). See Media and uploads. - MCP: the
video_masktool takesvideo_urlorvideo_asset_id,prompt, and optionalthreshold,provider,hold_last_mask,min_subject_height_pct,max_subject_height_pct,zone(left_pct,right_pct,top_pct,bottom_pct) andper_shot. Its job id chains intomask_compositeasmask_asset_id. See the MCP tools. - CLI:
nodaro media video-mask <videoUrl> <prompt> [--threshold <n>] [--model sam-3.1|sam-3] [--hold-last-mask] [--min-subject-height <pct>] [--max-subject-height <pct>] [--zone <L,R,T,B>] [--per-shot]. For example,--zone 10,10,5,5keeps only the subjects whose center is inside those left, right, top and bottom margins. See Media and voice commands.
See Run a single node and Jobs.
Frequently asked questions
What does the Video Mask node do?
Video Mask tracks a subject that you describe in plain words through a video. It returns a black-and-white mask video of the same length and frame rate, white on the subject in every frame and black everywhere else.
Which model should I choose, SAM 3.1 or SAM 3?
SAM 3.1 is the default. It tracks several objects in one pass and runs faster. SAM 3 costs half the price of SAM 3.1.
How long can the video be?
Up to 5 minutes at 30 fps. A faster clip counts proportionally longer, so a 60 fps clip can be up to 2.5 minutes long. A clip over the limit is refused before anything is charged.
Can I track more than one subject?
Yes. Separate the subjects with commas, for example "person, dog". The mask is white wherever any of them is.
What happens when the prompt matches nothing?
When nothing matches on any frame, the run fails with "No region matched the mask prompt on any frame" and your credits are refunded. Use a shorter, plainer description, or lower the Detection threshold.
Can Video Mask ignore people in the background?
Yes. Set "Ignore subjects smaller than (% of frame height)" to drop every region shorter than that share of the frame height, such as extras' faces behind the main person. "Ignore subjects larger than" does the opposite.
How do I put the masked subject into another video?
Wire the Mask output into the Mask input of a Mask Composite node. Wire the original video into its Foreground input and the new scene into its Background input.
Related
Mask Composite
Relight & Switch
Generate Mask
Trim Video
Prompt pre and post text
Last updated on
Video Depth
Turn any video into a depth video, where near is bright and far is dark, with Video Depth Anything or Depth Anything per frame, in grayscale or a colormap.
Trim Video
Cut a video by start and end time, trim seconds or frames from its edges, keep its first or last seconds, or cut at the cleanest loop point with Smart loop cut.