flow_frame_slice
Cut frames out of a video, an image batch, or a latent — with one node
- image
- latent
- video
- image
- latent
- video
You know how you keep having to reach for different trim tools depending on whether the thing in front of you is an image batch, a latent, or a video? flow_frame_slice is the "stop it, one node does all three" answer. Give it a start frame and an end frame, wire in whichever of the three you're holding, and it slices the same range out of all of them - which in this pack matters because the flow-stage video pipeline hands latents around while you're still iterating, and you don't want to decode to pixels just to trim five frames.
How it works
The mechanism is refreshingly honest about what it's doing. start_frame (default 0) and end_frame (default -1) get normalized the Python way: negative indices count back from the end, so -1 means "last frame" and 0 means "first frame." Both get clamped to the actual length of the input. The neat bit is that you can reverse a slice - set start higher than end and it returns the range in reverse order, which is handy for a quick ping-pong or replay effect.
It handles each input type properly:
- image - plain batch slicing along the frame axis.
- latent - slices the
samplestensor and, thoughtfully, keepsnoise_maskandbatch_indexin sync so a masked inpainting latent doesn't come out misaligned. - video - slices the frames and the alpha channel and the audio: the waveform is cut to match the selected frame window (and reversed if you reversed the frames), so a trimmed clip keeps its audio synced rather than starting mid-word.
Wire in nothing and you get an ExecutionBlocker on that output instead of a crash - the node is safe to leave half-hooked-up, which matters when you're building a workflow before you've connected every stage.
The inputs that matter
Just the three optional ports: image, latent, video. Pick the one matching what's upstream. The start_frame/end_frame defaults (0 and -1) mean "everything," so the node is a pass-through until you set a range - which is a nice way to build the node into a workflow from the start and trim later.
Outputs
image, latent, video - each only populated if that input was connected; the others come out as execution blockers. Nothing else to wire.
Install and notes
It's part of ComfyUI-Apt_Preset, so install is the usual: ComfyUI Manager → search "ComfyUI-Apt_Preset", or clone into custom_nodes and run install.bat. No extra models, no GPU magic - it's a pure tensor-op utility. The one thing to remember is that it operates on whatever type you hand it, and the frame index always refers to the frame axis (axis 0) of that input, so "frame 20" is frame 20 of your video or item 20 of your image batch. Also note the flow_stage_index_switch sibling handles which stage runs, while this handles which frames - if you're trimming between continuation clips, they're often used back to back.
Inputs (5)
| Name | Type | Default | Description |
|---|---|---|---|
| start_frame | INT | 0-2147483648–2147483647 | — |
| end_frame | INT | -1-2147483648–2147483647 | — |
| imageopt | IMAGE | — | |
| latentopt | LATENT | — | |
| videoopt | VIDEO | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| image | IMAGE | — |
| latent | LATENT | — |
| video | VIDEO | — |