[ PROMPT_NODE_24852 ]
backgrounds
[ SKILL_DOCUMENTATION ]
# 视频背景
HeyGen 支持多种背景类型,以自定义你的数字人视频外观。
## 背景类型
| 类型 | 描述 |
|------|-------------|
| `color` | 纯色背景 |
| `image` | 静态图像背景 |
| `video` | 循环视频背景 |
## 纯色背景
最简单的选项——使用纯色:
typescript
const videoConfig = {
video_inputs: [
{
character: {
type: "avatar",
avatar_id: "josh_lite3_20230714",
avatar_style: "normal",
},
voice: {
type: "text",
input_text: "Hello with a colored background!",
voice_id: "1bd001e7e50f421d891986aad5158bc8",
},
background: {
type: "color",
value: "#FFFFFF", // 白色背景
},
},
],
};
### 常用颜色值
| 颜色 | 十六进制值 | 使用场景 |
|-------|-----------|----------|
| 白色 | `#FFFFFF` | 简洁、专业 |
| 黑色 | `#000000` | 戏剧性、电影感 |
| 蓝色 | `#0066CC` | 企业、可信赖 |
| 绿色 | `#00FF00` | 色度键(用于合成) |
| 灰色 | `#808080` | 中性、现代 |
### 使用透明/绿幕
用于后期制作中的合成:
typescript
background: {
type: "color",
value: "#00FF00", // 绿幕
}
## 图像背景
使用静态图像作为背景:
### 从 URL
typescript
const videoConfig = {
video_inputs: [
{
character: {
type: "avatar",
avatar_id: "josh_lite3_20230714",
avatar_style: "normal",
},
voice: {
type: "text",
input_text: "Check out this custom background!",
voice_id: "1bd001e7e50f421d891986aad5158bc8",
},
background: {
type: "image",
url: "https://example.com/my-background.jpg",
},
},
],
};
### 从已上传资源
首先上传你的图像,然后使用资源 URL:
typescript
// 1. 上传图像
const assetId = await uploadFile("./background.jpg", "image/jpeg");
// 2. 在视频配置中使用
const videoConfig = {
video_inputs: [
{
character: {...},
voice: {...},
background: {
type: "image",
url: `https://files.heygen.ai/asset/${assetId}`,
},
},
],
};
### 图像要求
- **格式**: JPEG, PNG
- **推荐尺寸**: 匹配视频分辨率(例如 1080p 视频为 1920x1080)
- **宽高比**: 应与视频宽高比匹配
- **文件大小**: 建议 10MB 以下
## 视频背景