Frame Range Router (MEC)
Frame Range Router (MEC)
- images
- mask
- images
- mask
- frame_count
Frame Range Router (MEC) slices a video batch by frame range and keeps its mask in sync - which is the thing the pack's bare Image Batch Slice doesn't do. When you're working on a mask-tracked segment of a video (say, a 200-frame shot where only frames 40-90 have the subject you care about), slicing just the frames means your mask goes out of alignment with its images. This node routes both at once, so the mask you get matches the frames you get, index for index.
It's part of ComfyUI-CustomNodePacks, the ~72-node pack from Code2Collapse (Likhith-24, active on r/comfyui), sitting in the MaskEditControl/Metadata category.
How it works
Python slice semantics on a batch, with a mask riding along:
start- inclusive first frame. Negative indexes from the end.end- exclusive (the slice stops before it). The default-1means "to the end of the batch," so out of the box it's a no-op until you setstart.step- stride;2keeps every other frame.
Wire in the optional mask and it gets the same slice applied, so images and mask stay frame-aligned. If no mask is connected, it outputs a zero mask in the matching shape - a quirk to know about rather than fight. Outputs are images, mask, and frame_count (INT), and the node clamps everything to valid bounds instead of erroring.
The "router" in the name is aspirational but earned: because it takes a batch and hands back a resized, stride-adjusted batch, you can use it as the entry point of a branch - send one frame range down a heavy path and another down a light path - without hand-editing indices.
The inputs and outputs that matter
images- the video batch.mask(optional) - the per-frame mask that must stay aligned with the frames.start/end/step- the range. Beginners: setstartandendfirst; touchsteponly when you want decimation.images/mask/frame_count- outputs.frame_countis the honest count of what came through, useful for downstream checks.
Installing it
Ships inside ComfyUI-CustomNodePacks; no standalone repo. ComfyUI Manager → search "CustomNodePacks", or:
cd ComfyUI/custom_nodes
git clone https://github.com/Code2Collapse/ComfyUI-CustomNodePacks.git
Pure PyTorch slicing - no models, no extra dependencies beyond what the pack needs globally (opencv-python>=4.7.0, scipy>=1.10.0; install just those if missing, not the full requirements.txt, which can clobber ComfyUI's torch). Restart ComfyUI.
Common issues
- Mask comes back all zeros - you didn't connect a mask. The node fabricates a zero mask when none is given, so a missing wire reads as "blank mask" rather than an error. Check the wire.
- End-inclusive confusion -
endis exclusive. Want frames 0-9?start=0, end=10. The defaultend=-1reads as "to the end," which is why leaving it alone works. - Images and mask counts disagree after a run - that only happens if the mask batch was shorter than the images going in; the node clamps to the mask's length. Keep mask and images the same length upstream (the pack's mask tools generally do).
The honest take: it's a small convenience node - but mask/frame alignment bugs are a genuinely miserable category of video-workflow failure, and a node that removes the whole class is worth having around.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| images | IMAGE | — | |
| start | INT | 0-100000–100000 | — |
| end | INT | -1-100000–100000 | — |
| step | INT | 11–1000 | — |
| maskopt | MASK | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| images | IMAGE | — |
| mask | MASK | — |
| frame_count | INT | — |