You can call the AddLiveAISubtitle operation to add a caption template.
Operation description
Usage notes
You can use this operation to add a live caption template. The template describes the caption content, layout, and other information.
After you add a caption template, you must also call the AddLiveAIProduceRules operation to add a caption rule. After you restart the stream ingest, the playback stream will contain captions.
The real-time caption feature is available only in the China (Beijing), China (Shanghai), Singapore, Indonesia (Jakarta), and Saudi Arabia (Riyadh) regions.
The real-time caption feature is in public preview. Each user can add a maximum of 300 caption templates. The feature is free of charge during the public preview. You will be charged for the feature after the public preview ends. The end date will be announced separately.
QPS limits
The queries per second (QPS) limit for this operation is 60 calls per second for each user. If you exceed the limit, your API calls will be throttled. This may affect your business. Plan your calls accordingly. For more information, see QPS limits.
Try it now
Test
RAM authorization
|
Action |
Access level |
Resource type |
Condition key |
Dependent action |
|
live:AddLiveAISubtitle |
create |
*All Resource
|
None | None |
Request parameters
|
Parameter |
Type |
Required |
Description |
Example |
| RegionId |
string |
No |
The region ID. |
cn-shanghai |
| SubtitleName |
string |
Yes |
The name of the caption template. The name can contain only digits, uppercase letters, lowercase letters, and hyphens (-). A hyphen cannot be the first character. |
sub01 |
| SrcLanguage |
string |
Yes |
The source language. Valid values:
|
zh-CN |
| DstLanguage |
string |
No |
The destination language for translation. Valid values:
|
zh-CN |
| FontColor |
string |
No |
The font color in RGBA format. |
0xFFFFFF |
| FontName |
string |
No |
The font. Valid values:
|
KaiTi |
| BgColor |
string |
No |
The background color of the captions in RGBA format. |
0xFF0000 |
| PositionNormalized |
array |
Yes |
The position of the captions. |
|
|
number |
No |
The position of the captions. The coordinates are based on the x-axis and y-axis, with the origin (0,0) at the lower-left corner of the screen. Note
The x and y coordinates must be normalized. The actual values are calculated by multiplying the normalized values by the video height. For example, if the video height is 720p and you set PositionNormalized to [0.1,0.5], the actual position of the captions is at x = 72 and y = 360. |
[0.32,0.27] |
|
| ShowSourceLan |
boolean |
No |
Specifies whether to display the source language. The default value is false. |
true |
| MaxLines |
integer |
No |
The number of lines to display. |
2 |
| WordPerLine |
integer |
Yes |
The number of characters to display per line. Valid values: 1 to 500. |
20 |
| FontSizeNormalized |
number |
Yes |
The font size. Valid values: 0 to 1. |
0.037 |
| BorderWidthNormalized |
number |
No |
The font weight. Valid values: 0 to 1. |
0.05 |
| BgWidthNormalized |
number |
No |
The size of the caption background. Valid values: 0 to 1. |
0.09 |
| CopyFrom |
string |
No |
The caption template from which to copy the settings. Set this parameter to the name of the source template. |
sub01 |
| Description |
string |
No |
The custom description of the caption template. The description can contain Chinese characters, English letters, digits, and special characters. The description can be up to 128 characters in length. |
live AI subtitle template |
| Width |
string |
No |
The width of the preview video, in pixels. |
1280 |
| Height |
string |
No |
The height of the preview video, in pixels. The preview video resolution (Width × Height) must be one of the following:
|
720 |
Response parameters
|
Parameter |
Type |
Description |
Example |
|
object |
|||
| RequestId |
string |
The request ID. |
5c6a2a0df228-4a64-af62-20e91b96**** |
| SubtitleId |
string |
The ID of the caption template. |
445409ec-7eaa-461d-8f29-4bec2eb9**** |
Examples
Success response
JSON format
{
"RequestId": "5c6a2a0df228-4a64-af62-20e91b96****",
"SubtitleId": "445409ec-7eaa-461d-8f29-4bec2eb9****"
}
Error codes
|
HTTP status code |
Error code |
Error message |
Description |
|---|---|---|---|
| 400 | InvalidParameter | %s. | Parameter error |
| 400 | MissingParameter | %s. | Missing parameter |
| 400 | InvalidParameter.Malformed | There are invalid parameters: %s. | There are invalid parameters: %s. |
See Error Codes for a complete list.
Release notes
See Release Notes for a complete list.