Custom node for ComfyUI that loads an .mp4 video and outputs two images:
- first frame
- last frame
- Reads a video file from
ComfyUI/input(by filename) or from an absolute path. - Outputs two
IMAGEvalues:FIRST_FRAMEandLAST_FRAME. - Supports drag & drop of an
.mp4directly onto the node (UI feature).
- Add the node Video: First & Last Frame to your graph.
- Provide the input video using one of these methods:
- Set
videoto a filename fromComfyUI/input. - Set
videoto an absolute path to an.mp4file. - (UI) Drag & drop an
.mp4onto the node. It will upload intoComfyUI/inputand setvideoautomatically.
- Set
- Execute the graph.
- Use outputs
FIRST_FRAMEandLAST_FRAME(both are ComfyUIIMAGE).
- The core node works in API mode, but drag & drop is UI-only (it adds an upload route + frontend JS).
- In the ComfyUI, open Manager.
- Install this node from the list (search by repo name) or paste the repo URL.
- Restart ComfyUI after installation.
The recommended way to install is via ComfyUI-Manager. Manual install is best treated as a fallback.
-
Copy/clone this repo into
ComfyUI/custom_nodes/, for example:ComfyUI/custom_nodes/comfyui-videoframenode(this repo root is the node folder)
-
Run commands inside the same Python environment that ComfyUI uses (usually ComfyUI's venv):
Windows (PowerShell):
-
Activate venv (example):
& "D:\\ComfyUI\\.venv\\Scripts\\Activate.ps1"Note: Windows often blocks running
.ps1scripts by default.- Option A (temporary for this shell only):
Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Scope Process -Force(This applies only to the current PowerShell process; closing the terminal reverts it.) - Option B: use the
.batactivator instead (works well from CMD):"D:\\ComfyUI\\.venv\\Scripts\\activate.bat"
- Option A (temporary for this shell only):
-
Check what's already installed (recommended before installing anything):
python -m pip show opencv-python imageiopython -c "import cv2, imageio; print('cv2', cv2.__version__, 'imageio', imageio.__version__)"- (optional)
python -m pip list | findstr /i "opencv imageio torch"
-
Install deps:
pip install -r requirements.txt
Note about
torch/ Pylance- This node uses
torchbecause ComfyUI images aretorch.Tensor. torchis usually already included with ComfyUI, so you typically don't need to install it separately.- ComfyUI commonly uses a CUDA-specific build (for example
torch-cu130). Installing the plaintorchpackage viapipcan override the working CUDA build and break GPU acceleration. - For that reason,
torchis intentionally commented out inrequirements.txtin this repo. - If Pylance shows
Import "torch" could not be resolved, make sure VS Code is using the same environment (venv) as ComfyUI.
-
-
Restart ComfyUI.