Unlock the potential for infinite video narratives with this powerful ComfyUI workflow. Designed specifically for the WAN2.2 5B text-to-video model, this setup automates the creation of long, coherent video sequences by implementing an intelligent feedback loop. It doesn't just string clips together; it creates a visually consistent and dynamically evolving story.
β¨ Key Features & Highlights:
AI-Powered Prompt Chaining: The core of this workflow. An Ollama multi-modal LLM (like Qwen2.5-VL) analyzes the last frame of each generated video clip and automatically creates a new, detailed prompt for the next segment. This ensures each new clip logically continues from the previous one.
Perfect for Long-Form Content: Generate multi-part scenes, evolving transformations, or endless walking cycles without manual intervention. The loop is configurable to run for any number of iterations.
Superior Visual Consistency: Incorporates a color matching node (
easy imageColorMatch) to harmonize the colors and tones between segments, preventing jarring visual jumps and creating a seamless flow.Built-In Quality Enhancement: Includes a RIFE VFI frame interpolation node that doubles the frame rate of the final assembled video, resulting in buttery-smooth motion.
Fully Automated Pipeline: From loading the initial image to rendering the final high-quality video, the process is hands-free after the initial setup.
π οΈ How It Works:
Preparation: The workflow starts with your initial image, which is scaled and analyzed.
Ollama Vision Analysis: The LLM examines the image and generates a dynamic, movement-focused prompt tailored for the WAN2.2 model.
Video Generation: The WAN2.2 5B model generates a short video clip (~5 seconds) based on this AI-crafted prompt.
Loop & Refine: The last frame is extracted, color-corrected, and fed back to Ollama to generate the next prompt. This loop repeats for your set number of iterations.
Final Assembly: All individual clips are combined into a single, smooth, long-form video file.
π¦ What's Included:
.jsonWorkflow file for ComfyUI.A detailed breakdown of the node groups and their functions.
Recommended settings for optimal results.
βοΈ Recommended Models:
Text-Image-to-Video:
wan2.2_ti2v_5B_fp16.safetensorsLoRA:
Wan2_2_5B_FastWanFullAttn_lora_rank_128_bf16.safetensors(for faster generation)VAE:
wan2.2_vae.safetensorsLLM (for Ollama): A vision-capable model like
qwen2.5-vl:7borllava-1.6
π― Ideal For:
Creating music videos with evolving visuals.
Generating long animations and story sequences.
Producing dynamic social media content loops.
Experimenting with AI-driven storytelling and scene progression.
Disclaimer: This workflow requires a properly configured ComfyUI environment with the necessary custom nodes (ComfyUI-Easy-Use, Video-Helper-Suite, ComfyUI-Ollama, ComfyUI-Frame-Interpolation) and an Ollama server running with a vision model.
Description
FAQ
Comments (9)
Ive tried running a few of these and the problem with wan2.2 currently is that after the 2nd loop the last frame starts to deteriorate significantly, after the 4th loop you may get something drastically different and much lower quality than the original image that doesn't match the overall composition.
thats kinda expected from a workflow that uses last frame with its degraded quality and llm that writes a completely new prompt for each cycle π
@TurboCoomerΒ Yes, you can select "keep context" in the Ollama node and edit the prompt directly for a more personalized storyline.
Very nice, is there any node to use AI context. or connecting it to studio LLM?
Thanks π and to answer your questions not from my knowledge.
Your vram management is great, thanks for showing examples of where and when to use unload node on native ksampler workflow.
How can I install that ''qwen2.5-vl:7b or llava-1.6'' models?? Is nstw viable?
hello,
You have to give the explicit way to start ollama if your models aren't store at the ollama front end app. (which is different than ollama server).
for linux and windows, you can pull modele in bash
For windows you also can via new front end app.
Here is a fully code for windows (in Bash) to help you that way. Open a bash terminal, create a file (touch ollama_manager.sh), edit it ( nano ollama_manager.sh) and paste :
#!/usr/bin/env bash
# ======================================================
# π§ OLLAMA PROCESS MANAGER - Machine5 Pro v4.8
# Author: GPT-5 (custom for Machine5)
# ------------------------------------------------------
# β Auto-detect and set OLLAMA_MODELS (E:\modeles_ollama)
# β LAN mode via OLLAMA_HOST=0.0.0.0:11434
# β Q to quit logs (non-blocking)
# β Scan LAN + prompt over LAN ready
# ======================================================
USER_NAME=${USERNAME:-$(whoami)}
OLLAMA_DIR="/c/Users/$USER_NAME/AppData/Local/Programs/Ollama"
OLLAMA_EXE="$OLLAMA_DIR/ollama.exe"
PORT=11434
LOG_DIR="/c/Users/$USER_NAME/.ollama"
LOG_FILE="$LOG_DIR/ollama_live.log"
# ------------------------------------------------------
# π§© Auto-detect OLLAMA_MODELS location
detect_models_dir() {
local default_dir="/c/Users/$USER_NAME/.ollama/models"
local e_drive_dir="/e/modeles_ollama"
if [ -d "$e_drive_dir" ]; then
echo "$e_drive_dir"
elif [ -d "$default_dir" ]; then
echo "$default_dir"
else
echo "/c/Users/$USER_NAME/.ollama/models"
fi
}
# ------------------------------------------------------
header() {
clear
echo "======================================="
echo " π§ OLLAMA PROCESS MANAGER v4.8"
echo "======================================="
echo "User : $USER_NAME"
echo "Path : $OLLAMA_EXE"
echo "Port : $PORT"
echo "LAN : $(hostname)"
echo "---------------------------------------"
}
detect_ip() {
local ip
ip=$(ipconfig | grep "IPv4" | grep -v "127.0.0.1" | awk '{print $NF}' | head -n 1)
[[ -z "$ip" ]] && ip="Not detected"
echo "$ip"
}
is_running() {
tasklist | grep -Ei "ollama\.exe" >/dev/null 2>&1
}
# ------------------------------------------------------
start_ollama() {
if is_running; then
echo "β οΈ Ollama is already running."
else
echo "π Starting Ollama server (LAN 0.0.0.0)..."
mkdir -p "$LOG_DIR"
taskkill //IM "Ollama App.exe" //F >/dev/null 2>&1
MODELS_DIR=$(detect_models_dir)
export OLLAMA_MODELS="$MODELS_DIR"
export OLLAMA_HOST="0.0.0.0:11434"
echo "π Environment set:"
echo " OLLAMA_HOST=$OLLAMA_HOST"
echo " OLLAMA_MODELS=$OLLAMA_MODELS"
echo
nohup "$OLLAMA_EXE" serve >"$LOG_FILE" 2>&1 &
sleep 3
if is_running; then
echo "β Ollama started successfully."
else
echo "β Failed to start Ollama."
fi
fi
echo
}
# ------------------------------------------------------
stop_ollama() {
echo "π Stopping Ollama..."
taskkill //IM ollama.exe //F >/dev/null 2>&1
taskkill //IM Ollama.exe //F >/dev/null 2>&1
taskkill //IM "Ollama App.exe" //F >/dev/null 2>&1
echo "β Ollama stopped."
echo
}
# ------------------------------------------------------
check_status() {
if is_running; then
echo "β Ollama process is RUNNING"
if netstat -ano | grep -q "0\.0\.0\.0:$PORT"; then
echo "π LAN mode: β ACTIVE (IPv4)"
elif netstat -ano | grep -q "\[::\]:$PORT"; then
echo "π LAN mode: β ACTIVE (IPv6)"
else
echo "π LAN mode: β LOCAL ONLY"
fi
echo "π Model directory: $(detect_models_dir)"
else
echo "π₯ Ollama process is STOPPED"
fi
echo
}
# ------------------------------------------------------
show_logs() {
[[ ! -f "$LOG_FILE" ]] && echo "βΉοΈ No log file found." && return
echo "π Displaying live logs from: $LOG_FILE"
echo "π’ Press [Q] to quit log view."
echo "---------------------------------------"
tail -f "$LOG_FILE" &
TAIL_PID=$!
while true; do
read -t 1 -n 1 key
if [[ "$key" == "q" || "$key" == "Q" ]]; then
kill $TAIL_PID 2>/dev/null; wait $TAIL_PID 2>/dev/null
echo; echo "β Log viewer closed."; echo
break
fi
done
}
# ------------------------------------------------------
lan_scan() {
echo "π Scanning LAN for active Ollama servers..."
ip_base=$(detect_ip | cut -d'.' -f1-3)
[[ "$ip_base" == "Not" ]] && echo "β Unable to detect subnet." && return
echo "Subnet detected: ${ip_base}.0/24"
echo "---------------------------------------"
for i in $(seq 1 254); do
host="${ip_base}.${i}"
(
data=$(curl -s --max-time 1 "http://${host}:${PORT}/api/tags")
if [[ -n "$data" ]]; then
version=$(curl -s --max-time 1 "http://${host}:${PORT}/api/version" | jq -r '.version' 2>/dev/null)
models=$(echo "$data" | jq -r '.models[]?.name' 2>/dev/null | tr '\n' ',' | sed 's/,$//')
echo "β Ollama @ ${host}:${PORT} | Ver: ${version:-unknown} | Models: ${models:-none}"
fi
) &
done
wait
echo "---------------------------------------"
echo "β Scan complete."
echo
}
# ------------------------------------------------------
test_api() {
local ip_local ip_lan
ip_local="localhost"
ip_lan=$(detect_ip)
echo "π Testing Ollama API..."
echo "---------------------------------------"
for target in "$ip_local" "$ip_lan"; do
echo "β Testing http://$target:$PORT/api/tags"
response=$(curl -s --max-time 3 "http://$target:$PORT/api/tags")
[[ -n "$response" ]] && echo "β $target responded." || echo "β οΈ $target no response."
echo
done
}
# ------------------------------------------------------
menu() {
header
check_status
echo "1οΈβ£ Start Ollama"
echo "2οΈβ£ Stop Ollama"
echo "3οΈβ£ Show live logs (press Q to quit)"
echo "4οΈβ£ Restart Ollama"
echo "5οΈβ£ Scan LAN for Ollama servers"
echo "6οΈβ£ Test API (local + LAN)"
echo "0οΈβ£ Exit"
echo
read -p "Choose an option [0-6]: " choice
case $choice in
1) start_ollama ;;
2) stop_ollama ;;
3) show_logs ;;
4) stop_ollama; start_ollama ;;
5) lan_scan ;;
6) test_api ;;
0) echo "π Exiting..."; exit 0 ;;
*) echo "β Invalid choice."; sleep 1 ;;
esac
read -p "Press Enter to return to menu..."
menu
}
menu
According to that way you should be able to select in the comfyui front end, the model you have downloaded before. Really simple.
I think that for nsfw, you mus'nt use lora lighting that breaks nsfw use.
SDKtertiaire2