RenderingVideo 文档
添加字幕
使用内联字幕、素材池字幕和远程字幕源的教程
添加字幕
这个教程同时覆盖两种方式:直接内联字幕数据,以及通过 assets.subtitles 复用字幕。
1. 内联字幕示例
{
"type": "subtitle",
"start": 0,
"duration": 6,
"words": [
{ "word": "hello", "punctuated_word": "Hello", "start": 0, "end": 0.4 },
{ "word": "world", "punctuated_word": "world!", "start": 0.4, "end": 0.9 }
],
"config": {
"position": "bottom",
"fontSize": 58,
"textColor": "#ffffff",
"highlightColor": "#22d3ee",
"backgroundColor": "rgba(0,0,0,0.45)"
}
}
2. 通过素材池复用字幕
{
"assets": {
"subtitles": [
{
"id": "sub-main",
"words": [
{ "word": "hello", "punctuated_word": "Hello", "start": 0, "end": 0.4 },
{ "word": "world", "punctuated_word": "world!", "start": 0.4, "end": 0.9 }
]
}
]
}
}
引用方式:
{
"type": "subtitle",
"start": 0,
"duration": 6,
"words": { "$ref": "sub-main" },
"config": {
"position": "bottom",
"fontSize": 58,
"highlightColor": "#22d3ee"
}
}
3. 远程字幕 JSON
{
"type": "subtitle",
"start": 0,
"duration": 6,
"words": {
"src": "https://example.com/subtitle.json"
}
}
4. 实战建议
- 字幕时长要和语音片段对齐
- 移动端要留出底部安全区
- 同一套字幕会重复使用时,优先用
$ref
5. 继续阅读
- 字幕元素:看 Subtitle 元素
- 示例集合:看 示例