8
n8n 中文网amn8n.com

自动化视频上传 → 自动缩略图 → Google Drive

中级

这是一个Content Creation, Multimodal AI领域的自动化工作流,包含 9 个节点。主要使用 If, Webhook, GoogleDrive, ExecuteCommand, ReadBinaryFile 等节点。 使用 FFmpeg 和 Google Drive 自动化视频上传和缩略图生成

前置要求
  • HTTP Webhook 端点(n8n 会自动生成)
  • Google Drive API 凭证
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
  "id": "W69y1dllbQpuNZQ0",
  "meta": {
    "instanceId": "14e4c77104722ab186539dfea5182e419aecc83d85963fe13f6de862c875ebfa",
    "templateCredsSetupCompleted": true
  },
  "name": "自动化视频上传 → 自动缩略图 → Google Drive",
  "tags": [],
  "nodes": [
    {
      "id": "0f0dc32f-cadc-4001-9ded-4049186ed556",
      "name": "便签",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -570,
        -180
      ],
      "parameters": {
        "width": 1600,
        "height": 340,
        "content": "## 视频上传 → 自动缩略图 → Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "9e6b7fcd-2c7a-4762-8dd7-efa102ad9599",
      "name": "便签1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -560,
        180
      ],
      "parameters": {
        "width": 1580,
        "height": 660,
        "content": "# **节点分解与说明:**"
      },
      "typeVersion": 1
    },
    {
      "id": "eb68ca4d-93d6-4535-a009-be7a129e18f3",
      "name": "接受视频上传 (Webhook)",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -480,
        0
      ],
      "webhookId": "53a1804d-fde6-4e38-abd4-f22f5cf2e4b2",
      "parameters": {
        "path": "mediaUpload",
        "options": {},
        "httpMethod": "POST",
        "responseData": "allEntries",
        "responseMode": "lastNode"
      },
      "typeVersion": 1
    },
    {
      "id": "22cf7a78-1f4b-4dac-83b6-718476d74c11",
      "name": "验证上传是否为视频 (IF)",
      "type": "n8n-nodes-base.if",
      "position": [
        -260,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "string": [
            {
              "value1": "={{$binary.file.mimeType}}",
              "value2": "video/",
              "operation": "contains"
            }
          ],
          "boolean": []
        }
      },
      "typeVersion": 2
    },
    {
      "id": "9bc950c0-4ffd-4c86-9345-7aa2bb682625",
      "name": "将上传持久化到 /tmp (写入二进制文件)",
      "type": "n8n-nodes-base.writeBinaryFile",
      "position": [
        -40,
        0
      ],
      "parameters": {
        "options": {},
        "fileName": "={{$('Accept Video Upload (Webhook)').item.binary.media.fileName ? \"/tmp/\" + $('Accept Video Upload (Webhook)').item.binary.media.fileName : \"/tmp/input.mp4\"}}",
        "dataPropertyName": "media"
      },
      "typeVersion": 1
    },
    {
      "id": "b8ecc2ac-ddca-42cb-a735-ec3e79e02f1c",
      "name": "使用 FFmpeg 提取缩略图(自动安装)(执行命令)",
      "type": "n8n-nodes-base.executeCommand",
      "position": [
        180,
        0
      ],
      "parameters": {
        "command": "=set -e\n\nVIDEO=\"{{ $('Persist Upload to /tmp (Write Binary File)').item.json.fileName }}\"\nOUT=\"/tmp/{{ $('Accept Video Upload (Webhook)').item.binary.media.fileName }}_thumbnail.jpg\"\n\n# 1) locate ffmpeg\nif command -v ffmpeg >/dev/null 2>&1; then\n  FFMPEG_BIN=\"$(command -v ffmpeg)\"\nelif [ -x /tmp/ffmpeg/ffmpeg ]; then\n  FFMPEG_BIN=\"/tmp/ffmpeg/ffmpeg\"\nelse\n  # 2) fetch a static ffmpeg (no root). Works on most Linux hosts/containers.\n  ARCH=\"$(uname -m)\"\n  case \"$ARCH\" in\n    x86_64|amd64)  URL=\"https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-amd64-static.tar.xz\" ;;\n    aarch64|arm64) URL=\"https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-arm64-static.tar.xz\" ;;\n    armv7l|armhf)  URL=\"https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-armhf-static.tar.xz\" ;;\n    i686|i386)     URL=\"https://johnvansickle.com/ffmpeg/releases/ffmpeg-release-i686-static.tar.xz\" ;;\n    *) echo \"Unsupported CPU arch: $ARCH\" >&2; exit 1 ;;\n  esac\n\n  mkdir -p /tmp/ffmpeg && cd /tmp/ffmpeg\n\n  # downloader: prefer curl, else wget\n  if command -v curl >/dev/null 2>&1; then\n    curl -fsSL \"$URL\" -o ffmpeg.tar.xz\n  elif command -v wget >/dev/null 2>&1; then\n    wget -qO ffmpeg.tar.xz \"$URL\"\n  else\n    echo \"Need curl or wget to fetch ffmpeg\" >&2\n    exit 1\n  fi\n\n  # extract (xz support required by most tars on Linux)\n  tar -xJf ffmpeg.tar.xz --strip-components=1\n  chmod +x ./ffmpeg ./ffprobe\n  FFMPEG_BIN=\"/tmp/ffmpeg/ffmpeg\"\nfi\n\n# 3) do the work\n\"$FFMPEG_BIN\" -y -ss 5 -i \"$VIDEO\" -frames:v 1 -q:v 2 \"$OUT\"\n",
        "executeOnce": false
      },
      "typeVersion": 1
    },
    {
      "id": "736a61c2-bfeb-4821-8ca2-a0e54ddfb04d",
      "name": "从磁盘加载缩略图 (读取二进制文件)",
      "type": "n8n-nodes-base.readBinaryFile",
      "position": [
        400,
        0
      ],
      "parameters": {
        "filePath": "=/tmp/{{ $('Persist Upload to /tmp (Write Binary File)').item.binary.media.fileName }}_thumbnail.jpg"
      },
      "typeVersion": 1
    },
    {
      "id": "8b2760d0-22f8-4291-9663-71f01e3c397b",
      "name": "上传缩略图到 Drive (Google Drive)",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        620,
        0
      ],
      "parameters": {
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1AXMk_yyq3sD_Oc9f5eRLuqtJevbX-d1i",
          "cachedResultUrl": "",
          "cachedResultName": "Video_Thumbnail"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "LzEW2SwCQjcSdvdB",
          "name": "Google Drive account 6"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "418127d5-2902-472c-b4dc-5f9628c7c6b7",
      "name": "返回 API 响应 (响应 Webhook)",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        840,
        0
      ],
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "respondWith": "json",
        "responseBody": "={\n  \"ok\": true,\n  \"fileName\": \"{{ $json.name || $json.originalFilename }}\",\n  \"type\": \"{{ $json.mimeType || $json.fullFileExtension || $json.fileExtension }}\",\n  \"sizeBytes\": \"{{ $json.size }}\",\n  \"sizeHuman\": \"={{ (Number($json.size) >= 1048576 ? (Number($json.size)/1048576).toFixed(2) + ' MB' : (Number($json.size)/1024).toFixed(2) + ' KB') }}\",\n  \"url\": \"={{ $json.webViewLink || ('https://drive.google.com/file/d/' + $json.id + '/view') }}\",\n  \"downloadUrl\": \"={{ $json.webContentLink || ('https://drive.google.com/uc?id=' + $json.id + '&export=download') }}\",\n  \"createdTime\": \"{{ $json.createdTime }}\",\n  \"modifiedTime\": \"{{ $json.modifiedTime }}\",\n  \"image\": {\n    \"width\": \"{{ $json.imageMediaMetadata && $json.imageMediaMetadata.width }}\",\n    \"height\": \"{{ $json.imageMediaMetadata && $json.imageMediaMetadata.height }}\",\n    \"rotation\": \"{{ $json.imageMediaMetadata && $json.imageMediaMetadata.rotation }}\"\n  },\n  \"owner\": \"{{ $json.owners && $json.owners[0] && $json.owners[0].displayName }}\"\n}"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "8797b44a-f6aa-4043-9997-84a2147ae0aa",
  "connections": {
    "Accept Video Upload (Webhook)": {
      "main": [
        [
          {
            "node": "Validate Upload is Video (IF)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate Upload is Video (IF)": {
      "main": [
        [
          {
            "node": "Persist Upload to /tmp (Write Binary File)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload Thumbnail to Drive (Google Drive)": {
      "main": [
        [
          {
            "node": "Return API Response (Respond to Webhook)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Persist Upload to /tmp (Write Binary File)": {
      "main": [
        [
          {
            "node": "Extract Thumbnail with FFmpeg (Auto-Install) (Execute Command)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Load Thumbnail from Disk (Read Binary File)": {
      "main": [
        [
          {
            "node": "Upload Thumbnail to Drive (Google Drive)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Thumbnail with FFmpeg (Auto-Install) (Execute Command)": {
      "main": [
        [
          {
            "node": "Load Thumbnail from Disk (Read Binary File)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
常见问题

如何使用这个工作流?

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

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

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

需要付费吗?

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

工作流信息
难度等级
中级
节点数量9
分类2
节点类型8
难度说明

适合有一定经验的用户,包含 6-15 个节点的中等复杂度工作流

作者
WeblineIndia

WeblineIndia

@weblineindia

A Leading Software Engineering, Consulting & Outsourcing Services Company in USA & India serving Clients Globally since 1999.

外部链接
在 n8n.io 查看

分享此工作流