调用 UpdateSubtitleTranscodePreset 接口,更新已添加的字幕配置。
根据使用场景,选择合适的功能。
使用场景 | 推荐功能 | 参数配置 | 说明 |
|---|---|---|---|
为直播提供基础字幕,方便静音或嘈杂环境下观看。 | 原文 ASR 字幕 |
| 通过语音识别,在视频画面叠加原文字幕。 说明 目前实时流式出字方式仅支持中文和英文字幕,整句出字方式则支持更多语言。 |
进行跨语言文字交流,触达全球观众。 | 字幕翻译 |
说明 推荐选择声影同传模式,翻译效果更佳。 | 通过语音识别,在视频画面叠加翻译字幕,但保留原声音频。 |
提供配音式翻译体验,如同观看译制片。 | 同传声音 |
| 提供同传声音,并替换原声。 |
追求沉浸式真人翻译体验,提升专业性。 | 同传声音 + 数字人口型 |
| 在同传声音的基础上,通过 AI 技术驱动说话人口型与翻译音频同步,效果以假乱真。 |
下表仅列出该接口特有的请求参数和部分公共参数。更多信息请见公共参数。
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| Action | String | 是 | UpdateSubtitleTranscodePreset | 接口名称。当前 API 的名称为 UpdateSubtitleTranscodePreset。 |
| Version | String | 是 | 2023-01-01 | 接口版本。当前 API 的版本为 2023-01-01。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| Vhost | String | 是 | push.example.com | 域名空间,您可以调用 ListVhostSubtitleTranscodePreset 接口,获取待更新字幕配置的 Vhost 取值。 |
| App | String | 是 | live | 应用名称,您可以调用 ListVhostSubtitleTranscodePreset 接口,获取待更新字幕配置的 App 取值。 |
| PresetName | String | 是 | OriginPreset | 字幕配置的名称,您可以调用 ListVhostSubtitleTranscodePreset 接口,获取待更新字幕配置的 PresetName 取值。 |
| Description | String | 否 | subtitleconfig0001 | 字幕配置的描述信息。 |
Suffixes | Array of String | 否 |
| 当前 注意
示例:
|
Delay | Integer | 否 |
| 播出延迟时长,以保证同传声音和字幕的翻译处理完成。取值范围为
说明
|
DisplayPreset | String | 否 |
| (不推荐使用)预设效果,用于快速配置。
|
MaxRowNumber | Integer | 否 |
| 每种语言字幕最多显示的行数。取值如下:
说明
|
Position | Object of Position | 否 |
| 字幕位置。 说明 如传入 |
| SIConfig | Object of SIConfig | 否 | - | 声影同传模式配置。 |
| SIOutput | Object of SIOutput | 否 | - | 输出相关配置。 |
SourceLanguage | Object of SourceLanguage | 是 |
| 原文字幕配置。 说明
|
TargetLanguage | Array of TargetLanguage | 否 |
| 译文字幕配置。 说明
|
HotWordList | Array of String | 否 |
| 热词列表。默认为空。 注意 仅对原文 ASR 字幕生效。有关原文 ASR 字幕的相关参数配置,详见使用说明。 |
GlossaryWordList | Array of String | 否 |
| 关键词列表。默认为空。 注意
|
ReplaceMap | JSON Map | 否 |
| 易错词列表。默认为空。
注意
|
| SubtitleTosConfig | Object of SubtitleTosConfig | 否 | - | TOS 配置,用于生成字幕 SRT 文件。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
Relative | String | 否 |
| 字幕在画面中的位置。取值如下:
|
MarginVertical | Float | 否 |
| 字幕的上下边距,即字幕距离画面顶部或底部的距离。取值为画面高度的百分比,取值范围为
|
| MarginHorizontal | Float | 否 | 0.2 | 字幕的左右边距,即字幕距离画面左右边缘的距离。取值为画面宽度的百分比,取值范围为 (0, 0.3]。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
Enable | Boolean | 否 |
| 是否开启声影同传模式。取值如下:
|
Pipe | String | 否 |
| 声影同传类型。取值如下:
|
SpeakerRecognition | Integer | 否 |
| 是否开启同传声音功能。取值如下:
说明 仅在 |
DigitalHumanMouthShape | Boolean | 否 |
| 是否开启数字人口型功能。取值如下:
说明
|
PipeExtra | String | 否 |
| 额外配置,为 JSON 格式的字符串,包含音量均衡、降噪、原声音量等信息。详见 CreateSpeechTask 接口的 说明 建议仅在开启同传声音时传入该参数。有关同传声音的相关参数配置,详见使用说明。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
Sei | Array of String | 否 |
| 如需将字幕内容写入直播流的 SEI 消息,将参数值设置为 说明
|
| Callback | Object of Callback | 否 | - | 回调配置。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
Display | Boolean | 是 |
| 是否展示原文字幕,取值如下:
|
Language | String | 否 |
| 原文字幕语言。
|
ShowPriority | Integer | 否 |
| 原文字幕的展示优先级。 |
MaxCharNumber | Integer | 否 |
| 原文每行字幕的最大字符数。建议取值 说明
|
Font | String | 是 |
| 原文字幕字体。
|
FontSize | Integer | 否 |
| 原文字幕字号。单位为 px。 说明 如传入 |
FontColor | String | 否 |
| 原文字幕的字体颜色。
说明
|
| Box | Object of Box | 否 | - | 原文字幕字体背景。 |
| Border | Object of Border | 否 | - | 原文字幕字体阴影。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
Language | String | 否 |
| 译文字幕语言。
|
ShowPriority | Integer | 否 |
| 译文字幕的展示优先级。 |
MaxCharNumber | Integer | 否 |
| 译文每行字幕的最大字符数。建议取值 说明
|
Hidden | Boolean | 否 |
| 是否隐藏译文字幕。取值如下:
|
Font | String | 是 |
| 译文字幕的字体。
|
FontSize | Integer | 否 |
| 译文字幕字号。单位为 px。 说明 如传入 |
FontColor | String | 否 |
| 译文字幕的字体颜色。
说明
|
| Box | Object of Box | 否 | - | 译文字幕字体背景。 |
| Border | Object of Border | 否 | - | 译文字幕字体阴影。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
Enable | Boolean | 否 |
| 是否生成字幕 SRT 文件。默认值为
|
| Bucket | String | 否 | bucketa | 存储字幕 SRT 文件的 TOS 桶名称。长度为 3-63 个字符,只能包含小写字母(a-z)、数字(0-9)和连字符(-),且必须以小写字母(a-z)或数字(0-9)开头和结尾。 |
Region | String | 否 |
| 存储字幕 SRT 文件的 TOS 桶区域。取值如下:
|
StorageDir | String | 否 |
| 存储字幕 SRT 文件的 TOS 桶文件夹名称。长度为 1-255 个字符,
|
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| Url | String | 是 | https://xxx | 用于接收回调消息的地址。该地址需支持 HTTP 或 HTTPS 协议,并可通过公网访问。长度为 1 到 100 个字符。有关声影同传回调消息,详见声影同传回调消息。 |
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| W | Float | 是 | 1.0 | 宽度。单位为 px。建议取值范围为 [1,10]。 |
Color | String | 是 |
| 颜色。
说明
|
| 参数 | 类型 | 是否必选 | 示例值 | 描述 |
|---|---|---|---|---|
| Width | Float | 是 | 2 | 宽度。单位为 px。建议取值范围为 [1,10]。 |
Color | String | 是 |
| 颜色。
说明
|
本接口无特有的返回参数。更多信息请见返回结构。
原文 ASR 字幕(整句出字)
POST https://live.volcengineapi.com?Action=UpdateSubtitleTranscodePreset&Version=2023-01-01 { "Vhost": "push.example.com", "App": "live", "PresetName": "PresetA", "Description": "原文 ASR 字幕(整句出字)", "Suffixes": [ "_hd", "_bd" ], "Delay": 15, "MaxRowNumber": 2, "Position": { "Relative": "bottom", "MarginVertical": 0.05, "MarginHorizontal": 0.2 }, "SIConfig": { "Enable": true, "Pipe": "mix" }, "SIOutput": { "Sei": [ "subtitle" ], "Callback": { "Url": "https://example.com/callback" } }, "SourceLanguage": { "Display": true, "Language": "zh", "Font": "siyuanheiti", "FontSize": 18, "FontColor": "0xFFFFFF@1", "ShowPriority": 2, "MaxCharNumber": 60, "Box": { "W": 1.0, "Color": "0x000000@0.5" }, "Border": { "Width": 2, "Color": "0x000000@0.5" } }, "HotWordList": [ "视频直播", "赛事直播", "智能家居" ], "ReplaceMap": { "视屏直播": "视频直播" } }
{ "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "UpdateSubtitleTranscodePreset", "Version": "2023-01-01", "Service": "live", "Region": "cn-north-1" } }
原文 ASR 字幕(实时流式出字)
POST https://live.volcengineapi.com?Action=UpdateSubtitleTranscodePreset&Version=2023-01-01 { "Vhost": "push.example.com", "App": "live", "PresetName": "PresetB", "Description": "原文 ASR 字幕(实时流式出字)", "Suffixes": [ "_hd", "_bd" ], "Delay": 2, "MaxRowNumber": 2, "Position": { "Relative": "bottom", "MarginVertical": 0.05, "MarginHorizontal": 0.2 }, "SIConfig": { "Enable": true, "Pipe": "realtime" }, "SIOutput": { "Callback": { "Url": "https://example.com/callback" } }, "SourceLanguage": { "Display": true, "Language": "zh", "Font": "siyuanheiti", "FontSize": 18, "FontColor": "0xFFFFFF@1", "ShowPriority": 2, "MaxCharNumber": 60, "Box": { "W": 1.0, "Color": "0x000000@0.5" }, "Border": { "Width": 2, "Color": "0x000000@0.5" } }, "HotWordList": [ "视频直播", "赛事直播", "智能家居" ], "ReplaceMap": { "视屏直播": "视频直播" } }
{ "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "UpdateSubtitleTranscodePreset", "Version": "2023-01-01", "Service": "live", "Region": "cn-north-1" } }
字幕翻译(声影同传模式)
POST https://live.volcengineapi.com?Action=UpdateSubtitleTranscodePreset&Version=2023-01-01 { "Vhost": "push.example.com", "App": "live", "PresetName": "PresetC", "Description": "字幕翻译(声影同传模式)", "Suffixes": [ "_hd", "_bd" ], "Delay": 8, "MaxRowNumber": 2, "Position": { "Relative": "bottom", "MarginVertical": 0.05, "MarginHorizontal": 0.2 }, "SIConfig": { "Enable": true, "Pipe": "mix" }, "SIOutput": { "Sei": [ "subtitle" ], "Callback": { "Url": "https://example.com/callback" } }, "SourceLanguage": { "Display": true, "Language": "en", "Font": "inter", "FontSize": 18, "FontColor": "0xFFFFFF@1", "ShowPriority": 2, "MaxCharNumber": 60, "Box": { "W": 1.0, "Color": "0x000000@0.5" }, "Border": { "Width": 2, "Color": "0x000000@0.5" } }, "TargetLanguage": [ { "Language": "zh", "Font": "siyuanheiti", "FontSize": 18, "FontColor": "0xFFFFFF@1", "Hidden": false, "ShowPriority": 1, "MaxCharNumber": 60, "Box": { "W": 1.0, "Color": "0x000000@0.5" }, "Border": { "Width": 2, "Color": "0x000000@0.5" } } ], "GlossaryWordList": [ "ByteDance:字节跳动", "MediaLive:视频直播" ], "ReplaceMap": { "蒂姆": "Tim", "提姆": "Tim" } }
{ "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "UpdateSubtitleTranscodePreset", "Version": "2023-01-01", "Service": "live", "Region": "cn-north-1" } }
同传声音 + 译文字幕
POST https://live.volcengineapi.com?Action=UpdateSubtitleTranscodePreset&Version=2023-01-01 { "Vhost": "push.example.com", "App": "live", "PresetName": "PresetD", "Description": "同传声音 + 译文字幕", "Suffixes": [ "_hd", "_bd" ], "Delay": 12, "MaxRowNumber": 2, "Position": { "Relative": "bottom", "MarginVertical": 0.05, "MarginHorizontal": 0.2 }, "SIConfig": { "Enable": true, "Pipe": "si", "SpeakerRecognition": 1, "DigitalHumanMouthShape": false, "PipeExtra": "{\"Separator\":{\"HandleType\":1},\"Amix\":{\"AudioEnhance\":false}}" }, "SIOutput": { "Sei": [ "subtitle" ], "Callback": { "Url": "https://example.com/callback" } }, "SourceLanguage": { "Display": false, "Language": "en", "Font": "inter", "FontSize": 18, "FontColor": "0xFFFFFF@1", "ShowPriority": 2, "MaxCharNumber": 60, "Box": { "W": 1.0, "Color": "0x000000@0.5" }, "Border": { "Width": 2, "Color": "0x000000@0.5" } }, "TargetLanguage": [ { "Language": "zh", "Font": "siyuanheiti", "FontSize": 18, "FontColor": "0xFFFFFF@1", "Hidden": false, "ShowPriority": 1, "MaxCharNumber": 60, "Box": { "W": 1.0, "Color": "0x000000@0.5" }, "Border": { "Width": 2, "Color": "0x000000@0.5" } } ], "GlossaryWordList": [ "ByteDance:字节跳动", "MediaLive:视频直播" ], "ReplaceMap": { "蒂姆": "Tim", "提姆": "Tim" } }
{ "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "UpdateSubtitleTranscodePreset", "Version": "2023-01-01", "Service": "live", "Region": "cn-north-1" } }
同传声音 + 数字人口型 + 译文字幕
POST https://live.volcengineapi.com?Action=UpdateSubtitleTranscodePreset&Version=2023-01-01 { "Vhost": "push.example.com", "App": "live", "PresetName": "PresetE", "Description": "同传声音 + 数字人口型 + 译文字幕", "Suffixes": [ "_hd", "_bd" ], "Delay": 20, "MaxRowNumber": 2, "Position": { "Relative": "bottom", "MarginVertical": 0.05, "MarginHorizontal": 0.2 }, "SIConfig": { "Enable": true, "Pipe": "si", "SpeakerRecognition": 1, "DigitalHumanMouthShape": true, "PipeExtra": "{\"Separator\":{\"HandleType\":1},\"Amix\":{\"AudioEnhance\":false}}" }, "SIOutput": { "Sei": [ "subtitle" ], "Callback": { "Url": "https://example.com/callback" } }, "SourceLanguage": { "Display": false, "Language": "en", "Font": "inter", "FontSize": 18, "FontColor": "0xFFFFFF@1", "ShowPriority": 2, "MaxCharNumber": 60, "Box": { "W": 1.0, "Color": "0x000000@0.5" }, "Border": { "Width": 2, "Color": "0x000000@0.5" } }, "TargetLanguage": [ { "Language": "zh", "Font": "siyuanheiti", "FontSize": 18, "FontColor": "0xFFFFFF@1", "Hidden": false, "ShowPriority": 1, "MaxCharNumber": 60, "Box": { "W": 1.0, "Color": "0x000000@0.5" }, "Border": { "Width": 2, "Color": "0x000000@0.5" } } ], "GlossaryWordList": [ "ByteDance:字节跳动", "MediaLive:视频直播" ], "ReplaceMap": { "蒂姆": "Tim", "提姆": "Tim" } }
{ "ResponseMetadata": { "RequestId": "20230604110420****100232280022D31", "Action": "UpdateSubtitleTranscodePreset", "Version": "2023-01-01", "Service": "live", "Region": "cn-north-1" } }
下表仅列出本接口特有的错误码。更多信息请参见公共错误码获取详细信息。
| 状态码 | 错误码 | 错误信息 | 说明 |
|---|---|---|---|
| 200 | CommonErr | - | 未分类错误。建议重试,如果仍返回该错误码,请联系技术支持。 |
| 400 | InvalidParam | - | 输入的参数无效或不符合要求,请参照请求参数说明进行检查。 |
| 400 | InvalidParam.BindError | Request parameter error, please check input data | 参数未通过校验,请检查参数类型是否正确。 |
| 403 | RequestForbidden | - | 请求被拒绝,当前账号下无请求的资源(域名空间、域名、应用、配置模版、证书)。 |
| 403 | RequestForbidden.AccountIDNotAllow | this AccountID does not have permission to access the corresponding resource, please check the request parameters | 请求被拒绝,当前账号下无请求的资源(域名空间、域名、应用、配置模版、证书)。 |
| 403 | RequestForbidden.BillingStatus | Billing status is not available for the AccountID, please activate the service or recharge. | 未开通视频直播服务或账号欠费,造成账单不可用,请检查服务开通情况和账号欠费情况。 |
| 404 | ResourceNotFound | - | 未找到资源(域名空间、域名、应用、配置模版、证书)。建议重试,如果仍返回该错误码,请联系技术支持。 |
| 500 | InternalError | an internal error occurred, please contact the administrator. | 出现内部错误,请联系技术支持。 |
| 500 | InternalError.Preset | an internal error related to preset occurred, please contact the administrator. | 出现与功能配置相关的内部错误,请联系技术支持。 |
| 502 | InternalServiceError | an internal error occurred, please contact the administrator. | 服务间出现错误,请联系技术支持。 |
| 502 | InternalServiceError.BadResponse | an internal error occurred, please contact the administrator. | 服务间出现错误,请联系技术支持。 |
| 504 | InternalServiceTimeout | Internal Service is timeout. please contact the administrator. | 内部服务超时,请联系技术支持。 |
视频直播提供了配套的开发工具集 SDK,支持多种编程语言,帮助您更方便的调用 API。