{
  "name": "ComfyUI: wan 2.2 5b - image 2 video",
  "nodes": [
    {
      "parameters": {
        "formTitle": "Upload reference images",
        "formFields": {
          "values": [
            {
              "fieldLabel": "Image",
              "fieldType": "file",
              "multipleFiles": false,
              "acceptFileTypes": ".jpg, .png, .jpeg",
              "requiredField": true
            },
            {
              "fieldLabel": "prompt",
              "fieldType": "textarea",
              "placeholder": "what should happen on the video",
              "requiredField": true
            },
            {
              "fieldLabel": "Negative prompt",
              "placeholder": "optional"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.formTrigger",
      "typeVersion": 2.2,
      "position": [
        -1200,
        -60
      ],
      "id": "17826ac5-175e-4358-b686-3feb7feda0f8",
      "name": "On form submission"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "7d55d6da-a78c-4a28-9343-0ea9035a0aa3",
              "name": "COMFY_URL",
              "value": "={{   ((u) => {   let s = u.trim();   if (!/^https?:\\/\\//i.test(s)) s = 'https://' + s;   const parts = s.split('/');   return parts[0] + '//' + parts[2]; })($json.comfyui_url)  }}",
              "type": "string"
            },
            {
              "id": "c491a696-6081-4e42-98f5-0c3b75c16edc",
              "name": "NEGATIVE_PROMPT",
              "value": "={{ $('On form submission').item.json['Negative prompt'] || $json.negative_prompt }}",
              "type": "string"
            },
            {
              "id": "e179a11b-ab0b-4772-b151-10b0b7d49a8c",
              "name": "PROMPT",
              "value": "={{ $('On form submission').item.json.prompt }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -640,
        -60
      ],
      "id": "e93451b4-9100-4bbd-b67c-bcc28fd23344",
      "name": "Setup defaults"
    },
    {
      "parameters": {
        "url": "={{ $('Setup defaults').first().json.COMFY_URL }}/history/{{ $('Start the workflow with ComfyUI').first().json.prompt_id }}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        360,
        -60
      ],
      "id": "0211ed19-3112-4182-a384-c49ceaa52a31",
      "name": "Get video generation status",
      "retryOnFail": true
    },
    {
      "parameters": {
        "amount": 10
      },
      "type": "n8n-nodes-base.wait",
      "typeVersion": 1.1,
      "position": [
        160,
        -60
      ],
      "id": "dadbc73d-4d95-4d84-adb2-96348c66fa37",
      "name": "Wait until the video gets generated"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "5e89df7d-4c0e-4bd4-8a84-b1e28bdb1f7e",
              "leftValue": "={{ $json.keys().length > 0 && $json[$('Start the workflow with ComfyUI').item.json.prompt_id] && $json[$('Start the workflow with ComfyUI').item.json.prompt_id].status.completed }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            },
            {
              "id": "354e3206-bbe3-481d-876b-255eed39f7cf",
              "leftValue": "",
              "rightValue": "",
              "operator": {
                "type": "string",
                "operation": "equals",
                "name": "filter.operator.equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        580,
        -60
      ],
      "id": "4f467ba5-292f-425f-894d-6bedfa8e3f84",
      "name": "Completed?"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "9bfcdffd-8c7c-407d-b95c-83f8aa104845",
              "leftValue": "={{ $json[$('Start the workflow with ComfyUI').item.json.prompt_id].status.status_str === 'success' }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        860,
        -80
      ],
      "id": "bdd2f36a-6eee-4131-917a-504ef25f1e70",
      "name": "Success?"
    },
    {
      "parameters": {
        "url": "={{ $('Setup defaults').first().json.COMFY_URL }}/view",
        "sendQuery": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "type",
              "value": "output"
            },
            {
              "name": "filename",
              "value": "={{ $('Get video generation status').last().json[$('Start the workflow with ComfyUI').item.json.prompt_id].outputs.values().map(item => item.images).flat(Infinity).find(item => item.type === 'output').filename }}"
            },
            {
              "name": "subfolder",
              "value": "={{ $('Get video generation status').last().json[$('Start the workflow with ComfyUI').item.json.prompt_id].outputs['58'].images[0].subfolder }}"
            }
          ]
        },
        "sendBody": true,
        "contentType": "form-urlencoded",
        "bodyParameters": {
          "parameters": [
            {}
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        1100,
        -220
      ],
      "id": "d15a677b-531d-47b5-904c-15112134365b",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "errorMessage": "An error occoured while generating the image"
      },
      "type": "n8n-nodes-base.stopAndError",
      "typeVersion": 1,
      "position": [
        1100,
        0
      ],
      "id": "5a79f39c-006b-4e9f-ab9d-0db64d680fdc",
      "name": "Stop and Error"
    },
    {
      "parameters": {
        "content": "# Configure me",
        "height": 420,
        "width": 260,
        "color": 3
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -960,
        -240
      ],
      "id": "cacd5767-91ac-4ae0-8116-479a6c50590a",
      "name": "Sticky Note"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "1ece166a-0536-4c3e-bf1f-e0d4ff300169",
              "name": "workflow",
              "value": "={\n  \"3\": {\n    \"inputs\": {\n      \"seed\": {{ (() => {\n  const max = 0xFFFFFFFF - 1;\n  const seed = Math.floor(Math.random() * max) + 1;\n  return seed;\n})() }},\n      \"steps\": 20,\n      \"cfg\": 5,\n      \"sampler_name\": \"uni_pc\",\n      \"scheduler\": \"simple\",\n      \"denoise\": 1,\n      \"model\": [\n        \"48\",\n        0\n      ],\n      \"positive\": [\n        \"6\",\n        0\n      ],\n      \"negative\": [\n        \"7\",\n        0\n      ],\n      \"latent_image\": [\n        \"55\",\n        0\n      ]\n    },\n    \"class_type\": \"KSampler\",\n    \"_meta\": {\n      \"title\": \"KSampler\"\n    }\n  },\n  \"6\": {\n    \"inputs\": {\n      \"text\": \"${PROMPT}\",\n      \"clip\": [\n        \"38\",\n        0\n      ]\n    },\n    \"class_type\": \"CLIPTextEncode\",\n    \"_meta\": {\n      \"title\": \"CLIP Text Encode (Positive Prompt)\"\n    }\n  },\n  \"7\": {\n    \"inputs\": {\n      \"text\": \"${NEGATIVE_PROMPT}\",\n      \"clip\": [\n        \"38\",\n        0\n      ]\n    },\n    \"class_type\": \"CLIPTextEncode\",\n    \"_meta\": {\n      \"title\": \"CLIP Text Encode (Negative Prompt)\"\n    }\n  },\n  \"8\": {\n    \"inputs\": {\n      \"samples\": [\n        \"3\",\n        0\n      ],\n      \"vae\": [\n        \"39\",\n        0\n      ]\n    },\n    \"class_type\": \"VAEDecode\",\n    \"_meta\": {\n      \"title\": \"VAE Decode\"\n    }\n  },\n  \"37\": {\n    \"inputs\": {\n      \"unet_name\": \"wan2.2_ti2v_5B_fp16.safetensors\",\n      \"weight_dtype\": \"default\"\n    },\n    \"class_type\": \"UNETLoader\",\n    \"_meta\": {\n      \"title\": \"Load Diffusion Model\"\n    }\n  },\n  \"38\": {\n    \"inputs\": {\n      \"clip_name\": \"umt5_xxl_fp8_e4m3fn_scaled.safetensors\",\n      \"type\": \"wan\",\n      \"device\": \"default\"\n    },\n    \"class_type\": \"CLIPLoader\",\n    \"_meta\": {\n      \"title\": \"Load CLIP\"\n    }\n  },\n  \"39\": {\n    \"inputs\": {\n      \"vae_name\": \"wan2.2_vae.safetensors\"\n    },\n    \"class_type\": \"VAELoader\",\n    \"_meta\": {\n      \"title\": \"Load VAE\"\n    }\n  },\n  \"48\": {\n    \"inputs\": {\n      \"shift\": 8,\n      \"model\": [\n        \"37\",\n        0\n      ]\n    },\n    \"class_type\": \"ModelSamplingSD3\",\n    \"_meta\": {\n      \"title\": \"ModelSamplingSD3\"\n    }\n  },\n  \"55\": {\n    \"inputs\": {\n      \"width\": 1280,\n      \"height\": 704,\n      \"length\": 121,\n      \"batch_size\": 1,\n      \"vae\": [\n        \"39\",\n        0\n      ],\n      \"start_image\": [\n        \"56\",\n        0\n      ]\n    },\n    \"class_type\": \"Wan22ImageToVideoLatent\",\n    \"_meta\": {\n      \"title\": \"Wan22ImageToVideoLatent\"\n    }\n  },\n  \"56\": {\n    \"inputs\": {\n      \"image\": \"${IMAGE}\"\n    },\n    \"class_type\": \"LoadImage\",\n    \"_meta\": {\n      \"title\": \"Load Image\"\n    }\n  },\n  \"57\": {\n    \"inputs\": {\n      \"fps\": 24,\n      \"images\": [\n        \"8\",\n        0\n      ]\n    },\n    \"class_type\": \"CreateVideo\",\n    \"_meta\": {\n      \"title\": \"Create Video\"\n    }\n  },\n  \"58\": {\n    \"inputs\": {\n      \"filename_prefix\": \"video/ComfyUI\",\n      \"format\": \"auto\",\n      \"codec\": \"auto\",\n      \"video-preview\": \"\",\n      \"video\": [\n        \"57\",\n        0\n      ]\n    },\n    \"class_type\": \"SaveVideo\",\n    \"_meta\": {\n      \"title\": \"Save Video\"\n    }\n  }\n}",
              "type": "string"
            },
            {
              "id": "92df0709-c03c-400e-b2ac-1a8e3aff7416",
              "name": "comfyui_url",
              "value": "YOUR_COMFYUI_URL",
              "type": "string"
            },
            {
              "id": "fb621130-6eac-41ab-b514-576a0275f6b1",
              "name": "negative_prompt",
              "value": "\u8272\u8c03\u8273\u4e3d\uff0c\u8fc7\u66dd\uff0c\u9759\u6001\uff0c\u7ec6\u8282\u6a21\u7cca\u4e0d\u6e05\uff0c\u5b57\u5e55\uff0c\u98ce\u683c\uff0c\u4f5c\u54c1\uff0c\u753b\u4f5c\uff0c\u753b\u9762\uff0c\u9759\u6b62\uff0c\u6574\u4f53\u53d1\u7070\uff0c\u6700\u5dee\u8d28\u91cf\uff0c\u4f4e\u8d28\u91cf\uff0cJPEG\u538b\u7f29\u6b8b\u7559\uff0c\u4e11\u964b\u7684\uff0c\u6b8b\u7f3a\u7684\uff0c\u591a\u4f59\u7684\u624b\u6307\uff0c\u753b\u5f97\u4e0d\u597d\u7684\u624b\u90e8\uff0c\u753b\u5f97\u4e0d\u597d\u7684\u8138\u90e8\uff0c\u7578\u5f62\u7684\uff0c\u6bc1\u5bb9\u7684\uff0c\u5f62\u6001\u7578\u5f62\u7684\u80a2\u4f53\uff0c\u624b\u6307\u878d\u5408\uff0c\u9759\u6b62\u4e0d\u52a8\u7684\u753b\u9762\uff0c\u6742\u4e71\u7684\u80cc\u666f\uff0c\u4e09\u6761\u817f\uff0c\u80cc\u666f\u4eba\u5f88\u591a\uff0c\u5012\u7740\u8d70",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -880,
        -60
      ],
      "id": "dbae31f4-adbe-4295-b8aa-f5f1b228cb84",
      "name": "Configure me"
    },
    {
      "parameters": {
        "jsCode": "return $('On form submission').first()"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        -500,
        -60
      ],
      "id": "b3a85695-fa30-4c83-a30c-6de8795017f8",
      "name": "Relay image"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Setup defaults').first().json.COMFY_URL }}/upload/image",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "image",
              "inputDataFieldName": "Image"
            }
          ]
        },
        "options": {
          "redirect": {
            "redirect": {}
          }
        }
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -340,
        -60
      ],
      "id": "ad3ec3d9-22a3-400e-b4ad-73aa6c3f18e4",
      "name": "Upload the image to ComfyUI"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $('Setup defaults').first().json.COMFY_URL }}/prompt",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"client_id\": \"n8n\",\n  \"prompt\": {{ \n\n    $('Configure me').item.json.workflow\n      .replace('${IMAGE}', $json.name)\n      .replace('${PROMPT}', $('Setup defaults').first().json.PROMPT)\n      .replace('${NEGATIVE_PROMPT}', $('Setup defaults').first().json.NEGATIVE_PROMPT) \n\n}}\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -140,
        -60
      ],
      "id": "07a2c24e-bfb2-4e74-a726-468dd23c7364",
      "name": "Start the workflow with ComfyUI"
    },
    {
      "parameters": {
        "content": "# \ud83d\udcda [Join our Skool community for support, premium content and more!](https://www.skool.com/ai-agents-az/about?w9)\n\n## Get premium variations of this workflow!\n\n## Be part of a growing community and help us create more content like this",
        "height": 300,
        "width": 700,
        "color": 6
      },
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -960,
        -580
      ],
      "id": "055d892d-2aad-4a0d-b04b-83624b7e3fa3",
      "name": "Sticky Note16"
    }
  ],
  "connections": {
    "On form submission": {
      "main": [
        [
          {
            "node": "Configure me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Setup defaults": {
      "main": [
        [
          {
            "node": "Relay image",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get video generation status": {
      "main": [
        [
          {
            "node": "Completed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait until the video gets generated": {
      "main": [
        [
          {
            "node": "Get video generation status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?": {
      "main": [
        [
          {
            "node": "Success?",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait until the video gets generated",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Success?": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Stop and Error",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Configure me": {
      "main": [
        [
          {
            "node": "Setup defaults",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Relay image": {
      "main": [
        [
          {
            "node": "Upload the image to ComfyUI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload the image to ComfyUI": {
      "main": [
        [
          {
            "node": "Start the workflow with ComfyUI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Start the workflow with ComfyUI": {
      "main": [
        [
          {
            "node": "Wait until the video gets generated",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "de151387-c4df-4e03-b397-01c956840681",
  "id": "AV7iCymx5DJbqx67",
  "tags": []
}