Box2Video
The crop-by-coordinates helper every AniPortrait workflow quietly depends on
- image
- box
- IMAGE
- BOX
Box2Video is the least glamorous node in the whole pack, and also one of the most used if you build the full AniPortrait workflow by hand. It takes an image and a BOX - a plain [x1, y1, x2, y2] list of pixel coordinates - and crops the image to that box. That's it. No models, no sampling, no GPU math worth mentioning.
The reason it exists is that AniPortrait works best when it animates a tight crop of the face or person, not your whole 4K still. You crop, animate, and paste back. Box2Video is the "crop" end of that deal. The source is a one-liner under the hood: it slices image[:, y1:y2, x1:x2, :] and returns the crop alongside the same box, unchanged.
The inputs and outputs that matter
image- the tensor you want to crop, any IMAGE batch.box- coordinates in[x1, y1, x2, y2]order. You'll almost never type these by hand; they come from a node that produces boxes, likeMaskList2Video(which turns a segmentation mask into a box) or any detector node in your graph.
Outputs are the cropped IMAGE and the same BOX passed through. The passthrough matters: it lets you thread the box along the graph so the node that pastes everything back - CoverVideo - knows exactly where the crop came from. That round trip is the whole point of the coordinate-keeping.
Installing it
Part of chaojie/ComfyUI-AniPortrait, so install the pack:
cd ComfyUI/custom_nodes
git clone https://github.com/chaojie/ComfyUI-AniPortrait
pip install -r requirements.txt
Worth flagging: the node itself needs no models and barely any VRAM, but the pack's module imports its whole heavy stack (decord, av, mediapipe, onnxruntime-gpu, the lot) at load time. So you still have to run that requirements.txt before Box2Video even shows up in your node list. Model downloads are not required for this node, though - it's pure tensor slicing.
One honest caveat if you're new to box-based crops: there's no resizing here. Whatever the box says, you get that slice, full resolution, nothing more. If you feed it a box from a low-res mask run, the crop comes out small. It's a dumb, predictable tool, which is exactly what you want in the middle of a pipeline that's already complicated.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| image | IMAGE | — | |
| box | BOX | — |
Outputs (2)
| Name | Type | Description |
|---|---|---|
| IMAGE | IMAGE | — |
| BOX | BOX | — |