主题
add_text
POST /add_text
口径:本页参数表最后核对于 v23.9(2026-10-27)。v24.0~v24.8 的改动(add_video 的 timeline_start/timeline_end 别名、apply_edl 批内失败计数、resource/search 的 limit 与 count 等价、/agent/route 类型分诊等)以 llms-full.txt 与 GET /agent/capabilities 为准。
接口说明
向草稿添加一条文字或标题,支持字体、字号、颜色、透明度、描边、背景、阴影、位置、动画和分段样式。适合标题、说明、重点词和需要精确控制的单条文字。
文字是 overlay,叠加在图片、视频或音频之上。add_text 的时间参数只支持 start / end,单位秒,不支持 target_timerange。传了 target_timerange 会被忽略,多个标题可能堆在文字轨道开头。
正确做法是先确定图片和视频的主时间线,再添加文字。若发现 image_main / video_main 有空档,回到媒体轨道用 update_segment、update_segments 或 arrange_timeline 调整,不要用文字接口补主媒体时间。
请求参数
| 参数 | 必填 | 默认值 | 说明 |
|---|---|---|---|
text | 是 | — | 文字内容 |
start | 否 | 自动接在文字轨道末尾 | 时间轴开始时间,单位秒 |
end | 否 | start + 3 | 时间轴结束时间,单位秒;不传时默认显示 3 秒 |
draft_id | 是 | — | 草稿 ID,创建草稿后获得 |
transform_y | 否 | 0 | Y 轴位置偏移 |
transform_x | 否 | 0 | X 轴位置偏移 |
font | 否 | '文轩体' | 字体名称或资源 ID;先查询 resource_search |
color / font_color | 否 | '#FFFFFF' | 文字颜色 |
size / font_size | 否 | 8.0 | 字号 |
track_name | 否 | 'text_main' | 目标轨道名称 |
vertical | 否 | False | |
alpha / font_alpha | 否 | 1.0 | 透明度,1.0 为不透明 |
bold | 否 | False | 是否加粗 |
italic | 否 | False | 是否斜体 |
underline | 否 | False | 是否下划线 |
alignment / align | 否 | 'center' | 对齐方式,支持 left、center、right 或对应数字 |
outro_animation | 否 | None | 出场动画名称或资源 ID |
outro_duration | 否 | 0.5 | |
width | 否 | 1080 | 画布或素材宽度 |
height | 否 | 1920 | 画布或素材高度 |
fixed_width | 否 | -1 | 固定宽度,-1 表示不限制 |
fixed_height | 否 | -1 | 固定高度,-1 表示不限制 |
border_alpha | 否 | 1.0 | 描边透明度 |
border_color | 否 | '#000000' | 描边颜色 |
border_width | 否 | 0.0 | 描边宽度 |
background_color | 否 | '#000000' | 背景颜色 |
background_style | 否 | 0 | 背景样式 |
background_alpha | 否 | 0.0 | 背景透明度 |
background_round_radius | 否 | 0.0 | |
background_height | 否 | 0.14 | |
background_width | 否 | 0.14 | |
background_horizontal_offset | 否 | 0.5 | |
background_vertical_offset | 否 | 0.5 | |
shadow_enabled | 否 | False | 是否启用阴影 |
shadow_alpha | 否 | 0.9 | 阴影透明度 |
shadow_angle | 否 | -45.0 | |
shadow_color | 否 | '#000000' | 阴影颜色 |
shadow_distance | 否 | 5.0 | 阴影距离 |
shadow_smoothing | 否 | 0.15 | 阴影平滑度 |
bubble_effect_id | 否 | — | 气泡效果 ID |
bubble_resource_id | 否 | — | 气泡资源 ID |
effect_effect_id | 否 | — | 文字特效或花字 ID |
intro_animation | 否 | — | 入场动画名称或资源 ID |
intro_duration | 否 | 0.5 | |
text_styles | 否 | [] | 分段文字样式数组 |
line_spacing | 否 | 0.25 | 行间距 |
letter_spacing | 否 | 0.0 | 字间距 |
position_preset | 否 | — | 位置预设,覆盖 transform_x/y;可选 center、top-center、bottom-center、top-left、top-right、bottom-left、bottom-right |
size_preset | 否 | — | 尺寸预设,覆盖 scale_x/y;可选 small、medium、large、full-width |
motion_preset | 否 | — | 运镜预设,自动生成关键帧;可选 zoom_in_slowly、zoom_out_slowly、pan_left_to_right、pan_right_to_left、ken_burns、shake |
style_preset | 否 | — | 文字风格集合;可选 vlog_standard、cinematic、warning、subtitle |
style_preset 是默认值集合:显式传入的 color、size、bold、border_*、background_*、shadow_* 等优先,未传的字段由预设补齐,最后才用历史默认值。
调用示例
bash
curl -X POST https://your-domain.example/api/add_text \
-H "Content-Type: application/json" \
-H "X-API-Key: $VECTCUT_API_KEY" \
-d '{
"draft_id": "dfd_cat_demo_001",
"text": "今日推荐",
"start": 0,
"end": 5,
"font": "CC_Captial",
"font_size": 8.0,
"font_color": "#FFFFFF",
"intro_animation": "冲屏位移",
"outro_animation": "右上弹出",
"transform_x": 0,
"transform_y": -0.8
}'指定文字时间时这样写:
json
{
"draft_id": "dfd_cat_demo_001",
"text": "开场标题",
"start": 0,
"end": 5,
"track_name": "text_main",
"transform_x": 0,
"transform_y": -0.8
}不要写成:
json
{
"target_timerange": {
"start": 0,
"duration": 5000000
}
}排版与美化
两条最常见的文字质量问题——冲出画面、样式裸奔——都有对应的参数:
防出屏:位置用 position_preset(字幕 bottom-center、标题 top-center);字号单位是画布高的 1%(1080×1920 上 1 单位 ≈ 19px),常规字幕 7~8;一行约 7~8 个汉字,超长拆行或传 fixed_width(推荐 0.9)让剪映自动换行。没显式传 fixed_width 时,服务端估算最长行渲染宽度超过画布 94% 会自动收窄到 0.94 并在 warnings 里说明。
美化:按场景选 style_preset:
| 预设 | 特征 | 什么时候用 |
|---|---|---|
vlog_standard | 白字 + 黑描边 + 轻阴影 | 通用默认,日常 vlog / 字幕都稳 |
subtitle | 纯净字幕,不抢画面 | 只要可读性的常规字幕 |
cinematic | 细体 + 加字距 + 细描边 | 电影感、文艺、空镜 |
warning | 红底警示条 | 强提醒、警告信息 |
背景复杂时在预设之上叠加 border_width / border_color(描边)或 shadow_enabled / shadow_distance(阴影);重点词用 text_styles 换色 / 加粗,数组元素形如 (start 含、end 不含,按字符下标):
json
[
{"start": 0, "end": 4, "style": {"color": "#FFD400", "bold": true, "size": 9}}
]json
{
"draft_id": "dfd_cat_demo_001",
"text": "血展开双翅望向天边那片云海翻涌而来没有尽头",
"start": 0,
"end": 5,
"position_preset": "bottom-center",
"style_preset": "vlog_standard",
"fixed_width": 0.9
}返回格式
json
{
"success": true,
"output": {
"draft_id": "dfd_cat_demo_001",
"draft_url": "https://your-domain.example/api/draft/downloader?draft_id=dfd_cat_demo_001"
},
"error": ""
}