{
  "id": "hcZRb9eLdoCozXcS",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Extend and Merge UGC Viral Videos Using Kling 2.1",
  "tags": [],
  "nodes": [
    {
      "id": "85057e26-b59b-4319-b173-fa2cac3e7732",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        64,
        496
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c496ec89-5771-47f8-a3a6-e2489a507ea0",
      "name": "Completed?1",
      "type": "n8n-nodes-base.if",
      "position": [
        1504,
        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": "4849480f-f3da-43bb-a8fd-67a3522e68da",
      "name": "Get Last frame",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1776,
        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": "bcaec2e1-ab42-4e97-a5c8-8e9a1c4090c8",
      "name": "Update video url",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1776,
        1024
      ],
      "parameters": {
        "columns": {
          "value": {
            "VIDEO URL": "={{ $json.output.result }}",
            "row_number": "={{ $('Get prompts').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,
              "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/14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow/edit?usp=drivesdk",
          "cachedResultName": "Extend and merge video"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "3a578528-f974-4499-8a07-a38038b3a75a",
      "name": "Extract last frame",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        896,
        496
      ],
      "parameters": {
        "url": "https://queue.fal.run/fal-ai/ffmpeg-api/extract-frame",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n     \"video_url\": \"{{ $json.video }}\",\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": "32e1ef51-0cac-47b7-b8a8-80049190cf2f",
      "name": "Wait 10 sec.",
      "type": "n8n-nodes-base.wait",
      "position": [
        1120,
        496
      ],
      "parameters": {
        "amount": 10
      },
      "typeVersion": 1.1
    },
    {
      "id": "7c36d533-d710-4fd2-a37c-782e6ada4cae",
      "name": "Get status Extract Frame",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1312,
        496
      ],
      "parameters": {
        "url": "=https://queue.fal.run/fal-ai/ffmpeg-api/requests/{{ $('Extract last frame').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": "5607b995-f5f2-452d-af91-e21b1aaa25b7",
      "name": "Set params",
      "type": "n8n-nodes-base.set",
      "position": [
        544,
        496
      ],
      "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": "video",
              "type": "string",
              "value": "={{ $json.START}}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "df74f2a2-f598-489f-b43b-53782e44c432",
      "name": "Completed?5",
      "type": "n8n-nodes-base.if",
      "position": [
        1552,
        1584
      ],
      "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": "04530e5e-6fa0-4cb8-86b7-1bf39b6197d1",
      "name": "Upload Video2",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        2592,
        1008
      ],
      "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": "93fc3621-b08e-426c-b765-f0ee7baad60d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        1264
      ],
      "parameters": {
        "color": 7,
        "width": 468,
        "height": 216,
        "content": "Create a FREE account on [Upload-Post](https://www.upload-post.com/?linkId=lp_144414&sourceId=n3witalia&tenantId=upload-post-app) and Set YOUR_USERNAME and TITLE for Upload-Post"
      },
      "typeVersion": 1
    },
    {
      "id": "843ef8f5-6ab2-45ea-b55a-13c61b44be5e",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        1600
      ],
      "parameters": {
        "color": 7,
        "width": 484,
        "height": 200,
        "content": "Create a FREE account on [Postiz](https://postiz.com/?ref=n3witalia) and Set Channel_ID and TITLE for Postiz (TikTok, Instagram, Facebook, X, Youtube)"
      },
      "typeVersion": 1
    },
    {
      "id": "559f2cd0-5233-4fa4-b96b-bb0040a9fc98",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2560,
        960
      ],
      "parameters": {
        "color": 7,
        "width": 468,
        "height": 200,
        "content": "Upload final video to Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "897dd9a9-8adf-40f1-8145-a5c4375027b5",
      "name": "Generate clip",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        880,
        1040
      ],
      "parameters": {
        "url": "https://api.runpod.ai/v2/kling-v2-1-i2v-pro/run",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n    \"input\": {\n        \"prompt\": \"{{ $('Get prompts').item.json.PROMPT }}\",\n        \"image\": \"{{ $json.images[0].url }}\",\n        \"negative_prompt\": \"\",\n        \"guidance_scale\": 0.5,\n        \"duration\": {{ $('Get prompts').item.json.DURATION }},\n        \"enable_safety_checker\": true\n    }\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "f3a2de88-886d-4a4e-9f7e-e09967958a3e",
      "name": "Get status clip",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1328,
        1040
      ],
      "parameters": {
        "url": "=https://api.runpod.ai/v2/kling-v2-1-i2v-pro/status/{{ $json.id }}",
        "options": {},
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth"
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        },
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "e8df586a-7470-48d2-b4a7-16bc715ad4b5",
      "name": "Wait 60 sec.",
      "type": "n8n-nodes-base.wait",
      "position": [
        1136,
        1040
      ],
      "parameters": {
        "amount": 60
      },
      "typeVersion": 1.1
    },
    {
      "id": "a8b2c3c5-cbe3-4b48-a58f-eec2e3b168ed",
      "name": "Completed?",
      "type": "n8n-nodes-base.if",
      "position": [
        1520,
        1040
      ],
      "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": "15a2a446-e193-40e2-90b2-86d7bdd5384e",
      "name": "Set VideoUrls Json",
      "type": "n8n-nodes-base.code",
      "position": [
        2256,
        1024
      ],
      "parameters": {
        "jsCode": "const item = items[0].json;\n\nreturn [\n  {\n    json: {\n      urls: [\n        item.START,\n        item[\"VIDEO URL\"],\n      ]\n    }\n  }\n];\n"
      },
      "typeVersion": 2
    },
    {
      "id": "cbf2490c-8ea2-4af6-ad72-a27503bf3044",
      "name": "Get videos to merge",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2016,
        1024
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "MERGE"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow/edit?usp=drivesdk",
          "cachedResultName": "Extend and merge video"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "3ee5d942-7ad2-4478-959a-53690596f573",
      "name": "Get final video file",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2256,
        1568
      ],
      "parameters": {
        "url": "={{ $('Get final video url').item.json.video.url }}",
        "options": {}
      },
      "typeVersion": 4.3
    },
    {
      "id": "71ef8725-1bba-4568-859d-19025a88ccd8",
      "name": "Get status",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1376,
        1584
      ],
      "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": "d2f68b00-9dca-4a84-a34a-52338b9ab060",
      "name": "Get final video url",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1824,
        1568
      ],
      "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": "a99141d9-b745-4516-b448-7128825308c6",
      "name": "Update video url2",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2064,
        1568
      ],
      "parameters": {
        "columns": {
          "value": {
            "MERGE": "x",
            "VIDEO URL": "=",
            "row_number": "={{ $('Get prompts').item.json.row_number }}",
            "FINAL VIDEO": "={{ $json.video.url }}"
          },
          "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,
              "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": "FINAL VIDEO",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "FINAL VIDEO",
              "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/14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow/edit?usp=drivesdk",
          "cachedResultName": "Extend and merge video"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "239477c1-c0ac-43e5-a051-1d831b357da7",
      "name": "Wait 30 sec.",
      "type": "n8n-nodes-base.wait",
      "position": [
        1184,
        1584
      ],
      "parameters": {
        "amount": 30
      },
      "typeVersion": 1.1
    },
    {
      "id": "1ad2efa2-2a23-4ab7-8cf1-d7081d139d19",
      "name": "Merge Videos",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        864,
        1584
      ],
      "parameters": {
        "url": "https://queue.fal.run/fal-ai/ffmpeg-api/merge-videos",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"video_urls\": {{ JSON.stringify($json.urls) }},\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": "a9f82e50-f420-47f8-9c69-767ed2d203b3",
      "name": "Upload to Postiz",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2608,
        1664
      ],
      "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": "9fb2a1ee-8741-4aca-9e8d-b82f320539f3",
      "name": "Upload to Social",
      "type": "n8n-nodes-postiz.postiz",
      "position": [
        2896,
        1664
      ],
      "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": "fa657f93-b66a-447a-ae81-030ce7d03196",
      "name": "Upload to Youtube",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2592,
        1328
      ],
      "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": "620ee43e-7209-4fd4-8cc5-a099ebf70e7b",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        336
      ],
      "parameters": {
        "color": 7,
        "width": 1156,
        "height": 492,
        "content": "## STEP 2 - EXTRACT LAST FRAME FROM VIDEO\nCreate an account [here](https://fal.ai/) and obtain API KEY.\nIn the node \"Extract Last Frame\" set \"Header Auth\" and set:\n- Name: \"Authorization\"\n- Value: \"Key YOURAPIKEY\""
      },
      "typeVersion": 1
    },
    {
      "id": "04033b26-4c84-43f2-bdab-54627cde1065",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        864
      ],
      "parameters": {
        "color": 7,
        "width": 900,
        "height": 492,
        "content": "## STEP 3 - GENERATE EXTENDED VIDEO WITH KLING 2.1\nCreate an account on Runpod [here](https://runpod.io?ref=moqjqsgw) and obtain API KEY.\nIn the node \"Generate Clip\" set \"Header Auth\" and set:\n- Name: \"Authorization\"\n- Value: \"Bearer YOURAPIKEY\""
      },
      "typeVersion": 1
    },
    {
      "id": "3151a1b5-48d0-4de5-82e5-58ad3e8e8288",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        1392
      ],
      "parameters": {
        "color": 7,
        "width": 1604,
        "height": 492,
        "content": "## STEP 4 - MERGE VIDEOS\nCreate an account [here](https://fal.ai/) and obtain API KEY.\nIn the node \"Merge Videos\" set \"Header Auth\" and set:\n- Name: \"Authorization\"\n- Value: \"Key YOURAPIKEY\""
      },
      "typeVersion": 1
    },
    {
      "id": "ed077754-6c23-4185-88b4-3ab7b050f232",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        864
      ],
      "parameters": {
        "color": 7,
        "width": 676,
        "height": 492,
        "content": "## PREPARE VIDEOS TO MERGE\n"
      },
      "typeVersion": 1
    },
    {
      "id": "26d8c032-8d90-4591-b99d-8818c5e9b6ba",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2464,
        864
      ],
      "parameters": {
        "color": 7,
        "width": 708,
        "height": 1020,
        "content": "## STEP 5 - UPLOAD TO GOOGLE DRIVE AND SOCIAL MEDIA\n"
      },
      "typeVersion": 1
    },
    {
      "id": "16b1b296-b956-4c00-9455-bf641be349f3",
      "name": "Get video",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        304,
        496
      ],
      "parameters": {
        "options": {},
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "VIDEO URL"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow/edit#gid=0",
          "cachedResultName": "Foglio1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow/edit?usp=drivesdk",
          "cachedResultName": "Extend and merge video"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "ba797a59-c99d-4b27-9fef-7d135ab6e61a",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        336
      ],
      "parameters": {
        "color": 7,
        "width": 564,
        "height": 492,
        "content": "## STEP 1 - SET PARAMS\n[Clone this Sheet](https://docs.google.com/spreadsheets/d/14zlCDJFLrJIhcq7HwFGdKAHIwvjmkwP-FSTHmLTj0ow/edit?usp=sharing) and fill the columns START, PROMPT and DURATION (in seconds, 5 or 10 if you use Kling 2.1)"
      },
      "typeVersion": 1
    },
    {
      "id": "5f493393-29ac-40e6-9eea-83cc9fab5982",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -128
      ],
      "parameters": {
        "width": 1760,
        "height": 432,
        "content": "## Extend and Merge UGC Viral Videos Using Kling 2.1, Then Publish on Social Media\n\nThis workflow automates the full pipeline for **extending short Viral UGC-style videos** using AI, merging them, and finally publishing the output to cloud storage or **social media platforms** (*TikTok, Instagram, Facebook, Linkedin, X, and YouTube*). It integrates multiple external APIs (Fal AI, Runpod/Kling 2.1, Postiz, Upload-Post, Google Sheets, Google Drive) to create a smooth end-to-end video-generation system.\n\n### **How it works:**\n\nThis n8n workflow automates the full video-extension and publishing pipeline using AI. It begins by reading video URLs and prompts from a Google Sheet, extracting the final frame with **Fal AI\u2019s FFmpeg API**. That frame is sent to **RunPod\u2019s Kling 2.1 model** to generate new extended footage matching the style and prompt. The original and generated clips are then merged into a seamless video via **Fal AI\u2019s merge API**. Once complete, the merged output is uploaded to **Google Drive** and automatically distributed to social media through **Upload-Post** (YouTube) and **Postiz** (TikTok, Instagram, Facebook, X). All progress, URLs, and statuses are logged back into the Google Sheet for monitoring and automation tracking.\n\n\n### **Setup steps:**\n\nPrepare the Google Sheet with columns for `START`, `PROMPT`, and `DURATION`, then configure **Fal AI**, **RunPod**, **Upload-Post**, **Postiz**, and Google OAuth2 credentials in their respective nodes. Add your API keys using HTTP or Bearer authentication as required for each service. For social publishing, define your account credentials and post titles in the appropriate nodes. After setup, execute the workflow manually\u2014n8n will automatically handle AI video generation, merging, uploading, and multi-platform posting while updating the sheet with live results.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "dea6f93c-b7df-4366-9a84-b0181a8f34b6",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2048,
        -128
      ],
      "parameters": {
        "width": 832,
        "height": 912,
        "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": "21567981-3a34-4436-a48b-adfcdd2cd274",
  "connections": {
    "Get video": {
      "main": [
        [
          {
            "node": "Set params",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?": {
      "main": [
        [
          {
            "node": "Update video url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 60 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status": {
      "main": [
        [
          {
            "node": "Completed?5",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set params": {
      "main": [
        [
          {
            "node": "Extract last frame",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?1": {
      "main": [
        [
          {
            "node": "Get Last frame",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 10 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Completed?5": {
      "main": [
        [
          {
            "node": "Get final video url",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait 30 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Videos": {
      "main": [
        [
          {
            "node": "Wait 30 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 10 sec.": {
      "main": [
        [
          {
            "node": "Get status Extract Frame",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 30 sec.": {
      "main": [
        [
          {
            "node": "Get status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait 60 sec.": {
      "main": [
        [
          {
            "node": "Get status clip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate clip": {
      "main": [
        [
          {
            "node": "Wait 60 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Last frame": {
      "main": [
        [
          {
            "node": "Generate clip",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status clip": {
      "main": [
        [
          {
            "node": "Completed?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update video url": {
      "main": [
        [
          {
            "node": "Get videos to merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload to Postiz": {
      "main": [
        [
          {
            "node": "Upload to Social",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update video url2": {
      "main": [
        [
          {
            "node": "Get final video file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract last frame": {
      "main": [
        [
          {
            "node": "Wait 10 sec.",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set VideoUrls Json": {
      "main": [
        [
          {
            "node": "Merge Videos",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get final video url": {
      "main": [
        [
          {
            "node": "Update video url2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get videos to merge": {
      "main": [
        [
          {
            "node": "Set VideoUrls Json",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get final video file": {
      "main": [
        [
          {
            "node": "Upload Video2",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload to Youtube",
            "type": "main",
            "index": 0
          },
          {
            "node": "Upload to Postiz",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get status Extract Frame": {
      "main": [
        [
          {
            "node": "Completed?1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Get video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}