Skip to content

Repository files navigation

ComfyUI Wan2.2 Video Loop Generator

A custom ComfyUI node for creating seamless video loops using Wan2.2, with automatic frame chaining between iterations.

Features

  • 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

Installation

  1. Copy this entire folder to your ComfyUI custom_nodes directory:

    ComfyUI/custom_nodes/comfyui-wan-loop/
    
  2. Restart ComfyUI

  3. The node will appear under video/wan2.2 category as "Wan2.2 Video Loop Generator"

Required Models

This node requires the following Wan2.2 models to be installed in your ComfyUI models directory:

UNet Models (GGUF format)

  • Wan2.2-I2V-A14B-HighNoise-Q3_K_S.gguf
  • Wan2.2-I2V-A14B-LowNoise-Q3_K_S.gguf

LoRA Models

  • Wan2.2-Lightning_I2V-A14B-4steps-lora_HIGH_fp16.safetensors
  • Wan2.2-Lightning_I2V-A14B-4steps-lora_LOW_fp16.safetensors

VAE and CLIP

  • wan_2.1_vae.safetensors
  • umt5_xxl_fp8_e4m3fn_scaled.safetensors

Available Nodes

This package provides multiple nodes for different use cases:

1. Wan2.2 Video Loop (Dynamic Prompts)Recommended

  • 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

2. Wan2.2 Video Loop Generator

  • Fixed prompt inputs (prompt_1 through prompt_20)
  • All optional prompts always visible
  • Good for consistent workflows

3. Test Wan Loop Node

  • Simple test node to verify installation

Usage

Dynamic Prompts Node (Recommended)

Required:

  • start_image: Initial image for the first video segment
  • negative_prompt: Shared negative prompt for all segments
  • video_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_2 through prompt_10: Additional prompts as needed
  • skip_frames: Frames to skip when extracting last frame (default: 80)
  • seed: Random seed (-1 for random)

Outputs

  • final_video: Complete concatenated video with all segments
  • last_frame: Final frame for potential further chaining
  • generation_info: JSON string with generation statistics

Example Workflow

Using Dynamic Prompts Node:

  1. Add "Wan2.2 Video Loop (Dynamic Prompts)" node to your workflow
  2. Load your starting image and connect to start_image
  3. 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"
  4. Leave unused prompt inputs unconnected
  5. Set your video parameters
  6. 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

Technical Details

Architecture

  • 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

Performance

  • 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

Error Handling

  • 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

Troubleshooting

Common Issues

  1. "Failed to load models": Ensure all required Wan2.2 models are installed
  2. "No video segments generated": Check that prompts are valid and models loaded
  3. Memory errors: Reduce video_length or use smaller dimensions
  4. Slow generation: This is normal - each iteration takes several minutes

Debug Information

The generation_info output provides detailed information:

  • Number of segments generated
  • Total frame count
  • Model cache statistics
  • Prompts used
  • Video settings applied

Model Locations

Models should be placed in these ComfyUI directories:

  • UNet: models/diffusion_models/
  • LoRA: models/loras/
  • VAE: models/vae/
  • CLIP: models/text_encoders/

Based On

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.

License

This project follows the same license as ComfyUI.

About

Simplified iterative nodes for comfyui that allow for longer videos based on number of prompts

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages