{
  "id": "oRrY1WmePyiBPUuF",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Automated Long Video Creator",
  "tags": [],
  "nodes": [
    {
      "id": "6d2df4c5-1d2f-4096-8bc3-16751ae9bcd3",
      "name": "Upload Video",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        3168,
        -128
      ],
      "parameters": {
        "name": "={{ $now.format('yyyyLLddHHmmss') }}-{{ $('Get Clip Url').item.json.video.file_name }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1aHRwLWyrqfzoVC8HoB-YMrBvQ4tLC-NZ",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1aHRwLWyrqfzoVC8HoB-YMrBvQ4tLC-NZ",
          "cachedResultName": "Fal.run"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "16fb398a-43f4-4dc2-b6cd-d4221523356a",
      "name": "Upload to Youtube",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3168,
        176
      ],
      "parameters": {
        "url": "https://api.upload-post.com/api/upload",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "title",
              "value": "=XXX"
            },
            {
              "name": "user",
              "value": "YOUR_USERNAME"
            },
            {
              "name": "platform[]",
              "value": "youtube"
            },
            {
              "name": "video",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "d3046263-7a41-46e1-8ef3-97c3d4cb5253",
      "name": "Upload to Postiz",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        3168,
        496
      ],
      "parameters": {
        "url": "https://api.postiz.com/public/v1/upload",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "61cffd44-5f94-4eee-b08f-6199dd51d76a",
      "name": "Upload to Social",
      "type": "n8n-nodes-postiz.postiz",
      "position": [
        3440,
        496
      ],
      "parameters": {
        "date": "={{ $now.format('yyyy-LL-dd') }}T{{ $now.format('HH:ii:ss') }}",
        "posts": {
          "post": [
            {
              "value": {
                "contentItem": [
                  {
                    "image": {
                      "imageItem": [
                        {
                          "id": "={{ $json.id }}",
                          "path": "={{ $json.path }}"
                        }
                      ]
                    },
                    "content": "=XXX"
                  }
                ]
              },
              "integrationId": "XXX"
            }
          ]
        },
        "shortLink": true
      },
      "credentials": {
        "postizApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "376c15bc-7406-4c28-9c3b-00d13c7f5101",
      "name": "Set data",
      "type": "n8n-nodes-base.set",
      "position": [
        1248,
        128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "c713d31f-9abd-496a-ac79-e8e2efe60aa0",
              "name": "prompt",
              "type": "string",
              "value": "={{ $json.PROMPT }}"
            },
            {
              "id": "e8592b0f-4e8a-4922-a02a-d8d3cfb77ac8",
              "name": "duration",
              "type": "string",
              "value": "={{ $json.DURATION }}"
            },
            {
              "id": "f44b3427-aaf1-405c-b79c-ba3e0f60955f",
              "name": "image",
              "type": "string",
              "value": "={{ $json.START}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9ea28672-ac00-4876-9da3-6ac4179faed0",
      "name": "Get new video",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        304,
        112
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "VIDEO URL"
            },
            {
              "lookupColumn": "MERGE"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit?usp=drivesdk",
          "cachedResultName": "Long video"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "95e86784-d7d8-48dc-b5a1-039b574f15a4",
      "name": "Get Url Video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1168,
        496
      ],
      "parameters": {
        "url": "={{ $json.output.result }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        },
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "cef8aa0e-e66d-4f77-bb7c-54965f1ce4bd",
      "name": "Wait 60 sec.2",
      "type": "n8n-nodes-base.wait",
      "position": [
        1840,
        -256
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "a7fac3b8-3c8b-4d3d-bd65-6d70ec17eeee",
      "name": "Wait 60 sec.3",
      "type": "n8n-nodes-base.wait",
      "position": [
        1856,
        128
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "b2e7439c-fae2-44d9-9821-c7953dcd4433",
      "name": "Completed?3",
      "type": "n8n-nodes-base.if",
      "position": [
        2224,
        128
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "383d112e-2cc6-4dd4-8985-f09ce0bd1781",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "37400c9a-0719-41c3-85ad-28c61568d7c8",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        560,
        112
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "80ca8016-bd55-46c3-aabe-cdce0734cb43",
      "name": "Wait 60 sec.4",
      "type": "n8n-nodes-base.wait",
      "position": [
        1888,
        496
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "6babae9e-81d8-492f-a105-3d39a987fe3b",
      "name": "Completed?4",
      "type": "n8n-nodes-base.if",
      "position": [
        2256,
        496
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "383d112e-2cc6-4dd4-8985-f09ce0bd1781",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "22de257d-9394-4cd2-9262-72c238bb3b89",
      "name": "Completed?5",
      "type": "n8n-nodes-base.if",
      "position": [
        2208,
        -256
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "383d112e-2cc6-4dd4-8985-f09ce0bd1781",
              "operator": {
                "name": "filter.operator.equals",
                "type": "string",
                "operation": "equals"
              },
              "leftValue": "={{ $json.status }}",
              "rightValue": "COMPLETED"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "0ac35934-bd1f-47c6-843d-72c190dbc518",
      "name": "videoUrls",
      "type": "n8n-nodes-base.code",
      "position": [
        1184,
        -256
      ],
      "parameters": {
        "jsCode": "// Estrai tutti i VIDEO URL dall'input\nconst videoUrls = $input.all().map(item => item.json[\"VIDEO URL\"]);\n\n// Restituisci l'array correttamente incapsulato\nreturn [{ \n  json: { \n    videos: videoUrls \n  } \n}];"
      },
      "typeVersion": 2
    },
    {
      "id": "469e5aba-ea5a-4fc6-976b-ea9d270165ed",
      "name": "Merge videos",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1536,
        -256
      ],
      "parameters": {
        "url": "https://queue.fal.run/fal-ai/ffmpeg-api/merge-videos",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"video_urls\": {{ JSON.stringify($json.videos) }},\n  \"target_fps\": 24\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "43c3f7c5-9f1f-46a8-ab0f-11d0ed5e75d8",
      "name": "Get videos",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        880,
        -256
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupValue": "x",
              "lookupColumn": "MERGE"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit?usp=drivesdk",
          "cachedResultName": "Long video"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "727c5673-af3f-440d-b405-40834cc5f16d",
      "name": "Merge videos status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2032,
        -256
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/ffmpeg-api/requests/{{ $('Merge videos').item.json.request_id }}/status ",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4f9a0b2f-178d-4cec-bd85-6f44c5f35c82",
      "name": "Get final video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2560,
        -272
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/ffmpeg-api/requests/{{ $json.request_id }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "66de0708-5e3c-4a2b-8b94-626ad79fc99d",
      "name": "Get frame",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        912,
        128
      ],
      "parameters": {
        "options": {
          "returnFirstMatch": true
        },
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "VIDEO URL"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit?usp=drivesdk",
          "cachedResultName": "Long video"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "ba3da761-c1fa-48b3-aeb4-730f268c562a",
      "name": "Generate video",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1568,
        128
      ],
      "parameters": {
        "url": "https://api.runpod.ai/v2/wan-2-5/run",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"input\": {\n    \"prompt\": \"{{ $json.prompt }}\",\n    \"image\": \"{{ $json.image }}\",\n    \"negative_prompt\": \"\",\n    \"size\": \"1280*720\",\n    \"duration\": {{ $json.duration }},\n    \"seed\": -1,\n    \"enable_prompt_expansion\": false,\n    \"enable_safety_checker\": true\n  }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {}
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "d69b2c91-252f-4ba3-bf8e-c764bbb7a376",
      "name": "Generate video status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2048,
        128
      ],
      "parameters": {
        "url": "=https://api.runpod.ai/v2/wan-2-5/status/{{ $json.id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        },
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "a80475bf-2a68-46be-aee3-eee4d24bbc00",
      "name": "Update video",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1376,
        496
      ],
      "parameters": {
        "columns": {
          "value": {
            "MERGE": "x",
            "VIDEO URL": "={{ $('Completed?3').item.json.output.result }}",
            "row_number": "={{ $('Loop Over Items1').item.json.row_number }}"
          },
          "schema": [
            {
              "id": "START",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "START",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "PROMPT",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "PROMPT",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "DURATION",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "DURATION",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "VIDEO URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "VIDEO URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MERGE",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "MERGE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit?usp=drivesdk",
          "cachedResultName": "Long video"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "f944d077-954e-4498-93f0-49235e3c75ec",
      "name": "Extract Frame Status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2080,
        496
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/ffmpeg-api/requests/{{ $('Extract last frame1').item.json.request_id }}/status ",
        "options": {},
        "sendQuery": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "queryParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "4e84228d-4462-48cb-8c5c-560f5bca7e36",
      "name": "Extract last frame1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1664,
        496
      ],
      "parameters": {
        "url": "https://queue.fal.run/fal-ai/ffmpeg-api/extract-frame",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n     \"video_url\": \"{{ $json[\"VIDEO URL\"] }}\",\n     \"frame_type\": \"last\"\n   } ",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "36c12a7d-8c65-436e-8f23-84bcfa3bfc15",
      "name": "Update last frame",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2752,
        480
      ],
      "parameters": {
        "columns": {
          "value": {
            "START": "={{ $json.images[0].url }}",
            "VIDEO URL": "=",
            "row_number": "={{ $('Loop Over Items1').item.json.row_number  + 1}}"
          },
          "schema": [
            {
              "id": "START",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "START",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "PROMPT",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "PROMPT",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "DURATION (4, 6 or 8seconds)",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "DURATION (4, 6 or 8seconds)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "VIDEO URL",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "VIDEO URL",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "MERGE",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "MERGE",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "row_number",
              "type": "number",
              "display": true,
              "removed": false,
              "readOnly": true,
              "required": false,
              "displayName": "row_number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "row_number"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "update",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit?usp=drivesdk",
          "cachedResultName": "Long video"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "af0ff761-3648-47be-b82e-73b9167207df",
      "name": "Get Last frame",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2528,
        480
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/ffmpeg-api/requests/{{ $json.request_id }}",
        "options": {},
        "sendHeaders": true,
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6d3f1a77-b17f-4847-9309-e6766db31afa",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        16,
        112
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "1b3ad001-b1c5-445d-9e6f-a11f8a62dfec",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        224,
        0
      ],
      "parameters": {
        "color": 7,
        "width": 272,
        "height": 320,
        "content": "## STEP 1 - Set Sheet\nClone [this sheet](https://docs.google.com/spreadsheets/d/1MisBkHc1RmsYit1ndaPS7oOvSQV1VBMW7nyehTuiRQs/edit?usp=sharing) and fill basic info"
      },
      "typeVersion": 1
    },
    {
      "id": "fa9ad042-5805-4de9-b1b2-9fb34a330b52",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -256,
        -752
      ],
      "parameters": {
        "width": 752,
        "height": 720,
        "content": "## Automated Long Video Creator & Multi-Platform Upload\n\nThis workflow automates the **creation of long AI-generated videos from prompts**, merges the generated clips into a single video, and automatically distributes the final content across multiple platforms.\n\n### How it works\n\nThis workflow automates long-form AI video creation by generating multiple clips from prompts stored in a Google Sheet and assembling them into a single video. When triggered, it reads rows containing prompts, durations, and starting images, then sequentially sends these parameters to the RunPod WAN 2.5 video generation API. The workflow monitors job status with periodic polling until each clip is complete, retrieves the resulting video URL, and records it back in the sheet for tracking.\n\nAfter each clip is produced, the workflow extracts the final frame using the Fal AI FFmpeg API and assigns it as the starting image for the next scene, ensuring visual continuity. Once all clips marked for merging are ready, their URLs are collected and sent to the Fal AI FFmpeg merge API to produce a single long video. The merged file is then retrieved and automatically distributed by uploading it to Google Drive, publishing it to YouTube, and sending it to Postiz for cross-posting across social platforms such as TikTok, Instagram, Facebook, and X.\n\n### Setup steps\n\nBegin by cloning the provided Google Sheet template and updating the Sheet ID in all Google Sheets nodes within the workflow. Populate the sheet with scene data including the initial image URL (START), the generation prompt (PROMPT), and clip duration (DURATION). Mark any rows that should be included in the final merged video with an \u201cx\u201d in the MERGE column so the workflow knows which clips to assemble.\n\nNext, configure the required API credentials in n8n: Google Sheets OAuth2 for spreadsheet access, Google Drive OAuth2 for storing the final video, RunPod API for WAN 2.5 video generation, Fal AI API for frame extraction and merging, Upload-Post API for YouTube publishing, and Postiz API for distributing the video to social media platforms. Update workflow nodes with your specific details, including the YouTube username, social integration IDs, titles, and the correct Google Drive folder IDs. Finally, run the workflow manually to test the full pipeline and confirm that clips generate, merge correctly, and publish successfully. "
      },
      "typeVersion": 1
    },
    {
      "id": "e1ca6727-35ea-48c8-89e1-c3506c395d5a",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 1664,
        "height": 336,
        "content": "## STEP 2  - Generate short video\nSign up to [Runpod](https://get.runpod.io/n3witalia)\nSends the prompt and parameters to RunPod's WAN 2.5 video generation API"
      },
      "typeVersion": 1
    },
    {
      "id": "4695b69b-584f-452e-9bb8-0b9bf68f21f4",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1584,
        400
      ],
      "parameters": {
        "color": 7,
        "width": 1376,
        "height": 336,
        "content": "## STEP 3 - Extract Last Frame\nAfter each video is generated, it extracts the last frame and save to Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "0d1a6c21-1289-40e9-9205-0af34d6d1bb1",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        -368
      ],
      "parameters": {
        "color": 7,
        "width": 1040,
        "height": 336,
        "content": "## STEP 4 - Merge videos\nAll individual clips are merged into long final video"
      },
      "typeVersion": 1
    },
    {
      "id": "0b74debf-bfd9-4c07-bdbd-d0a73779fdf4",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3024,
        -368
      ],
      "parameters": {
        "color": 7,
        "width": 656,
        "height": 1104,
        "content": "## STEP 5 - Upload to Social and Google Drive\nPosted to multiple social platforms and upload to Google Drive\n\n- Get [Upload-Post API Key](https://www.upload-post.com/?linkId=lp_144414&sourceId=n3witalia&tenantId=upload-post-app) \n- Get [Postiz API Key](https://affiliate.postiz.com/n3witalia)"
      },
      "typeVersion": 1
    },
    {
      "id": "4ab70724-deb1-48c5-9e6d-9a753f193ab2",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1040,
        -768
      ],
      "parameters": {
        "color": 7,
        "width": 736,
        "height": 736,
        "content": "## MY NEW YOUTUBE CHANNEL\n\ud83d\udc49 [Subscribe to my new **YouTube channel**](https://youtube.com/@n3witalia). Here I\u2019ll share videos and Shorts with practical tutorials and **FREE templates for n8n**.\n\n[![image](https://n3wstorage.b-cdn.net/n3witalia/youtube-n8n-cover.jpg)](https://youtube.com/@n3witalia)"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "0c6cba15-f385-46c4-aebc-205113c1a0d3",
  "connections": {
    "Set data": {
      "main": [
        [
          {
            "node": "Generate video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get frame": {
      "main": [
        [
          {
            "node": "Set data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "videoUrls": {
      "main": [
        [
          {
            "node": "Merge videos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get videos": {
      "main": [
        [
          {
            "node": "videoUrls",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?3": {
      "main": [
        [
          {
            "node": "Get Url Video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 60 sec.3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?4": {
      "main": [
        [
          {
            "node": "Get Last frame",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 60 sec.4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?5": {
      "main": [
        [
          {
            "node": "Get final video",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 60 sec.2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge videos": {
      "main": [
        [
          {
            "node": "Wait 60 sec.2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update video": {
      "main": [
        [
          {
            "node": "Extract last frame1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Video": {
      "main": [
        []
      ]
    },
    "Get Url Video": {
      "main": [
        [
          {
            "node": "Update video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get new video": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 60 sec.2": {
      "main": [
        [
          {
            "node": "Merge videos status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 60 sec.3": {
      "main": [
        [
          {
            "node": "Generate video status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 60 sec.4": {
      "main": [
        [
          {
            "node": "Extract Frame Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate video": {
      "main": [
        [
          {
            "node": "Wait 60 sec.3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Last frame": {
      "main": [
        [
          {
            "node": "Update last frame",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get final video": {
      "main": [
        [
          {
            "node": "Upload Video",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload to Youtube",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload to Postiz",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [
          {
            "node": "Get videos",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Get frame",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Postiz": {
      "main": [
        [
          {
            "node": "Upload to Social",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update last frame": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Youtube": {
      "main": [
        []
      ]
    },
    "Extract last frame1": {
      "main": [
        [
          {
            "node": "Wait 60 sec.4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge videos status": {
      "main": [
        [
          {
            "node": "Completed?5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Frame Status": {
      "main": [
        [
          {
            "node": "Completed?4",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate video status": {
      "main": [
        [
          {
            "node": "Completed?3",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Get new video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}