移除视频背景并在自定义背景上合成(使用Google Drive)
高级
这是一个自动化工作流,包含 25 个节点。主要使用 If, Set, Wait, Merge, Webhook 等节点。 移除视频背景并在自定义视频背景上合成(使用Google Drive)
前置要求
- •HTTP Webhook 端点(n8n 会自动生成)
- •Google Drive API 凭证
- •可能需要目标 API 的认证凭证
分类
-
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"name": "移除视频背景并在自定义背景上合成(使用 Google Drive)",
"nodes": [
{
"id": "sticky-overview",
"name": "📋 概述",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1100,
60
],
"parameters": {
"width": 520,
"height": 580,
"content": "## 🎬 视频背景移除与合成"
},
"typeVersion": 1,
"notesTextSize": "large",
"notesBackgroundColor": 4
},
{
"id": "sticky-api-key",
"name": "🔑 API 密钥设置",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
60
],
"parameters": {
"width": 380,
"height": 360,
"content": "## 🔑 API 密钥设置(必需)"
},
"typeVersion": 1
},
{
"id": "sticky-inputs",
"name": "📥 输入",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1100,
660
],
"parameters": {
"width": 380,
"height": 280,
"content": "## 📥 所需输入视频"
},
"typeVersion": 1
},
{
"id": "sticky-composition",
"name": "🎨 合成",
"type": "n8n-nodes-base.stickyNote",
"position": [
-480,
460
],
"parameters": {
"width": 380,
"height": 360,
"content": "## 🎨 合成模板"
},
"typeVersion": 1
},
{
"id": "sticky-polling",
"name": "🔄 轮询",
"type": "n8n-nodes-base.stickyNote",
"position": [
-60,
60
],
"parameters": {
"width": 380,
"height": 300,
"content": "## 🔄 处理与轮询"
},
"typeVersion": 1
},
{
"id": "sticky-gdrive",
"name": "💾 Google Drive",
"type": "n8n-nodes-base.stickyNote",
"position": [
540,
60
],
"parameters": {
"width": 380,
"height": 280,
"content": "## 💾 Google Drive 设置"
},
"typeVersion": 1
},
{
"id": "sticky-usage",
"name": "🚀 使用",
"type": "n8n-nodes-base.stickyNote",
"position": [
1140,
60
],
"parameters": {
"width": 380,
"height": 340,
"content": "## 🚀 使用方法"
},
"typeVersion": 1
},
{
"id": "webhook-1",
"name": "Webhook触发器",
"type": "n8n-nodes-base.webhook",
"position": [
-1040,
900
],
"webhookId": "compose-video",
"parameters": {
"path": "compose-video",
"options": {
"responseData": "allEntries"
},
"httpMethod": "POST",
"responseMode": "responseNode"
},
"typeVersion": 1.1
},
{
"id": "manual-1",
"name": "手动触发器",
"type": "n8n-nodes-base.manualTrigger",
"position": [
-1040,
1040
],
"parameters": {},
"typeVersion": 1
},
{
"id": "set-web-1",
"name": "提取 Webhook 数据",
"type": "n8n-nodes-base.set",
"position": [
-820,
900
],
"parameters": {
"assignments": {
"assignments": [
{
"name": "foreground_video_url",
"type": "string",
"value": "={{ $json.body?.foreground_video_url ?? $json.foreground_video_url ?? 'https://videos.videobgremover.com/public-videos/assets/ai-actor.mp4' }}"
},
{
"name": "background_video_url",
"type": "string",
"value": "={{ $json.body?.background_video_url ?? $json.background_video_url ?? 'https://videos.videobgremover.com/public-videos/assets/vertical_background.mp4' }}"
},
{
"name": "source",
"type": "string",
"value": "webhook"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "set-manual-1",
"name": "示例视频 URL(在此编辑)",
"type": "n8n-nodes-base.set",
"position": [
-820,
1040
],
"parameters": {
"assignments": {
"assignments": [
{
"name": "foreground_video_url",
"type": "string",
"value": "https://videos.videobgremover.com/public-videos/assets/ai-actor.mp4"
},
{
"name": "background_video_url",
"type": "string",
"value": "https://videos.videobgremover.com/public-videos/assets/vertical_background.mp4"
},
{
"name": "source",
"type": "string",
"value": "manual"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "merge-1",
"name": "合并触发器",
"type": "n8n-nodes-base.merge",
"position": [
-600,
970
],
"parameters": {
"mode": "append",
"options": {}
},
"typeVersion": 2.1
},
{
"id": "http-1",
"name": "1. 创建作业(上传前景)",
"type": "n8n-nodes-base.httpRequest",
"position": [
-380,
970
],
"parameters": {
"url": "https://api.videobgremover.com/api/v1/jobs",
"method": "POST",
"options": {
"response": {
"response": {
"neverError": true,
"responseFormat": "json"
}
}
},
"jsonBody": "={ \"video_url\": \"{{ $json.foreground_video_url }}\" }",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "X-API-Key",
"value": "={{ $vars.VIDEOBGREMOVER_KEY }}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.1
},
{
"id": "http-2",
"name": "2. 开始合成",
"type": "n8n-nodes-base.httpRequest",
"position": [
-140,
970
],
"parameters": {
"url": "=https://api.videobgremover.com/api/v1/jobs/{{ $json.id }}/start",
"method": "POST",
"options": {
"response": {
"response": {
"neverError": true,
"responseFormat": "json"
}
}
},
"jsonBody": "={\n \"background\": {\n \"type\": \"composition\",\n \"composition\": {\n \"template\": \"ai_ugc_ad\",\n \"background_type\": \"video\",\n \"background_url\": \"{{ $('Merge Triggers').item.json.background_video_url }}\",\n \"background_audio_enabled\": true,\n \"background_audio_volume\": 0.3,\n \"export_format\": \"h264\",\n \"export_preset\": \"medium\"\n }\n }\n}",
"sendBody": true,
"sendHeaders": true,
"specifyBody": "json",
"headerParameters": {
"parameters": [
{
"name": "X-API-Key",
"value": "={{ $vars.VIDEOBGREMOVER_KEY }}"
},
{
"name": "Content-Type",
"value": "application/json"
}
]
}
},
"typeVersion": 4.1
},
{
"id": "http-3",
"name": "3. 检查作业状态",
"type": "n8n-nodes-base.httpRequest",
"position": [
100,
970
],
"parameters": {
"url": "=https://api.videobgremover.com/api/v1/jobs/{{ $('1. Create Job (Upload Foreground)').item.json.id }}/status",
"method": "GET",
"options": {
"response": {
"response": {
"neverError": true,
"responseFormat": "json"
}
}
},
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "X-API-Key",
"value": "={{ $vars.VIDEOBGREMOVER_KEY }}"
}
]
}
},
"typeVersion": 4.1
},
{
"id": "if-complete",
"name": "是否完成?",
"type": "n8n-nodes-base.if",
"position": [
300,
970
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "is_completed_condition",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.status }}",
"rightValue": "completed"
}
]
}
},
"typeVersion": 2
},
{
"id": "download",
"name": "4. 下载视频",
"type": "n8n-nodes-base.httpRequest",
"position": [
520,
830
],
"parameters": {
"url": "={{ $json.processed_video_url }}",
"options": {
"response": {
"response": {
"responseFormat": "file"
}
}
}
},
"typeVersion": 4.1
},
{
"id": "gdrive",
"name": "5. 上传到 Google Drive",
"type": "n8n-nodes-base.googleDrive",
"position": [
740,
830
],
"parameters": {
"name": "=composed_video_{{ $('1. Create Job (Upload Foreground)').item.json.id }}_{{ new Date().getTime() }}.mp4",
"driveId": {
"__rl": true,
"mode": "list",
"value": "My Drive"
},
"options": {
"simplifyOutput": true,
"googleFileConvert": false
},
"folderId": {
"__rl": true,
"mode": "list",
"value": "root"
},
"operation": "upload",
"binaryPropertyName": "data"
},
"typeVersion": 3
},
{
"id": "success-set",
"name": "构建成功响应",
"type": "n8n-nodes-base.set",
"position": [
960,
830
],
"parameters": {
"assignments": {
"assignments": [
{
"name": "final_result",
"type": "object",
"value": "={{ {\n success: true,\n job_id: $('1. Create Job (Upload Foreground)').item.json.id,\n export_id: $('2. Start Composition').item.json.export_id,\n google_drive_id: $json.id,\n google_drive_url: $json.webViewLink,\n download_url: $('3. Check Job Status').item.json.processed_video_url,\n message: 'Video composed successfully and saved to Google Drive',\n filename: $json.name,\n video_length_seconds: $('3. Check Job Status').item.json.length_seconds,\n source: $('Merge Triggers').item.json.source\n} }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "if-failed",
"name": "是否失败?",
"type": "n8n-nodes-base.if",
"position": [
500,
1200
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "is_failed_condition",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.status }}",
"rightValue": "failed"
}
]
}
},
"typeVersion": 2
},
{
"id": "wait-20",
"name": "等待 20 秒",
"type": "n8n-nodes-base.wait",
"position": [
720,
1340
],
"parameters": {
"unit": "seconds",
"amount": 20
},
"typeVersion": 1.1
},
{
"id": "error-set",
"name": "构建错误响应",
"type": "n8n-nodes-base.set",
"position": [
720,
1200
],
"parameters": {
"assignments": {
"assignments": [
{
"name": "final_result",
"type": "object",
"value": "={{ {\n success: false,\n job_id: $('1. Create Job (Upload Foreground)').item.json.id,\n error: $json.error || 'Video composition failed',\n status: $json.status,\n message: 'Failed to compose video',\n source: $('Merge Triggers').item.json.source\n} }}"
}
]
}
},
"typeVersion": 3.3
},
{
"id": "if-webhook",
"name": "来自 Webhook?",
"type": "n8n-nodes-base.if",
"position": [
1180,
1010
],
"parameters": {
"options": {},
"conditions": {
"options": {
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "is_webhook_condition",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.final_result?.source ?? $json.source }}",
"rightValue": "webhook"
}
]
}
},
"typeVersion": 2
},
{
"id": "respond",
"name": "响应 Webhook",
"type": "n8n-nodes-base.respondToWebhook",
"position": [
1400,
920
],
"parameters": {
"responseBody": "={{ $json.final_result ?? $json }}",
"responseCode": 200
},
"typeVersion": 1.1
},
{
"id": "end-manual",
"name": "手动测试完成",
"type": "n8n-nodes-base.set",
"position": [
1400,
1100
],
"parameters": {
"assignments": {
"assignments": [
{
"name": "final_result",
"type": "object",
"value": "={{ $json.final_result ?? $json }}"
}
]
}
},
"typeVersion": 3.3
}
],
"settings": {
"executionOrder": "v1"
},
"connections": {
"Wait 20s": {
"main": [
[
{
"node": "3. Check Job Status",
"type": "main",
"index": 0
}
]
]
},
"Has Failed?": {
"main": [
[
{
"node": "Build Error Response",
"type": "main",
"index": 0
}
],
[
{
"node": "Wait 20s",
"type": "main",
"index": 0
}
]
]
},
"Is Complete?": {
"main": [
[
{
"node": "4. Download Video",
"type": "main",
"index": 0
}
],
[
{
"node": "Has Failed?",
"type": "main",
"index": 0
}
]
]
},
"From Webhook?": {
"main": [
[
{
"node": "Respond to Webhook",
"type": "main",
"index": 0
}
],
[
{
"node": "Manual Test Complete",
"type": "main",
"index": 0
}
]
]
},
"Manual Trigger": {
"main": [
[
{
"node": "Sample Video URLs (Edit Here)",
"type": "main",
"index": 0
}
]
]
},
"Merge Triggers": {
"main": [
[
{
"node": "1. Create Job (Upload Foreground)",
"type": "main",
"index": 0
}
]
]
},
"Webhook Trigger": {
"main": [
[
{
"node": "Extract Webhook Data",
"type": "main",
"index": 0
}
]
]
},
"4. Download Video": {
"main": [
[
{
"node": "5. Upload to Google Drive",
"type": "main",
"index": 0
}
]
]
},
"3. Check Job Status": {
"main": [
[
{
"node": "Is Complete?",
"type": "main",
"index": 0
}
]
]
},
"2. Start Composition": {
"main": [
[
{
"node": "3. Check Job Status",
"type": "main",
"index": 0
}
]
]
},
"Build Error Response": {
"main": [
[
{
"node": "From Webhook?",
"type": "main",
"index": 0
}
]
]
},
"Extract Webhook Data": {
"main": [
[
{
"node": "Merge Triggers",
"type": "main",
"index": 0
}
]
]
},
"Build Success Response": {
"main": [
[
{
"node": "From Webhook?",
"type": "main",
"index": 0
}
]
]
},
"5. Upload to Google Drive": {
"main": [
[
{
"node": "Build Success Response",
"type": "main",
"index": 0
}
]
]
},
"Sample Video URLs (Edit Here)": {
"main": [
[
{
"node": "Merge Triggers",
"type": "main",
"index": 1
}
]
]
},
"1. Create Job (Upload Foreground)": {
"main": [
[
{
"node": "2. Start Composition",
"type": "main",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
高级
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
使用 Nano Banana (Gemini 图像) 生成 AI 背景
使用Gemini和VideoBGRemover创建带有AI生成背景的视频
If
Set
Code
+8
35 节点Paul Roussel
UGC - 截图→Gemini→Sora2→VBR(竖版)
使用Gemini、Sora 2和VideoBGRemover从应用录屏制作UGC广告
If
Set
Code
+8
39 节点Paul Roussel
使用 Google Drive 移除视频背景并合成到自定义图像背景
视频背景移除与图像合成,集成Google Drive
If
Set
Wait
+7
25 节点Paul Roussel
AI智能助手:与Supabase存储和Google Drive文件对话
AI智能助手:与Supabase存储和Google Drive文件对话
If
Set
Wait
+20
62 节点Mark Shcherbakov
工程
使用AI将Reddit帖子转换为短视频
使用AI将Reddit帖子转换为短视频
If
Set
Code
+11
43 节点Artur
人工智能
在可视化参考库中探索n8n节点
在可视化参考库中探索n8n节点
If
Ftp
Set
+93
113 节点I versus AI
其他