Gemini创意视频AI 评分 · 待评分AI 辅助编辑·未发现明显提示词注入风险n8n.io

YouTube 视频自动转博客文章:Gemini AI 转录

输入 YouTube 链接 → 下载音频 → Gemini 转录 → AI 生成结构化博客 → 输出 JSON

有一点经验步骤流程提示词贴士
给谁
内容创作者、营销人员、教育工作者、博主
你会得到
将任意 YouTube 视频自动转换为带标题、描述、分类、标签和完整转录文本的博客文章
你需要
n8n · yt-dlp

硬约束

需要自托管 n8n 实例,安装 yt-dlp,配置 Google Gemini API 密钥(googlePalmApi 凭证类型)。通过 POST 请求触发 webhook,工作流下载视频音频、转录、生成博客内容,最后将结构化 JSON 返回或转发到指定端点。

他们做了什么

作者 attakhalighi 在 n8n 官方模板库发布了该工作流模板。模板展示了如何通过 n8n 将 YouTube 视频 URL 经 webhook 传入后,自动下载音频、使用 Gemini 1.5 Flash 转录、再由 AI Agent 生成带固定 JSON Schema 的博客文章,最终通过 webhook 返回结果。

效果如何

作者报告该模板可将视频内容在数分钟内转换为可发布的博客文章,并保持与视频原语言一致(author_report)。模板已被 n8n 官方收录并展示。

值得知道

1)yt-dlp 必须安装在 n8n 所在的服务器上,云托管 n8n 可能无此权限;2)使用 googlePalmApi 凭证类型连接 Gemini,非标准 Gemini API 凭证名;3)AI Agent 的 systemMessage 强制要求 JSON markdown 代码块输出,Structured Output Parser 配合 autoFix 解析,并提供 jsonSchemaExample 作为格式参考;4)输出语言跟随输入转录文本的语言,非固定英文;5)输出 webhook 需自行配置为实际 CMS 或接收端;6)Webhook 路径为 57fddbda-a118-4546-a223-8e91a7d53ff6,响应模式为 responseNode;7)Set 节点中 videoUrl 取自 body.url,而非 body.videoUrl;8)本站未实测运行,复现前请检查 yt-dlp 可用性和 API 配额。

n8n 工作流模板

结构已检查 · 未实际运行

下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。

配置与测试清单

需要绑定的凭证

  • Google Gemini Chat Model 节点:绑定Google Gemini/PaLM API 凭证。
  • Transcribe a recording 节点:绑定Google Gemini/PaLM API 凭证。

需要替换的配置

  • 源模板来自 n8n 公开库 #8037(约 12 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
  • Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。

测试输入与预期结果

  • 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
  • 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。

模板处理说明

  • 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
  • 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。

模板获取日期: 2026-10-24

步骤

  1. 配置 Webhook 触发器并接收 YouTube URL

    在 n8n 中设置 Webhook 节点,方法选择 POST,路径为 57fddbda-a118-4546-a223-8e91a7d53ff6,响应模式设为 responseNode。调用方发送 JSON body:{"videoUrl": "https://www.youtube.com/watch?v=..."}。工作流从此节点启动。

  2. 生成时间戳

    使用 Set 节点生成当前 Unix 时间戳(now_unix = {{ new Date().getTime() }}),用于后续音频文件命名,避免文件名冲突。

  3. 下载 YouTube 音频

    使用 Execute Command 节点运行 yt-dlp 命令,提取视频音频并保存为 MP3。命令引用上游的 videoUrl 和时间戳。确保 n8n 运行环境已安装 yt-dlp。

    运行提示词 · 来源原文。Execute Command 节点的 Command 字段

    =yt-dlp -x --audio-format mp3 -o output-{{ $json.now_unix }}.mp3 '{{ $('Get Youtube Url').item.json.body.videoUrl }}'
  4. 读取 MP3 二进制文件

    使用 Read/Write Files from Disk 节点读取上一步生成的 MP3 文件(文件选择器:=output-{{ $('Get Time').item.json.now_unix }}.mp3),作为二进制数据传递给转录节点。

  5. Gemini 转录音频

    使用 Google Gemini 节点(models/gemini-1.5-flash)处理音频二进制输入,将语音内容转录为文本。需配置 googlePalmApi 凭证,resource 设为 audio,inputType 设为 binary。

  6. AI Agent 生成结构化博客文章

    AI Agent 节点接收转录文本,通过 Google Gemini Chat Model 和 Structured Output Parser 生成符合固定 JSON Schema 的博客文章。Structured Output Parser 启用 autoFix,并提供 jsonSchemaExample 作为格式示例。包含用户提示词和系统提示词两部分。

    运行提示词 · 来源原文。AI Agent 节点的 Text / User Message 字段

    =Please create a blog post from the following video transcript. Identify the key themes, structure the content logically, and generate a title, category, and tags.
    
    Transcript:
    {{ $json.content.parts[0].text }}

    运行提示词 · 来源原文。AI Agent 节点的 Options > System Message 字段

    =You are an expert content strategist and editor. Your task is to transform a raw video transcript into a well-structured and engaging blog post.
    
    You must adhere to the following rules:
    1.  Your entire response must be a single JSON object enclosed in a markdown code block (```json ... ```).
    2.  Do NOT include any introductory phrases, explanations, apologies, or any text whatsoever outside of the JSON markdown block.
    3.  The tone should be informative, clear, and engaging, transforming the conversational transcript into polished written content.
    4.  The language of all generated text in the output JSON must match the primary language of the input transcript.
    5.  The JSON object must have this exact structure:
    {
      "category": "A single, top-level category based on the content.",
      "tags": [
        "An array of 3 to 5 relevant, lowercase string tags."
      ],
      "title": "A creative, compelling title for the blog post.",
      "short_description": "A concise, one-to-two sentence summary of the blog post, optimized for search engines (around 150-160 characters).",
      "body": "The full blog post content formatted in HTML, including <h1>, <h2>, and <p> tags."
    }
  7. 合并视频链接与完整转录

    使用 Set 节点将原始 YouTube URL(videoUrl = {{ $('Get Youtube Url').item.json.body.url }})和完整转录文本(fulltext = {{ $('Transcribe a recording').item.json.content.parts[0].text }})添加到 AI Agent 的输出中,丰富最终返回的数据。includeOtherFields 设为 true 以保留上游字段。

  8. 返回博客文章 JSON

    使用 Respond to Webhook 节点将最终结构化 JSON(含博客文章、分类、标签、转录、原视频链接)返回给调用方,或转发到配置的 CMS/数据库端点。

可复制提示词

搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限

这一段是提示词,页面不会在这里插入广告。

你是一个 n8n 工作流搭建助手。用户希望复现「YouTube 视频自动转博客文章」模板。请先确认:1)用户是否有自托管 n8n 实例或云实例的 shell 访问权限以安装 yt-dlp;2)是否已获取 Google Gemini API 密钥;3)目标输出端点(CMS、Notion、Slack 或其他 webhook)。确认后指导用户按步骤导入 workflow JSON 或手动搭建节点,并替换凭证和输出端点。

先确认 yt-dlp 安装、Gemini API 密钥、输出端点,再导入或手动搭建

来源

Automated YouTube video to blog post conversion with Gemini AI transcription · attakhalighi · n8n.io · 2025-08-29

留言与反馈

试过这个方法吗?分享效果、遇到的问题或改进建议。留言审核后公开,请勿填写敏感信息。

正在加载…

    相关用例