Nodes/OmniNodes/Video Trim / Extract ✂️
ComfyUI Node

Video Trim / Extract ✂️

Trim dead frames off a clip, or pull one scene out of a batch

By TensorVizion·Created 3 months ago·Updated about 8 hours ago· 0
Video Trim / Extract ✂️
  • images
  • images
  • frame_count
  • summary
moderange
start_frame0
end_frame-1
explicit_indices

ComfyUI video is a batch of frames, which means "editing" is mostly slicing a tensor. Video Trim / Extract is that slice, in two flavours: crop a contiguous start-to-end range, or pull an arbitrary list of individual frames. It's the boring utility node you'll reach for constantly once you start finishing videos instead of just generating them.

How it works

ComfyUI's own frame-count helper gets a start_frame and end_frame and slices the batch dimension. That's the whole mechanism - no re-encoding, no resampling, just tensor indexing on the IMAGE batch. Frame 5 comes out in the same pixel order it went in, so whatever was downstream stays compatible.

The two modes matter more than the rest of the inputs put together:

  • range - inclusive slice from start_frame to end_frame. end_frame = -1 means "through the last frame", which is the value you want when trimming dead frames off the head of a clip. Default start_frame is 0, so trim-both-ends is "set start, leave end at -1".
  • explicit - a comma-separated string of frame numbers like 0, 24, 48. This is the fun one: the pack's Video Scene Detect outputs its cut_frame_indices STRING in exactly this format, so you can feed a detected scene boundary straight into explicit_indices and isolate one shot for separate processing.

The inputs that matter

  • images - your frame batch.
  • mode - range or explicit. Pick before you touch anything else; the other widgets only apply to one mode each.
  • start_frame / end_frame - the range bounds.
  • explicit_indices - the hand-typed or Scene Detect-fed list, only read in explicit mode.

Out-of-range indices don't crash the node. They're clamped or skipped, and the summary tells you exactly which requested indices fell outside the batch, which makes a mismatched wiring mistake - wrong video, wrong frame count - easy to spot instead of mysteriously "working."

Outputs

images is the sliced batch, frame_count is how many frames you actually got out (handy for wiring into Video Save's parameters or a downstream interpolate node), and summary describes what was extracted, including any skipped/invalid indices in explicit mode.

Install

cd ComfyUI/custom_nodes
git clone https://github.com/TensorVizion/OmniNodes

Restart ComfyUI; the node lives under TensorVizion/Video as Video Trim / Extract ✂️. No extra dependencies - it's pure PyTorch on top of what ComfyUI already ships.

Where people get burned

  • The silent swap. If end_frame comes out below start_frame, the node swaps them rather than erroring. Handy for lazy typing, treacherous if you expected an error to catch a wrong value. Check the summary.
  • Empty explicit list. Give it nothing valid and you get back a zero-frame batch, not an error. An empty batch flowing into Video Save is the kind of thing that produces a mysteriously empty file, so glance at frame_count before you render.
  • Expecting time-based trimming. Everything here is frame-indexed. If you're thinking in seconds, multiply by your source FPS first - the pack's Video Load reports the FPS in its summary for exactly this.

The pairing worth remembering: Video Load → Video Scene Detect → this node in explicit mode → Video Save is the whole "cut out the good scenes" pipeline, and this is the only node in it that actually does the cutting. It's not glamorous, but it's the one you'll actually use.

CategoryTensorVizion/Video

Inputs (5)

NameTypeDefaultDescription
imagesIMAGE
modeCOMBOrange2 options: range, explicit
start_frameINT00–100000
end_frameINT-1-1–100000
explicit_indicesSTRING

Outputs (3)

NameTypeDescription
imagesIMAGE
frame_countINT
summarySTRING