1.1 KiB
1.1 KiB
AI Demo - 后端服务
视频合成后端服务,使用 FFmpeg 处理视频合成任务。
前置要求
- Node.js 18+
- FFmpeg - 需要安装到系统环境变量中
安装 FFmpeg
Windows
- 下载 FFmpeg: https://www.gyan.dev/ffmpeg/builds/
- 解压到
C:\ffmpeg - 添加
C:\ffmpeg\bin到系统环境变量 PATH
macOS
brew install ffmpeg
Linux
sudo apt update && sudo apt install ffmpeg
安装依赖
cd server
npm install
启动服务
npm run dev # 开发模式(自动重启)
npm start # 生产模式
服务将在 http://localhost:3001 启动。
API 接口
POST /api/video/compose
合成视频
请求体:
{
"slides": [
{
"imageUrl": "https://example.com/image1.png",
"audioUrl": "https://example.com/audio1.mp3"
}
],
"width": 1920,
"height": 1080
}
响应: video/mp4 格式的视频文件
GET /api/video/health
检查视频服务状态
前端配置
前端 Vite 开发服务器会自动代理 /api 请求到后端服务。
确保后端服务运行在 http://localhost:3001。