[ PROMPT_NODE_24856 ]
dimensions
[ SKILL_DOCUMENTATION ]
# 视频尺寸与分辨率
HeyGen 支持多种视频尺寸和宽高比,以适配不同的平台和使用场景。
## 标准分辨率
### 横屏 (16:9)
| 分辨率 | 宽度 | 高度 | 使用场景 |
|------------|-------|--------|----------|
| 720p | 1280 | 720 | 标准质量,处理速度快 |
| 1080p | 1920 | 1080 | 高质量,最常用 |
### 竖屏 (9:16)
| 分辨率 | 宽度 | 高度 | 使用场景 |
|------------|-------|--------|----------|
| 720p | 720 | 1280 | 移动端优先内容 |
| 1080p | 1080 | 1920 | 高质量竖屏 |
### 正方形 (1:1)
| 分辨率 | 宽度 | 高度 | 使用场景 |
|------------|-------|--------|----------|
| 720p | 720 | 720 | 社交媒体帖子 |
| 1080p | 1080 | 1080 | 高质量正方形 |
## 设置尺寸
### TypeScript
typescript
// 横屏 1080p
const landscapeConfig = {
video_inputs: [...],
dimension: {
width: 1920,
height: 1080
}
};
// 竖屏 1080p
const portraitConfig = {
video_inputs: [...],
dimension: {
width: 1080,
height: 1920
}
};
// 正方形 1080p
const squareConfig = {
video_inputs: [...],
dimension: {
width: 1080,
height: 1080
}
};
### curl
bash
# 横屏 1080p
curl -X POST "https://api.heygen.com/v2/video/generate"
-H "X-Api-Key: $HEYGEN_API_KEY"
-H "Content-Type: application/json"
-d '{
"video_inputs": [...],
"dimension": {
"width": 1920,
"height": 1080
}
}'
## 尺寸辅助函数
typescript
type AspectRatio = "16:9" | "9:16" | "1:1" | "4:3" | "4:5";
type Quality = "720p" | "1080p";
interface Dimensions {
width: number;
height: number;
}
function getDimensions(aspectRatio: AspectRatio, quality: Quality): Dimensions {
const configs: Record<AspectRatio, Record> = {
"16:9": {
"720p": { width: 1280, height: 720 },
"1080p": { width: 1920, height: 1080 },
},
"9:16": {
"720p": { width: 720, height: 1280 },
"1080p": { width: 1080, height: 1920 },
},
"1:1": {
"720p": { width: 720, height: 720 },
"1080p": { width: 1080, height: 1080 },
},
"4:3": {
"720p": { width: 960, height: 720 },
"1080p": { width: 1440, height: 1080 },
},
"4:5": {
"720p": { width: 576, height: 720 },
"1080p": { width: 864, height: 1080 },
},
};
return configs[aspectRatio][quality];
}
// 用法
const youTubeDimensions = getDimensions("16:9", "1080p");
co