Function
This API is used to modify a transcoding template.
When modifying a transcoding template, the Live service directly overwrites the configuration in the request. Therefore, the request content must contain all template information for the domain and application, that is, all items in the quality_info array must be included.
URI
PUT /v1/{project_id}/template/transcodings
Table 1 Path Parameters | Parameter | Mandatory | Type | Description |
| project_id | Yes | String | Project ID. For details about how to obtain the project ID, see Obtaining a Project ID. |
Request Parameters
Table 3 Request body parameters | Parameter | Mandatory | Type | Description |
| domain | Yes | String | Definition Ingest domain name. Constraints N/A Range Length: 1 to 255 characters Default Value N/A |
| app_name | Yes | String | Definition Application name. Constraints N/A Range Length: 1 to 128 characters Default Value N/A |
| trans_type | No | String | Definition Transcoding triggering mode. Constraints N/A Range Default value: play |
| quality_info | Yes | Array of QualityInfo objects | Definition Video quality information. Constraints N/A |
Table 4 QualityInfo | Parameter | Mandatory | Type | Description |
| quality | Yes | String | Definition Transcoding specifications. Constraints If you set this parameter to userdefine, the templateName field cannot be empty. Range -
lud: ultra HD (default name) -
lhd: HD (default name) -
lsd: SD (default name) -
lld: smooth (default name) -
userdefine: custom video quality If you set this parameter to userdefine, the templateName field cannot be empty. Default Value N/A |
| templateName | No | String | Definition Custom template name. Constraints -
The name of a custom template can contain a maximum of 32 characters. -
To customize a template name, set quality to userdefine. -
The name of each custom template must be unique. -
A custom template cannot have the same quality settings as any another templates. -
If quality is not set to userdefine, do not set this parameter. Range Length: 0 to 32 characters Default Value N/A |
| PVC | No | String | Definition Indicates whether to use narrowband HD transcoding. Constraints Note: This field is no longer used. Use hdlb instead. Range -
off: disabled -
on: enabled Default value: off |
| hdlb | No | String | Definition Indicates whether to enable low-bitrate HD transcoding. It provides superior image quality compared to PVC. Constraints When the hdlb field is used to enable low-bitrate HD, the PVC field does not take effect. Range Default value: off |
| codec | No | String | Definition Video encoding format. Constraints N/A Range -
H264: H.264 is used. -
H265: H.265 is used. Default value: H264 |
| width | No | Integer | Definition Long side of the video. For landscape orientation, the width is the long side. For portrait orientation, the height is the long side. Unit: pixel. Constraints If both width and height are set to 0, the output resolution matches the input. If either width or height is set to 0, the output video is scaled proportionally based on the specified dimension. Range -
When codec is set to H264, the recommended width ranges from 32 to 3840, and the value must be a multiple of 2. -
When codec is set to H265, the recommended width ranges from 320 to 3840, and the value must be a multiple of 2. Default Value 0 |
| height | No | Integer | Definition Short side of the video. For landscape orientation, the width is the long side. For portrait orientation, the height is the short side. Unit: pixel. Constraints If both width and height are set to 0, the output resolution matches the input. If either width or height is set to 0, the output video is scaled proportionally based on the specified dimension. Range -
When codec is set to H264, the recommended height ranges from 32 to 2160, and the value must be a multiple of 2. -
When codec is set to H265, the recommended height ranges from 240 to 2160, and the value must be a multiple of 2. Default Value 0 |
| bitrate | Yes | Integer | Definition Bitrate of the transcoded video. Unit: kbit/s. Constraints N/A Range 40 to 30000 Default Value N/A |
| video_frame_rate | No | Integer | Definition Frame rate of the transcoded video. Unit: FPS Constraints N/A Range 0 to 60. The value 0 indicates that the frame rate remains unchanged. Default Value 0 |
| protocol | No | String | Definition Protocol supported by transcoded outputs. Constraints Currently, only RTMP is supported. Range Default value: RTMP |
| iFrameInterval | No | Integer | Definition Maximum I-frame interval, in frames. Constraints To set the I-frame interval using iFrameInterval, set gop to 0. Range 0 to 500 Default Value 50 |
| gop | No | Integer | Definition I-frame interval, in seconds. Constraints If gop is not 0, the I-frame interval is set based on gop, and the iFrameInterval field does not take effect. Default Value 2 Value range: 0~10 |
| bitrate_adaptive | No | String | Definition Adaptive bitrate parameter. Constraints N/A Range -
off: Adaptive bitrate is disabled. The output will follow the configured target bitrate. -
minimum: The output bitrate is the smaller one between the target bitrate and the source bitrate (ensuring no bitrate up-conversion). -
adaptive: The output bitrate dynamically adapts to the source bitrate. Default Value off |
| i_frame_policy | No | String | Definition Policy for outputting I-frames during encoding. Constraints For multi-bitrate transcoding, you are advised to use strictSync so outputs at different bitrates share the same I-frame positions. Range -
auto: I-frames are output based on the configured GOP duration. -
strictSync: Output I-frames are strictly aligned with the source. If a source frame is an I-frame, it is encoded as an I-frame. If the source frame is not an I-frame, it is encoded as a non-I-frame. When this option is used, the GOP duration setting is invalid. Default Value auto |
Response Parameters
Status code: 204
Transcoding template modified successfully.
Status code: 400
Table 5 Response body parameters | Parameter | Type | Description |
| error_code | String | Error code. |
| error_msg | String | Error description. |
Example Requests
Modifies a transcoding template. Set the application name to live, transcoding quality to SD, transcoding format to H.264, width to 1920 pixels, and height to 1080 pixels.
PUT https://{endpoint}/v1/{project_id}/template/transcodings
{
"domain" : "play.example.com",
"app_name" : "live",
"quality_info" : [ {
"quality" : "lsd",
"hdlb" : "off",
"codec" : "H264",
"width" : 1920,
"height" : 1080,
"bitrate" : 4500,
"video_frame_rate" : 20,
"gop" : 4
}, {
"quality" : "userdefine",
"templateName" : "yourTemplateName",
"hdlb" : "off",
"codec" : "H264",
"width" : 1920,
"height" : 1080,
"bitrate" : 4500,
"video_frame_rate" : 20,
"gop" : 4
} ]
} Example Responses
Status code: 400
Failed to modify the transcoding template.
{
"error_code" : "LIVE.100011001",
"error_msg" : "Request Illegal"
} Status Codes
| Status Code | Description |
| 204 | Transcoding template modified successfully. |
| 400 | Failed to modify the transcoding template. |