获取视频信息
How long is that video, actually? Ask VideoInfo
- 视频时长(秒)
- 视频总帧数
- 视频帧率(FPS)
- 视频宽度
- 视频高度
VideoInfo (获取视频信息, "get video info") reads the basics off a video file and hands them to your graph as numbers: duration in seconds, total frame count, frames-per-second, width, and height. It's the video version of the pack's AutioInfo for audio, and it exists because video workflows constantly need these numbers inside the graph - to size a latent, to set a loop count equal to the frame count, to compute how many seconds of audio a clip needs.
It's a boring, load-bearing utility, which is the highest compliment a node like this can get. If you've ever hardcoded 1280×720 and a frame count into a video workflow, then swapped in a differently-sized clip and watched the graph break, you know why you reach for this. The numbers come straight from the file, every run.
How it works
The mechanism is a single cv2.VideoCapture read via OpenCV (the pack installs opencv-python). It opens the file at the path you give it, pulls CAP_PROP_FPS, CAP_PROP_FRAME_COUNT, CAP_PROP_FRAME_WIDTH, and CAP_PROP_FRAME_HEIGHT, computes duration as frame_count / fps, and returns all five. If the file doesn't exist it raises a clear error; if OpenCV can't open it (corrupt file, unsupported container), it raises another.
Inputs and output
video_path- aSTRINGpath to the video file.- Outputs, in order:
视频时长(秒)(duration) -FLOAT, seconds.视频总帧数(total frames) -INT.视频帧率(FPS)-INT. Yes, integer - a 29.97fps file reads as29, so don't use this output for frame-accurate math.视频宽度(width) /视频高度(height) -INTpixels.
Install
In yanlang0123/ComfyUI_Lam - Manager search "ComfyUI_Lam", or:
cd ComfyUI/custom_nodes
git clone https://github.com/yanlang0123/ComfyUI_Lam
restart. It needs OpenCV, which is in the pack's requirements.txt - this is one of the few nodes in this list where the README's install.bat step is actually relevant, since a bare ComfyUI won't have cv2. If you already have OpenCV from another pack, you're fine.
Gotchas
The INT FPS return is the trap: duration is computed with the real fps before truncation, so duration stays accurate, but the displayed/returned FPS is floored. For frame-exact work (matching audio to frames), recompute from duration and total_frames instead of trusting the FPS output. Also, video_path wants a real filesystem path - the string output of a loader like LoadVideo or AutioPath-style path nodes works, but ComfyUI's temp-video convention (a temp_... filename) means you need to resolve it first. Minor, but it's the difference between "works" and "File does not exist."
Inputs (1)
| Name | Type | Default | Description |
|---|---|---|---|
| video_path | STRING | — |
Outputs (5)
| Name | Type | Description |
|---|---|---|
| 视频时长(秒) | FLOAT | — |
| 视频总帧数 | INT | — |
| 视频帧率(FPS) | INT | — |
| 视频宽度 | INT | — |
| 视频高度 | INT | — |