8
n8n 中文网amn8n.com

Sora 2

高级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 21 个节点。主要使用 Set, Form, Wait, Merge, Switch 等节点。 使用OpenAI Sora 2生成AI视频并上传到Google云端硬盘

前置要求
  • Google Drive API 凭证
  • 可能需要目标 API 的认证凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "fUtTSVUudypSMWPr",
  "meta": {
    "instanceId": "69cb24484ded4b91a528eddf1eab8f391c66f63b5d8162ce8f6f60ffd7b0e0d1",
    "templateCredsSetupCompleted": true
  },
  "name": "Sora 2",
  "tags": [],
  "nodes": [
    {
      "id": "6285ad92-d4fb-474d-a27f-4e53064db2ab",
      "name": "等待",
      "type": "n8n-nodes-base.wait",
      "notes": "30 seconds",
      "position": [
        944,
        176
      ],
      "webhookId": "d6b5d4ee-dce9-4053-97c0-75b49c1158a4",
      "parameters": {
        "amount": 30
      },
      "notesInFlow": true,
      "typeVersion": 1.1
    },
    {
      "id": "5a1ec7d2-bea1-49e7-8f72-645b00b909b2",
      "name": "状态",
      "type": "n8n-nodes-base.switch",
      "notes": "Decide next step",
      "position": [
        752,
        -32
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "Completed",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "debfc1f4-f7ee-48c3-aefb-929fc6a02c17",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "completed"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "In Progress",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3d03417e-a385-4bf2-992d-2b46a18cde03",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "in_progress"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "Queued",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "43850b6f-73fa-4914-af6a-d423c259d993",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "queued"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "cf5a311e-8604-493c-a9cf-05ca7c6aac8c",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $json.status }}",
                    "rightValue": "failed"
                  }
                ]
              }
            }
          ]
        },
        "options": {}
      },
      "notesInFlow": true,
      "typeVersion": 3.2
    },
    {
      "id": "6c4e7f40-d42d-4b43-899a-e04f53e00ea9",
      "name": "检查状态",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Check current status",
      "position": [
        560,
        0
      ],
      "parameters": {
        "url": "=https://api.openai.com/v1/videos/{{ $json.id }}",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('On form submission').item.json.YOUR_ACCESS_TOKEN }}"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "b122a24f-b1c1-4986-a2c3-457dc8af4a31",
      "name": "下载",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1184,
        -48
      ],
      "parameters": {
        "url": "=https://api.openai.com/v1/videos/{{ $json.id }}/content",
        "options": {},
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('On form submission').item.json.YOUR_ACCESS_TOKEN }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0fdf2bcf-7331-4edb-b0c2-20244a34a66c",
      "name": "便签3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1360,
        -144
      ],
      "parameters": {
        "color": 6,
        "width": 180,
        "height": 576,
        "content": "### 上传视频和缩略图到 Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "26688dc3-c615-49d0-8921-1dd5c6d7ce86",
      "name": "便签2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1136,
        -144
      ],
      "parameters": {
        "color": 5,
        "width": 200,
        "height": 576,
        "content": "### 获取生成的视频"
      },
      "typeVersion": 1
    },
    {
      "id": "c403a8db-5789-4d14-a9c4-42bb9f28338d",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        -144
      ],
      "parameters": {
        "color": 4,
        "width": 1140,
        "height": 576,
        "content": "## Sora"
      },
      "typeVersion": 1
    },
    {
      "id": "e850e99e-5239-4fdd-92f6-07c2dc430972",
      "name": "设置",
      "type": "n8n-nodes-base.set",
      "position": [
        -192,
        272
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "78950a7f-e225-430d-a262-e5d82962d231",
              "name": "prompt",
              "type": "string",
              "value": "={{ $json.Prompt }}"
            },
            {
              "id": "083ce6d6-8cd2-4f73-8edd-eecd98002b1c",
              "name": "model",
              "type": "string",
              "value": "={{ $json.Model }}"
            },
            {
              "id": "9d513c9a-a150-42d8-8243-0ba08c9d3093",
              "name": "size",
              "type": "string",
              "value": "={{ $json.Size }}"
            },
            {
              "id": "aa4fa43a-85f5-400b-9b2b-0d0de6590d39",
              "name": "seconds",
              "type": "string",
              "value": "={{ $json.Duration }}"
            }
          ]
        },
        "includeOtherFields": true
      },
      "typeVersion": 3.4
    },
    {
      "id": "8a86f10f-3c06-4d7f-8a22-1caea453e4f1",
      "name": "便签4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -304,
        -144
      ],
      "parameters": {
        "height": 576,
        "content": "### 设置"
      },
      "typeVersion": 1
    },
    {
      "id": "e01752f8-633f-4238-b568-d9f3cb7a1140",
      "name": "表单提交时",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -480,
        224
      ],
      "webhookId": "1c041721-9e17-4486-927e-d2de9a113977",
      "parameters": {
        "options": {},
        "formTitle": "OpenAI Sora",
        "formFields": {
          "values": [
            {
              "fieldLabel": "YOUR_ACCESS_TOKEN",
              "requiredField": true
            },
            {
              "fieldType": "textarea",
              "fieldLabel": "Prompt",
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Model",
              "fieldOptions": {
                "values": [
                  {
                    "option": "sora-2"
                  },
                  {
                    "option": "sora-2-pro"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Size",
              "fieldOptions": {
                "values": [
                  {
                    "option": "1280x720"
                  },
                  {
                    "option": "720x1280"
                  },
                  {
                    "option": "1024x1792"
                  },
                  {
                    "option": "1792x1024"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldType": "dropdown",
              "fieldLabel": "Duration",
              "fieldOptions": {
                "values": [
                  {
                    "option": "4"
                  },
                  {
                    "option": "8"
                  },
                  {
                    "option": "12"
                  }
                ]
              },
              "requiredField": true
            },
            {
              "fieldType": "file",
              "fieldLabel": "Image Reference",
              "multipleFiles": false,
              "acceptFileTypes": ".jpg, .png, .webp"
            }
          ]
        },
        "formDescription": "OpenAI Sora 2 Video Generator"
      },
      "typeVersion": 2.2
    },
    {
      "id": "6e3c9c65-091f-428e-afd0-916d73196fae",
      "name": "参考",
      "type": "n8n-nodes-base.switch",
      "notes": "Image Reference",
      "position": [
        16,
        112
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "False",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "debfc1f4-f7ee-48c3-aefb-929fc6a02c17",
                    "operator": {
                      "type": "number",
                      "operation": "notExists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('On form submission').item.json['Image Reference'].size }}",
                    "rightValue": "completed"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "True",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "3d03417e-a385-4bf2-992d-2b46a18cde03",
                    "operator": {
                      "type": "number",
                      "operation": "exists",
                      "singleValue": true
                    },
                    "leftValue": "={{ $('On form submission').item.json['Image Reference'].size }}",
                    "rightValue": "in_progress"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "notesInFlow": true,
      "typeVersion": 3.2
    },
    {
      "id": "9e10f930-6817-4123-85d5-532832ef28f0",
      "name": "创建视频 B",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "With image reference",
      "position": [
        336,
        224
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/videos",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.prompt }}"
            },
            {
              "name": "model",
              "value": "={{ $json.model }}"
            },
            {
              "name": "size",
              "value": "={{ $json.size }}"
            },
            {
              "name": "seconds",
              "value": "={{ $json.seconds }}"
            },
            {
              "name": "input_reference",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "=Image_Reference"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('On form submission').item.json.YOUR_ACCESS_TOKEN }}"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "74d10265-af5d-4a91-9082-f16627018373",
      "name": "创建视频 A",
      "type": "n8n-nodes-base.httpRequest",
      "notes": "Without image reference",
      "position": [
        336,
        0
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/videos",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "prompt",
              "value": "={{ $json.prompt }}"
            },
            {
              "name": "model",
              "value": "={{ $json.model }}"
            },
            {
              "name": "size",
              "value": "={{ $json.size }}"
            },
            {
              "name": "seconds",
              "value": "={{ $json.seconds }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('On form submission').item.json.YOUR_ACCESS_TOKEN }}"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 4.2
    },
    {
      "id": "f23a5c7c-db0c-45e2-9e3c-dc1db548efc3",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1568,
        -144
      ],
      "parameters": {
        "color": 3,
        "width": 580,
        "height": 576,
        "content": "### 处理错误、缩略图和下载链接"
      },
      "typeVersion": 1
    },
    {
      "id": "5d96a299-f67c-4ee1-ac9b-d5a1374264e1",
      "name": "失败",
      "type": "n8n-nodes-base.form",
      "position": [
        1920,
        240
      ],
      "webhookId": "898add9e-df30-4b09-aa45-9773a250f79d",
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Error",
        "completionMessage": "=<h2>{{ $json.error.code }}</h2> {{ $json.error.message }}"
      },
      "typeVersion": 1
    },
    {
      "id": "4231bd6a-64f2-4dea-b5c7-a3c1f5cdbca6",
      "name": "已完成",
      "type": "n8n-nodes-base.form",
      "position": [
        1920,
        48
      ],
      "webhookId": "4fb73428-39f7-44c8-b7ff-287fa4aa745b",
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Generation Completed",
        "completionMessage": "=<a href=\"{{ $json.content[0].webViewLink }}\"><img src=\"{{ $json.content[1].thumbnailLink }}\"><a>\n<br>\n<b><a href=\"{{ $json.content[0].webViewLink }}\">Download</a></b>"
      },
      "typeVersion": 1
    },
    {
      "id": "1e4887e9-8236-4d87-b703-bb57142b6407",
      "name": "缩略图1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1184,
        144
      ],
      "parameters": {
        "url": "=https://api.openai.com/v1/videos/{{ $json.id }}/content",
        "options": {
          "redirect": {
            "redirect": {}
          },
          "response": {
            "response": {
              "responseFormat": "file",
              "outputPropertyName": "thumbnail.webp"
            }
          }
        },
        "sendQuery": true,
        "sendHeaders": true,
        "queryParameters": {
          "parameters": [
            {
              "name": "variant",
              "value": "thumbnail"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Authorization",
              "value": "=Bearer {{ $('On form submission').item.json.YOUR_ACCESS_TOKEN }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "58c457f8-4d8d-40c7-b2df-a2a4f3b93d80",
      "name": "合并",
      "type": "n8n-nodes-base.merge",
      "position": [
        1616,
        48
      ],
      "parameters": {},
      "typeVersion": 3.2
    },
    {
      "id": "de9cc0c1-a726-4935-83d0-da4aefbd7440",
      "name": "上传视频",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1408,
        -48
      ],
      "parameters": {
        "name": "={{ $json.id }}.mp4",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1hUOUwcbOPpkfT4zCOGCju61qXVC3uenw",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1hUOUwcbOPpkfT4zCOGCju61qXVC3uenw",
          "cachedResultName": "Sora"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "rqC0SH1li8N0Qvrg",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "26f032a9-d6d2-40a3-bdd3-32c985b7bbb6",
      "name": "Aggregate",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1776,
        48
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData",
        "destinationFieldName": "content"
      },
      "typeVersion": 1
    },
    {
      "id": "1899d016-5475-41b8-82e2-9b07727f617e",
      "name": "上传缩略图",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1408,
        144
      ],
      "parameters": {
        "name": "={{ $json.id }}.webp",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive",
          "cachedResultUrl": "https://drive.google.com/drive/my-drive",
          "cachedResultName": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1hUOUwcbOPpkfT4zCOGCju61qXVC3uenw",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1hUOUwcbOPpkfT4zCOGCju61qXVC3uenw",
          "cachedResultName": "Sora"
        },
        "inputDataFieldName": "thumbnail.webp"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "rqC0SH1li8N0Qvrg",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "63abde8c-6130-44a4-a4a4-51deacb87fed",
  "connections": {
    "Wait": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Aggregate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Status": {
      "main": [
        [
          {
            "node": "Download",
            "type": "main",
            "index": 0
          },
          {
            "node": "Thumbnail1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Failed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download": {
      "main": [
        [
          {
            "node": "Upload Video",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Settings": {
      "main": [
        [
          {
            "node": "Reference",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate": {
      "main": [
        [
          {
            "node": "Completed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reference": {
      "main": [
        [
          {
            "node": "Create Video A",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Create Video B",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Thumbnail1": {
      "main": [
        [
          {
            "node": "Upload Thumbnail",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Status": {
      "main": [
        [
          {
            "node": "Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Video": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Video A": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Video B": {
      "main": [
        [
          {
            "node": "Check Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Thumbnail": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "On form submission": {
      "main": [
        [
          {
            "node": "Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。

这个工作流适合什么场景?

高级 - 内容创作, 多模态 AI

需要付费吗?

本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。

工作流信息
难度等级
高级
节点数量21
分类2
节点类型10
难度说明

适合高级用户,包含 16+ 个节点的复杂工作流

作者
Juan Cristóbal Andrews

Juan Cristóbal Andrews

@crisandrews

eCommerce | Marketing | Data Science

外部链接
在 n8n.io 查看

分享此工作流