Nodes/ComfyUI-Apt_Preset/AD_VideoSeg_auto_auto
ComfyUI Node

AD_VideoSeg_auto_auto

Chop a long video at the cuts, get the first and last frame of each shot

By cardenluo·Created 2 years ago·Updated about 15 hours ago· 334
AD_VideoSeg_auto_auto
  • video
  • imagelsit
  • status
video_path
detector_mode自适应检测
enable_fade_blacktrue
sensitivity25
black_threshold10
min_scene_seconds0.5
frame_skip1
Seg_moldtrue
target_scene_count5
save_folderoutput/scene_ultimate

Feeding a ten-minute source video into a generation pipeline is mostly a waste: you want the shots, not the file. AD_VideoSeg_auto_auto (the mapped name of the AD_VideoSeg_auto class) runs scene detection over a video, splits it into per-shot files with FFmpeg, and hands back the first and last frame of every shot as an IMAGE batch - which is exactly the pair you need for a first-frame/last-frame interpolation workflow, a reference set, or a quick visual contact sheet before you commit to anything.

It's a utility node, not a model node. No diffusion, no VRAM. It is, however, the node in this pack most likely to fail on a fresh install, because it has two hard external dependencies and checks both at runtime.

How it works

The node resolves its input video from either the optional video wire or the video_path string. The resolution order is defensive to the point of being funny - it tries a video_info dict, a plain string, a list, a dict scanned for anything ending in .mp4/.mov/.webm/.avi/.mkv, then a series of common attributes. If the path doesn't exist it retries inside ComfyUI/input, then by basename. Blunt, but it means the node usually finds your file instead of making you fight it.

Then it runs PySceneDetect with the algorithm you chose, applies black-frame/fade detection if enable_fade_black is on, and - optionally - forcibly adjusts the result to a target shot count. Segments are written with FFmpeg into <save_folder>/<source-name>_<timestamp>/videos/, while OpenCV seeks to each segment's first and last frame, saves them as PNGs under .../images/, and accumulates them into one IMAGE batch.

That output is an OUTPUT_NODE too, so it runs even if nothing consumes it downstream - which is how it gets away with being mostly a side-effecting tool.

Inputs worth setting

  • video_path - a manual path, and honestly the most reliable route.
  • detector_mode - three algorithms. 内容检测 (content) is basic frame-change detection, fine for hard cuts. 自适应检测 (adaptive) is the default and the one you should keep: it survives handheld shake and fast motion without slicing every camera move. 哈希检测 (hash) compares perceptual hashes, so it holds up against watermarks and lighting shifts.
  • sensitivity - counter-intuitive by design: lower numbers are more sensitive and cut more finely, 1–200.
  • min_scene_seconds - the anti-confetti dial. Default 0.5s; raise it when a shot gets cut into five pieces.
  • frame_skip - 1 means every frame; 4 is four times faster and proportionally less precise.
  • Seg_mold + target_scene_count - when Seg_mold is on, the node forces the output to exactly N segments by merging or evenly dividing whatever detection found. Useful when you need a fixed number of render slots; useless for accuracy.
  • black_threshold - the brightness below which a frame counts as black or a fade, 0–100.
  • save_folder - defaults to output/scene_ultimate.

Outputs are imagelsit (yes, that spelling - an IMAGE batch of shot boundary frames) and status, a STRING summary you can print or feed to a text node.

Install

The pack installs like every other Apt_Preset node:

cd ComfyUI/custom_nodes
git clone https://github.com/cardenluo/ComfyUI-Apt_Preset
cd ComfyUI-Apt_Preset
pip install -r requirements.txt

On Windows the README points you at install.bat, which just loops over requirements.txt with your embedded Python - fine, but it's the same command with fewer surprises if you do it by hand.

This node additionally needs PySceneDetect (in requirements.txt as scenedetect), OpenCV, and a working FFmpeg on your PATH. Miss any one and you get a clear error rather than a mystery hang: "please install scenedetect opencv-python-headless", or the FFmpeg one pointing at BtbN's Windows builds. If ComfyUI's own FFmpeg works but this node says it doesn't, that's a PATH problem in the environment ComfyUI was launched from, not in the node.

What goes wrong

The category is Apt_Preset/AD/😺backup, and that's honest: this is the older auto-segmentation node kept around rather than the pack's headline feature. It's a scene splitter, so treat it as one.

Practically, the two things to watch are over-segmentation and the imagelsit shape. If you get 40 clips out of a two-minute video, you didn't change sensitivity - the default of 25 is aggressive on anything with fast cuts or strobe. And remember the output batch is two frames per scene, interleaved, so an 8-shot video gives you 16 images; if you're wiring it into a frame-pair workflow, budget for that rather than assuming one image per shot.

One more: the split videos land on disk, not in the graph. There's no upstream node to clean them up, so a folder of scene runs will accumulate - and at 4K sources that folder gets large fast.

CategoryApt_Preset/AD/😺backup

Inputs (11)

NameTypeDefaultDescription
video_pathSTRING
detector_modeCOMBO自适应检测3 options: 内容检测, 自适应检测, 哈希检测
enable_fade_blackBOOLEANtrue
sensitivityFLOAT251–200
black_thresholdFLOAT100–100
min_scene_secondsFLOAT0.50.1–10
frame_skipINT11–4
Seg_moldBOOLEANtrue
target_scene_countINT51–30
save_folderSTRINGoutput/scene_ultimate
videoopt*

Outputs (2)

NameTypeDescription
imagelsitIMAGE
statusSTRING