A custom ComfyUI node for creating seamless video loops using Wan2.2, with automatic frame chaining between iterations.
- Seamless Video Loops: Automatically chains the last frame of each segment to the next
- Dynamic Prompts: Support for multiple prompts to create varied video segments
- Model Caching: Efficient reuse of loaded models across iterations
- Frame Extraction: Smart last frame detection for smooth transitions
- Progress Tracking: Visual feedback during generation process
- Error Handling: Graceful failure recovery with partial results
-
Copy this entire folder to your ComfyUI
custom_nodesdirectory:ComfyUI/custom_nodes/comfyui-wan-loop/ -
Restart ComfyUI
-
The node will appear under
video/wan2.2category as "Wan2.2 Video Loop Generator"
This node requires the following Wan2.2 models to be installed in your ComfyUI models directory:
Wan2.2-I2V-A14B-HighNoise-Q3_K_S.ggufWan2.2-I2V-A14B-LowNoise-Q3_K_S.gguf
Wan2.2-Lightning_I2V-A14B-4steps-lora_HIGH_fp16.safetensorsWan2.2-Lightning_I2V-A14B-4steps-lora_LOW_fp16.safetensors
wan_2.1_vae.safetensorsumt5_xxl_fp8_e4m3fn_scaled.safetensors
This package provides multiple nodes for different use cases:
- True dynamic prompt inputs - only use the prompt inputs you need
- Individual
prompt_1,prompt_2, etc. inputs (up to 10) - Only connected/filled prompts are processed
- Perfect for variable-length sequences
- Fixed prompt inputs (prompt_1 through prompt_20)
- All optional prompts always visible
- Good for consistent workflows
- Simple test node to verify installation
Required:
start_image: Initial image for the first video segmentnegative_prompt: Shared negative prompt for all segmentsvideo_length: Number of frames per segment (default: 81)width: Video width (default: 832)height: Video height (default: 480)fps: Output video frame rate (default: 16)
Optional:
prompt_1: First video segment prompt (required if no other prompts)prompt_2throughprompt_10: Additional prompts as neededskip_frames: Frames to skip when extracting last frame (default: 80)seed: Random seed (-1 for random)
final_video: Complete concatenated video with all segmentslast_frame: Final frame for potential further chaininggeneration_info: JSON string with generation statistics
Using Dynamic Prompts Node:
- Add "Wan2.2 Video Loop (Dynamic Prompts)" node to your workflow
- Load your starting image and connect to
start_image - Connect individual prompt inputs as needed:
prompt_1: "A peaceful lake at sunrise with gentle ripples"prompt_2: "The same lake at noon with bright sunlight"prompt_3: "The lake at sunset with golden reflections"prompt_4: "The lake at night with stars reflecting"
- Leave unused prompt inputs unconnected
- Set your video parameters
- Run the workflow
Automatic Processing:
- Processes only the connected/filled prompts (1-4 in this example)
- Generates 4 video segments seamlessly chained together
- Each segment's last frame becomes the next segment's starting image
- Outputs a single concatenated video loop
Flexible Usage:
- 1 prompt = Single 5-second video
- 3 prompts = 15-second seamless loop
- 10 prompts = 50-second complex transition sequence
- Workflow Template Engine: Converts single-shot workflows to reusable templates
- Model Cache: Efficient loading and reuse of Wan2.2 models
- Frame Processor: Handles frame extraction and format conversion
- Iteration Controller: Manages sequential workflow execution
- Models are loaded once and cached for all iterations
- Each iteration processes independently for memory efficiency
- Progress tracking shows current iteration status
- Supports up to 20 iterations per generation
- Graceful degradation if individual iterations fail
- Partial results returned if some segments generate successfully
- Detailed error messages in generation info output
- Model loading validation with fallback behavior
- "Failed to load models": Ensure all required Wan2.2 models are installed
- "No video segments generated": Check that prompts are valid and models loaded
- Memory errors: Reduce video_length or use smaller dimensions
- Slow generation: This is normal - each iteration takes several minutes
The generation_info output provides detailed information:
- Number of segments generated
- Total frame count
- Model cache statistics
- Prompts used
- Video settings applied
Models should be placed in these ComfyUI directories:
- UNet:
models/diffusion_models/ - LoRA:
models/loras/ - VAE:
models/vae/ - CLIP:
models/text_encoders/
This node builds upon the single-shot Wan2.2 workflow pattern and automates the frame chaining process that would otherwise require manual copy-pasting of nodes.
This project follows the same license as ComfyUI.