全自动短视频生成系统搭建指南

一、基础环境配置
1.1 必要组件
-
n8n工作流平台
-
推荐Docker部署方式 -
需保持长期运行状态
-
-
网络代理配置
-
必须开启全局模式(中国地区用户) -
允许局域网连接设置示例: -
-
二、核心工作流实现
2.1 用户输入模块
表单设计规范
-
采用标准化输入接口 -
支持多平台文案风格选择 -
数据预处理
// 输入标准化示例functionformatInput(text) { return { cleanText: text.trim(), lang: detectLanguage(text), timestamp: newDate() }}

2.2 AI文案生成引擎
高级提示词设计
# 系统级提示模板role:资深自媒体专家task:-生成爆款短视频文案-输出结构化内容requirements:1.标题≤10字2.正文100-150字3.包含三大要素:-悬念钩子(前3秒)-核心价值点×3-行动召唤output_format: { "title":"string", "content":"string" }
Gemini模型配置
-
API密钥获取流程: -
模型选择建议: -
常规使用:gemini-1.5-flash -
高质量需求:gemini-1.5-pro
-
测试验证

三、视频生成服务部署
3.1 MoneyPrinterTurbo部署
# 完整部署流程git clone https://github.com/harry0703/MoneyPrinterTurbo.gitcd MoneyPrinterTurbocp config.example.toml config.toml# 编辑配置文件后docker compose up -d --build
需要注意优先拉取docker 的python环境。docker pull python:3.11-slim-bullseye
3.2 关键服务配置
Pexels素材库
-
注册地址:https://www.pexels.com/api -
配置示例:
网络问题解决方案
# 修改voice.py解决代理问题communicate = edge_tts.Communicate( text=script, voice=voice_name, proxy="http://host.docker.internal:7890"# Docker特殊地址)

四、自动化流程详解
4.1 视频生成API
POST/api/v1/videosHTTP/1.1Host: host.docker.internal:8080Content-Type: application/json{"video_subject":"{{title}}","video_script":"{{content}}","video_aspect":"9:16","voice_name":"zh-CN-YunxiNeural","subtitle_enabled":true}
4.2 状态轮询机制

判断逻辑
functioncheckStatus(taskId) { do { status = getTaskStatus(taskId) if(status.progress === 100) { return status.video_url } sleep(5000) } while(true)}
五、多平台发布方案
5.1 YouTube配置
-
启用API服务: -
OAuth凭证创建:
5.2 发布测试

六、完整工作流展示

附录:常见问题处理
|
|
|
---|---|---|
|
|
![]() |
|
GET /videoCategories |
![]() |
|
host.docker.internal 替代localhost |
![]() |

本篇文章来源于微信公众号: DataScience
文章评论