ComfyUI Extension: Comfyui-SceneDetect
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.
Comfyui-SceneDetect is a ComfyUI custom node that uses PySceneDetect to locate scene boundaries in a video and emit one representative frame per scene as an IMAGE batch. It also returns per-scene metadata as JSON (STRING) and the total number of detected scenes (INT).
README
Comfyui-ZNGB-SceneDetect
ComfyUI custom node based on PySceneDetect. It detects scene boundaries from a loaded video, outputs one representative frame per scene, exports each scene as an mp4 segment, and returns scene metadata as JSON.
Node
- Display name: ZNGB-PySceneDetect
- Category: Video/PySceneDetect
- Class name: PySceneDetectToImages
Features
- Detect scenes with content, adaptive, or threshold mode
- Output one representative image for each detected scene
- Export each detected scene as an mp4 segment into ComfyUI temp
- Return structured scene metadata in JSON format
- Optionally write thumbnail jpg files for each scene
Installation
Clone or copy this folder into your ComfyUI custom_nodes directory:
custom_nodes/Comfyui-ZNGB-SceneDetect
Install dependencies:
pip install -r requirements.txt
Current dependencies:
- scenedetect>=0.6,<0.7
- opencv-python>=4.9,<5
- numpy
Restart ComfyUI after installation.
Inputs
Required
-
image
- Type: IMAGE
- Usually connected from the image/frame output of a video loading node
- LATENT input is rejected at runtime
-
video_info
- Type: VHS_VIDEOINFO
- Connect the fourth output from VHS Load Video or another compatible video node that provides fps metadata
-
method
- Options: content, adaptive, threshold
- Scene detection strategy used by PySceneDetect
-
threshold
- Float
- Detection threshold for the selected method
-
min_scene_len_sec
- Float
- Minimum scene duration in seconds
-
min_scene_len_frames
- Int
- Minimum scene duration in frames
-
luma_only
- Boolean
- When enabled, scene detection uses luminance only
Optional
-
representative
- Options: start, middle, end
- Chooses which frame to output for each scene
-
max_width
- Int
- Resize representative frames to fit within this width while keeping aspect ratio
-
max_height
- Int
- Resize representative frames to fit within this height while keeping aspect ratio
-
limit_scenes
- Int
- If greater than 0, only the first N detected scenes are used
-
write_thumbs
- Boolean
- When enabled, writes thumbnail jpg files to disk
-
thumbs_dir
- String
- Output folder for thumbnails
- If left empty, thumbnails are written to ./scene_thumbs
Outputs
-
images
- Type: IMAGE
- Batch of representative frames, one frame per scene
-
scenes_json
- Type: STRING
- JSON string containing fps, method, thresholds, and per-scene metadata
-
scene_count
- Type: INT
- Total number of scenes returned by the node
-
path_string
- Type: STRING
- Newline-separated absolute paths of exported scene mp4 files
Exported Segment Files
Each run creates a new random output folder under ComfyUI temp:
ComfyUI/temp/transnet_segments_0833f5f6/
Inside that folder, segments are written as:
segment_001.mp4
segment_002.mp4
segment_003.mp4
This avoids filename collisions between different workflow runs.
Typical Workflow
- Use a compatible video loader such as VHS Load Video.
- Connect the frame/image output to image.
- Connect the video metadata output to video_info.
- Run ZNGB-PySceneDetect.
- Use images for preview, selection, or downstream image workflows.
- Use scenes_json for metadata-driven logic.
- Use path_string if you need the exported mp4 paths in later nodes.
Notes
- The node requires a valid fps value in video_info. If fps is missing, execution will fail.
- The node converts the input image batch back into a temporary video file before scene detection.
- If no representative frame can be produced, the node returns a 1x1 black fallback image for type consistency.
- Exported scene videos are written into ComfyUI's temp directory, not the output directory.
Included Workflow
This repository includes an example workflow file:
- workflow/pysence-detect_workflow.json
License
See LICENSE.
Run ComfyUI workflows without the setup
No installs, no CUDA version roulette, no GPU sitting idle on your bill. Bring a workflow and run it in the browser.