# Wan Workflow Recipe

Use this when you want the app to batch prompts through a local ComfyUI Wan 2.1 text-to-video workflow.

## What to download

1. Text encoder:
   - `umt5_xxl_fp8_e4m3fn_scaled.safetensors`
   - source: https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/blob/main/split_files/text_encoders/umt5_xxl_fp8_e4m3fn_scaled.safetensors

2. VAE:
   - `wan_2.1_vae.safetensors`
   - source: https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/blob/main/split_files/vae/wan_2.1_vae.safetensors

3. Diffusion model:
   - `wan2.1_t2v_1.3B_fp16.safetensors`
   - source: https://huggingface.co/Comfy-Org/Wan_2.1_ComfyUI_repackaged/blob/main/split_files/diffusion_models/wan2.1_t2v_1.3B_fp16.safetensors

4. Official native workflow JSON:
   - `text_to_video_wan.json`
   - source: https://comfyanonymous.github.io/ComfyUI_examples/wan/text_to_video_wan.json

## Where to put the files

- put `umt5_xxl_fp8_e4m3fn_scaled.safetensors` in `ComfyUI/models/text_encoders/`
- put `wan_2.1_vae.safetensors` in `ComfyUI/models/vae/`
- put `wan2.1_t2v_1.3B_fp16.safetensors` in `ComfyUI/models/diffusion_models/`

## What to set in the app

In Exocortex MediaForge:

1. Set `Engine` to `comfyui`
2. Set `Mode` to `video`
3. Set `Preset` to `Wan 2.1 T2V 1.3B`
4. Set `Server URL` to your local ComfyUI server, usually `http://127.0.0.1:8188`
5. Pick your saved API-format workflow JSON
6. Set `Expected Output` to `webm`
7. Click `Refresh Models`
8. Choose `diffusion_models`
9. Set `Model Override` to `wan2.1_t2v_1.3B_fp16.safetensors`

## Recommended node fields

If you use the official `text_to_video_wan.json` workflow:

- `Model Node`: `UNETLoader`
- `Model Input`: `model_name`
- `Prompt Node`: `CLIP Text Encode (Positive Prompt)`
- `Prompt Input`: `text`
- `Negative Prompt Node`: `CLIP Text Encode (Negative Prompt)`
- `Negative Prompt Input`: `text`

The official workflow also includes:

- `VAELoader` with `wan_2.1_vae.safetensors`
- `CLIPLoader` with `umt5_xxl_fp8_e4m3fn_scaled.safetensors`
- `EmptyHunyuanLatentVideo` with default `832 x 480` and `33` frames
- `SaveWEBM` as the actual clip output

If those titles do not resolve in your copy:

- use the exact node ids from your workflow instead
- the app accepts either node ids or matching node titles

## Practical defaults

- start with the official `832 x 480` / `33` frame workflow settings
- keep the workflow's own sampler and guidance at first
- test a single prompt in ComfyUI directly before running a batch in the app
- stick to `480p` first; Wan’s own docs recommend that for the 1.3B model
- once the workflow renders one clean clip, the app can handle the batch, filenames, manifest, and retry flow

## Output behavior

The official native workflow saves a real clip through `SaveWEBM`, so the app should download the `.webm` file cleanly during batch runs.

If you swap the save node to something else:

- set the app's `Expected Output` to match it
- keep the workflow writing a real file into ComfyUI history

## Why this is slightly manual

The workflow still owns the real local video graph:

- model loading
- text encoder wiring
- VAE
- latent video size and frame count
- sampler
- save node

The app just handles:

- prompt batching
- prompt replacement
- model override
- output naming
- manifest/log writing
- retry support

## Sources

- Wan 2.1 Diffusers docs: https://huggingface.co/docs/diffusers/v0.34.0/api/pipelines/wan
- Wan 2.1 official model page: https://huggingface.co/Wan-AI/Wan2.1-T2V-1.3B-Diffusers
- ComfyUI Wan examples: https://comfyanonymous.github.io/ComfyUI_examples/wan/
- Official native workflow JSON: https://comfyanonymous.github.io/ComfyUI_examples/wan/text_to_video_wan.json
- ComfyUI Wan tutorial: https://docs.comfy.org/tutorials/video/wan/wan-video
