Nodes/ComfyUI Video Segmentation Node/🐾MiaoshouAI Segment Video
ComfyUI Node

🐾MiaoshouAI Segment Video

Split your video into shots without touching an editor

By miaoshouai·Created about a year ago·Updated about a year ago· 40
🐾MiaoshouAI Segment Video
  • TransNet_model
  • video
  • segment_paths
  • path_string
threshold0.50
min_scene_length30
output_dir

First, get the name straight, because it'll trip you up. When most ComfyUI people say "video segmentation" they mean object segmentation - SAM2-style masks to feed Wan-Animate or a ControlNet. That is not this. TransNetV2_Run does scene segmentation: it watches a video, finds where the cuts are - the moment one shot ends and the next begins - then exports each shot as its own MP4. Cut detection, not masking. If you've ever wanted footage auto-split into scenes, this is the node.

This is the heart of the whole MiaoshouAI pack, and the node you actually came for. It takes a TransNet model (from the sibling "🐾MiaoshouAI Load TransNet Model" node), runs it over your video, and writes the detected shots to disk. TransNetV2 is a real, published network - the shot-transition-detection model from the 2020 paper (arXiv:2008.04838), the architecture a lot of video-tooling scene detection is built on.

How it works

The node reads your video frame by frame with OpenCV and resizes every frame down to a comically tiny 48×27 before running the network over the whole clip in one pass. That downscale is why this is fast and light - this is not a diffusion model chewing through VRAM. The network scores each frame for "is this a shot boundary?", the threshold slider decides how confident it has to be, and any detected shot shorter than min_scene_length gets merged into its neighbor instead of emitted as a two-frame clip. Then it hands the boundary list to ffmpeg, which re-encodes each shot as H.264 with AAC audio (crf 23, preset fast) and names them segment_001.mp4, segment_002.mp4, and so on.

The 48×27 trick keeps the GPU bill near zero, but the memory bill is elsewhere: the node loads the entire video into RAM as one numpy array before inference starts. A long 1080p file can eat a few gigabytes just sitting there. Keep that in mind before pointing it at a two-hour movie.

The inputs that matter

  • TransNet_model - wire in the output of the Load TransNet Model node. No model, no run.
  • threshold (default 0.5) - how sure the network must be before it declares a cut. Lower finds more cuts, including fades and quick flashes; if you're getting chopped to bits, nudge it toward 0.8.
  • min_scene_length (default 30) - in frames, not seconds. At 30 fps that's one second. Pre-cutting footage for a training set? Crank this to 60–90 so you get longer, less jittery segments.
  • output_dir - leave this empty and you will regret it. Empty means "write to a random UUID folder inside ComfyUI's temp directory," which ComfyUI periodically cleans. Set a real folder if you want the segments to survive the session.

There's also an optional video input - a VIDEO output from a generation node (it saves it to a temp file first) or a plain string file path.

Outputs

  • segment_paths - a LIST you can feed into "🐾MiaoshouAI Select Video" to grab one scene.
  • path_string - the same list joined with newlines, which is exactly the format "🐾MiaoshouAI Zip Compress" expects.

If the node can't read your video, both come back empty. Check the console log for the real error.

Install

Same as every node in this pack:

cd ComfyUI/custom_nodes
git clone https://github.com/miaoshouai/ComfyUI-Video-Segmentation
cd ComfyUI-Video-Segmentation
pip install -r requirements.txt

…then restart ComfyUI. Or skip the terminal: ComfyUI Manager → Custom Nodes → search "MiaoshouAI" → Install. The model weights download automatically from HuggingFace on first run (into ComfyUI/models/VLM/transnetv2-pytorch-weights/), no key needed.

Two install gotchas, both from reading the repo rather than the README. First, requirements.txt lists tensorflow 2.x even though the shipped code is pure PyTorch - you'll still get that ~600MB install because pip reads the whole file, so don't panic when something named TensorFlow shows up. Second, ffmpeg must be on your PATH; the node shells out to it directly to build segments. And if a comment or the README tells you to pip install transnetv2, ignore it - the code imports transnetv2_pytorch, not transnetv2.

Where people get burned

The empty-output_dir trap above is the big one - your segments silently vanish into temp. The RAM thing is second. And remember the model-loading step: TransNetV2_Run doesn't download anything itself, so a fresh workflow that skips the Load node fails immediately. All three are fixable in about a minute, and after that this thing just works - which is more than you can say for most video nodes.

CategoryMiaoshouAI Video Segmentation

Inputs (5)

NameTypeDefaultDescription
TransNet_modelTRANSNET_MODEL
thresholdFLOAT0.500.1–1
min_scene_lengthINT301–300
output_dirSTRING
videooptVIDEO

Outputs (2)

NameTypeDescription
segment_pathsLIST
path_stringSTRING