ComfyUI Extension
ComfyUI-EditRouter
Custom node to detect an edit in a batch of images.
clayton-grey/ComfyUI-EditRouter
Nodes1
On cloudLocal install
Categoryvideo/analysis
Stars0
Updated7 months ago
Nodes (1)
Readme
ComfyUI - Edit Router Custom Node
This custom node detects the first edit in a batch of frames and splits the batch into:
- before_edit: frames before the cut
- after_edit: frames after the cut
If there is no edit, the node passes all frames through before_edit and returns an empty after_edit.
This is intended for video frame batches where you want to route “pre-edit” frames and “post-edit” frames into different branches of a workflow. This is useful if you want to apply VFI within a workflow, as hard edits recieve undesirable transition frames.
Node
Edit Router
Category: video/analysis
Inputs
images(IMAGE): A batch of frames ([B,H,W,C]).threshold(FLOAT, default0.06): Sensitivity for detecting an edit.stable_frames(INT, default3): Number of consecutive “stable” frames required to consider the transition finished (used to trim short fades/dissolves).
Outputs
before_edit(IMAGE): Frames before the detected edit.after_edit(IMAGE): Frames after the edit (fade frames removed).
How it works (high level)
- Converts frames to luma (brightness) and downsamples for more stable scoring.
- Computes a per-frame difference score between consecutive frames.
- Finds the first frame where the score exceeds
threshold(the edit boundary). - If the edit looks like a short transition (fade/dissolve), it trims frames until the signal returns to “normal motion” for
stable_framesframes. - Returns the split batches.
Tuning guide
If it misses edits
- Lower
threshold(try0.04→0.05).
If it triggers on normal motion / camera movement
- Raise
threshold(try0.08→0.12).
If it leaves a couple blended frames from a short fade
- Increase
stable_frames(try4to6).
If it trims too aggressively (removes real post-cut frames)
- Decrease
stable_frames(try1to2).
Notes / limitations
- Detects only the first edit in the batch.
- Best for hard cuts and short fades. Long, slow transitions may be treated as “always transitioning” depending on content.
- Designed around an assumed frame rate of 16 fps (if you changed the implementation to hardcode fps).
Install / usage
- Place this custom node in:
ComfyUI/custom_nodes/ComfyUI-EditRouter/ - Restart ComfyUI.
- Search for “Edit Router” in the node menu.
- Feed an
IMAGEbatch (e.g. from a video loader) into the node. - Route
before_editandafter_editto separate branches.
Troubleshooting
The node doesn’t show up:
- Confirm the file has
NODE_CLASS_MAPPINGSandNODE_DISPLAY_NAME_MAPPINGS. - Confirm the folder is under
custom_nodes/and ComfyUI was restarted.
after_edit is empty but I expected frames:
- If the detected edit occurs near the end of the batch, there may not be many “after” frames.
- Try lowering
stable_framesor raisingthreshold. - (If you still hit this) add temporary debug prints for
start,end, andb.