π§ Get Video Crop Frames
Crop every video frame around the face β and remember exactly where it was
- frames
- bboxes
- masks
- restore_info
- cropped_frames
- cropped_masks
If you've ever tried to enhance a face in a video, you know the trap: a detection box moves frame to frame, so the naive crop isn't a rectangle that follows the face - it's a different-sized crop on every frame. ComfyUI image batches demand one uniform size. You end up with black bars, squashed content, or a mosaic of mismatched crops. This node is the honest fix: it takes per-frame bboxes or masks, figures out the single crop size that fits every frame, crops them all uniformly, and records the geometry so its sibling can paste them back precisely.
It's part of the π§ SuperNodes pack by SuperCC, and it's the front half of a video crop-restore pair with Restore Video Crop Frames. Think face-swap, face-fix, or region inpainting applied to video: crop here, process the batch however you want, restore there.
How it works
The inputs that do the actual work:
- frames - the source batch
[B,H,W,C]. - bboxes (
BBOX) or masks - per-frame detections. If you connect both, masks win; they're preferred over bboxes. If you connect neither, the node errors. - square - pad the common crop to a square (max of width/height). For face work this is usually what you want, since models don't care about the rectangle's shape.
- padding - grow every detection by this many pixels (clamped to the frame). This is your feather room: without it, a restored face can't blend outside its own box.
- multiple_of - round the output crop up to a multiple of this (default 16), so it stays VAE/UNet friendly.
- horizontal_offset / vertical_offset (-5 to 5) - where the detection sits inside the crop's extra margin: 0 centered, -5 flush left, +5 flush right (vertical is inverted in the tooltip, so check it before assuming). Leave at 0 for centered.
- pad_mode / pad_color - how to fill space when a crop window overflows the frame: solid
color(as"R,G,B"0β255) oredge(replicate the border pixels).
The mechanism: it finds the largest detection across all frames, uses that as the common crop size, then anchors each frame's own detection inside that window per the offsets. Outputs are cropped_frames (uniform batch), cropped_masks (same geometry, either from your masks or rebuilt as solid rectangles from the bboxes), and restore_info - the per-frame metadata Restore Video Crop Frames consumes. That metadata wire is the whole deal; don't lose it.
When you'd reach for it
- Video face work: track a face, crop every frame uniformly, enhance or swap the batch, restore.
- Any video pipeline where a moving region of interest needs stable crop geometry across the clip.
Install
ComfyUI Manager, search "ComfyUI-SuperNodes", or:
cd ComfyUI/custom_nodes
git clone https://github.com/sonnybox/ComfyUI-SuperNodes
Restart ComfyUI. No model downloads. The pack's only extra dependency is matplotlib (Sigmas Graph only), and the whole pack targets ComfyUI's newer extension API - stale ComfyUI builds won't load it.
Gotchas
- You need a detection for every frame. A frame with an invalid or missing bbox comes back as a black crop - no error, just a black frame that will happily get processed and pasted back. Check your tracker's coverage before you burn a long render.
masksmust match the frame dimensions exactly, and there must be at least as many masks/bboxes as frames, or it raises.multiple_of: 16is a good default, but if your restorer later upscales, keep in mind the crop size is baked intorestore_info- the restore node handles scaling, so this is mostly about keeping the middle stage happy.
The crop-restore pair is the most genuinely useful thing in this pack, and this node is the half people underestimate. Get the geometry right here and the restore is trivial; get it wrong and no amount of blending saves you.
Inputs (10)
| Name | Type | Default | Description |
|---|---|---|---|
| frames | IMAGE | The source frame batch [B,H,W,C]. | |
| square | BOOLEAN | true | If true, pad the common crop size to a square (max of width/height). |
| padding | INT | 00β4096 | Grow each bbox/mask by this many pixels on all sides (clamped to the frame). Useful to leave room to feather outside the detection. |
| multiple_of | INT | 161β512 | Round the output crop width/height up to a multiple of this value. |
| horizontal_offset | FLOAT | 0.0-5β5 | Anchor the bbox/mask horizontally within the crop margin. 0 = centered, -5 = flush left, +5 = flush right. |
| vertical_offset | FLOAT | 0.0-5β5 | Anchor the bbox/mask vertically within the crop margin. 0 = centered, +5 = flush top, -5 = flush bottom. |
| pad_mode | COMBO | How to fill regions outside the frame when the crop window overflows. | |
| pad_color | STRING | 0,0,0 | Fill color as 'R,G,B' (0-255) used when pad_mode is 'color'. |
| bboxesopt | BBOX | Per-frame bounding boxes [x1,y1,x2,y2]. If a bbox is invalid or empty, the corresponding frame will be black. | |
| masksopt | MASK | Per-frame masks [B,H,W] defining regions of interest. If provided, masks are preferred over bboxes. |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| restore_info | BBOX_RESTORE_INFO | Per-frame crop metadata required by Restore Video Crop Frames. |
| cropped_frames | IMAGE | Uniform-size cropped frame batch. |
| cropped_masks | MASK | Uniform-size cropped mask batch. |