74 lines
1.1 KiB
Markdown
74 lines
1.1 KiB
Markdown
# AI Demo - 后端服务
|
|
|
|
视频合成后端服务,使用 FFmpeg 处理视频合成任务。
|
|
|
|
## 前置要求
|
|
|
|
- Node.js 18+
|
|
- **FFmpeg** - 需要安装到系统环境变量中
|
|
|
|
### 安装 FFmpeg
|
|
|
|
#### Windows
|
|
1. 下载 FFmpeg: https://www.gyan.dev/ffmpeg/builds/
|
|
2. 解压到 `C:\ffmpeg`
|
|
3. 添加 `C:\ffmpeg\bin` 到系统环境变量 PATH
|
|
|
|
#### macOS
|
|
```bash
|
|
brew install ffmpeg
|
|
```
|
|
|
|
#### Linux
|
|
```bash
|
|
sudo apt update && sudo apt install ffmpeg
|
|
```
|
|
|
|
## 安装依赖
|
|
|
|
```bash
|
|
cd server
|
|
npm install
|
|
```
|
|
|
|
## 启动服务
|
|
|
|
```bash
|
|
npm run dev # 开发模式(自动重启)
|
|
npm start # 生产模式
|
|
```
|
|
|
|
服务将在 http://localhost:3001 启动。
|
|
|
|
## API 接口
|
|
|
|
### POST /api/video/compose
|
|
|
|
合成视频
|
|
|
|
**请求体:**
|
|
```json
|
|
{
|
|
"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`。
|