🎬 视频分段拆帧
Cut a video into frame-clips and keep the audio for your LLM pipeline
- num_clips
- clips
- audio
This is the node you reach for when you need a long video understood by something that isn't a video model. Say you want to caption a 10-minute clip, summarize it with an LLM, or generate new frames from a reference shot. Video models choke on length and VRAM; this node's job is to break the video into bite-sized chunks - a list of frame clips - and hand you the audio track alongside, so you can process piece by piece.
It ships in comfyUI_LLM, a Chinese-language grab bag from XieJunchen that's mostly about wiring LLMs and cloud storage into ComfyUI. The node's display name is "🎬 视频分段拆帧" (video segmentation + frame extraction). It's listed under 云服务 (cloud services), which is misleading - this one is fully local.
How it works
Under the hood it's OpenCV plus a side of ffmpeg. cv2.VideoCapture reads the file frame by frame, converts BGR to RGB, normalizes to float32 in [0,1], and piles frames into a clips list - one entry every max_frames_per_clip frames. Meanwhile ffmpeg extracts the whole audio track to a temp WAV (44.1 kHz, stereo), and torchaudio loads it into ComfyUI's standard AUDIO dict (waveform + sample_rate). No audio in the file? You get a silent placeholder instead of a crash, which is thoughtful - downstream audio nodes won't explode.
Inputs that matter
Only two, both plain strings/ints, which keeps it simple:
video_path- type the path to your video (.mp4, whatever). This is a raw string, not a file picker, and it's resolved relative to where ComfyUI runs, not yourinput/folder. Absolute paths are your friend.max_frames_per_clip- the ceiling per clip, 1–1000, default 30. At 30 fps that's a 1-second clip; for an LLM that just needs a few frames, 100+ is usually plenty.
Outputs
num_clips(INT) - how many clips you got, handy for wiring an index loop.clips(LIST) - the actual payload: a Python list of dicts, each{"frames": tensor, "audio": dict}. Feed this into this pack'sGetVideoClipByIndexto pull one clip out as IMAGE + AUDIO.audio(AUDIO) - the full soundtrack, same track attached to every clip. Wire it to a video encoder or an audio-consumer.
Installing it
ComfyUI Manager → search comfyUI_LLM → install, or:
cd ComfyUI/custom_nodes
git clone https://github.com/XieJunchen/comfyUI_LLM
# then restart ComfyUI
Here's the trap: the pack's requirements.txt lists pillow, numpy, requests, qiniu, openai, imageio-ffmpeg, torch, torchaudio - but not OpenCV, which this node imports as cv2 at the top of the module. You'll get an import error until you pip install opencv-python yourself. You also need an ffmpeg binary on your PATH for the audio step. Neither is mentioned in the README, which is basically one sentence plus screenshots - read the source if something's off.
Common issues
No module named cv2- see above. Install opencv-python into ComfyUI's Python env.- Audio comes back empty - no audio stream, or ffmpeg isn't on PATH. Check the console for the "无音轨" (no audio track) warning.
无法打开视频文件(can't open video) - the path is wrong or relative to the wrong directory; give an absolute path.- Frames aren't resized, so the node assumes your source is one consistent resolution. It is - it's one file. Don't overthink it.
One honest caveat: there's no community footprint on this node to lean on - it's a personal-pack utility. But the mechanism is simple and it works as written.
Inputs (2)
| Name | Type | Default | Description |
|---|---|---|---|
| video_path | STRING | your_video.mp4 | — |
| max_frames_per_clip | INT | 301–1000 | — |
Outputs (3)
| Name | Type | Description |
|---|---|---|
| num_clips | INT | — |
| clips | LIST | — |
| audio | AUDIO | — |