Nodes/ComfyUI-SuperNodes/🐧 Get Video Crop Frames
ComfyUI Node

🐧 Get Video Crop Frames

Crop every video frame around the face β€” and remember exactly where it was

By sonnyboxΒ·Created 11 months agoΒ·Updated 4 days agoΒ· 12
🐧 Get Video Crop Frames
  • frames
  • bboxes
  • masks
  • restore_info
  • cropped_frames
  • cropped_masks
β—„squaretrueβ–Ί
β—„padding0β–Ί
β—„multiple_of16β–Ί
β—„horizontal_offset0.0β–Ί
β—„vertical_offset0.0β–Ί
β—„pad_modeβ–Ύβ–Ί
β—„pad_color0,0,0β–Ί

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) or edge (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.
  • masks must match the frame dimensions exactly, and there must be at least as many masks/bboxes as frames, or it raises.
  • multiple_of: 16 is a good default, but if your restorer later upscales, keep in mind the crop size is baked into restore_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.

CategorySuperNodes/Video

Inputs (10)

NameTypeDefaultDescription
framesIMAGEThe source frame batch [B,H,W,C].
squareBOOLEANtrueIf true, pad the common crop size to a square (max of width/height).
paddingINT00–4096Grow each bbox/mask by this many pixels on all sides (clamped to the frame). Useful to leave room to feather outside the detection.
multiple_ofINT161–512Round the output crop width/height up to a multiple of this value.
horizontal_offsetFLOAT0.0-5–5Anchor the bbox/mask horizontally within the crop margin. 0 = centered, -5 = flush left, +5 = flush right.
vertical_offsetFLOAT0.0-5–5Anchor the bbox/mask vertically within the crop margin. 0 = centered, +5 = flush top, -5 = flush bottom.
pad_modeCOMBOHow to fill regions outside the frame when the crop window overflows.
pad_colorSTRING0,0,0Fill color as 'R,G,B' (0-255) used when pad_mode is 'color'.
bboxesoptBBOXPer-frame bounding boxes [x1,y1,x2,y2]. If a bbox is invalid or empty, the corresponding frame will be black.
masksoptMASKPer-frame masks [B,H,W] defining regions of interest. If provided, masks are preferred over bboxes.

Outputs (3)

NameTypeDescription
restore_infoBBOX_RESTORE_INFOPer-frame crop metadata required by Restore Video Crop Frames.
cropped_framesIMAGEUniform-size cropped frame batch.
cropped_masksMASKUniform-size cropped mask batch.