All Products
Search
Document Center

:AddRtsLiveStreamTranscode

Last Updated:Aug 09, 2024

Adds a custom Real-Time Streaming (RTS) transcoding configuration.

Usage notes

You can call this operation to add a custom RTS transcoding configuration. This operation supports four custom template types: h264, h264-nbhd, h264-origin, and audio.

QPS limit

You can call this operation up to 10 times per second per account. Requests that exceed this limit are dropped and you will experience service interruptions. We recommend that you take note of this limit when you call this operation. For more information, see QPS limits.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter

Type

Required

Example

Description

Action

String

Yes

AddRtsLiveStreamTranscode

The operation that you want to perform. Set the value to AddRtsLiveStreamTranscode.

Domain

String

Yes

example.com

The main streaming domain.

App

String

Yes

aliyun-test

The name of the application to which the live stream belongs. Value requirements:

  • The name can contain letters, digits, underscores (_), and hyphens (-).

  • We recommend that you specify a name that is more than three characters in length. The name must start with a letter or digit.

Template

String

Yes

ld

The name of the custom transcoding template. Value requirements:

  • The name can contain letters, digits, underscores (_), and hyphens (-).

  • We recommend that you specify a name that contain more than three characters in length. The name must start with a letter or digit.

Note

The name cannot be the same as that of a default transcoding template.

TemplateType

String

Yes

h264

The type of the custom transcoding template. Valid values:

  • h264: custom H.264 standard transcoding.

  • h264-nbhd: custom H.264 Narrowband HD™ transcoding.

  • h264-origin: H.264 original quality. If you use this type of template, the video quality settings of the source are retained by default.

  • audio: audio-only transcoding. If you use this type of template, images are removed from the video source and an audio-only stream is generated. In addition, you must also specify the AudioBitrate parameter.

Note

If you set this parameter to h264, h264-nbhd, or h264-origin, you must also specify the Height, Width, FPS, VideoBitrate, and DeleteBframes parameters.

Height

Integer

No

1280

The height of the output video. Unit: pixels.

Important

This parameter is required if you set TemplateType to h264, h264-nbhd, or h264-origin.

The value must comply with the following rules:

  • Height ≥ 100: The height of the video is greater than or equal to 100 pixels.

  • max(Height,Width) ≤ 2560: The width or height of the video, whichever is greater, cannot exceed 2,560 pixels.

  • min(Height,Width) ≤ 1440: The width or height of the video, whichever is smaller, cannot exceed 1,440 pixels.

For example, a resolution of 1560 × 1560 pixels is invalid.

Note

An original quality template retains the settings of the video source. Therefore, the resolution can be up to 4K.

Width

Integer

No

720

The width of the output video. Unit: pixels.

Important

This parameter is required if you set TemplateType to h264, h264-nbhd, or h264-origin.

The value must comply with the following rules:

  • Width ≥ 100: The width of the video is greater than or equal to 100 pixels.

  • max(Height,Width) ≤ 2560: The width or height of the video, whichever is greater, cannot exceed 2,560 pixels.

  • min(Height,Width) ≤ 1440: The width or height of the video, whichever is smaller, cannot exceed 1,440 pixels.

For example, a resolution of 1560 × 1560 pixels is invalid.

Note

An original quality template retains the settings of the video source. Therefore, the resolution can be up to 4K.

FPS

Integer

No

30

The frame rate of the output video. Unit: frames per second (FPS). Valid values: 1 to 60.

Important

This parameter is required if you set TemplateType to h264, h264-nbhd, or h264-origin.

VideoBitrate

Integer

No

2000

The bitrate of the output video. Unit: Kbit/s. Valid values: 1 to 6000.

Important

This parameter is required if you set TemplateType to h264, h264-nbhd, or h264-origin.

Note

The bitrate of the output video may not be the same as the value that you specify, but is as close to the value as possible, especially when the value is excessively large or small.

AudioBitrate

Integer

No

128

The bitrate of the output audio.

Unit: Kbit/s. Valid values: 1 to 1000.

Important

This parameter is required if you set TemplateType to audio.

Gop

String

No

2

The group of pictures (GOP) size of the output video. This parameter is used to specify the keyframe interval. Unit: seconds. Valid values: 1 to 3.

DeleteBframes

Boolean

No

false

Specifies whether to remove B-frames during transcoding. Valid values:

Important

This parameter is required if you set TemplateType to h264, h264-nbhd, or h264-origin.

  • true: removes B-frames.

  • false (default): retains B-frames.

Note

If you do not specify this parameter, the default value false is used.

Opus

Boolean

No

true

Specifies whether to transcode audio to the Opus format to be compatible with native WebRTC. Valid values:

  • true: transcodes audio to the Opus format.

  • false: does not transcode audio to the Opus format.

Note

If you do not specify this parameter, the default value false is used.

Profile

Integer

No

2

The video encoding profile. The profile determines how a video is encoded. In most cases, a greater value indicates better image quality and higher resource consumption. Valid values:

  • 1: baseline. This value is suitable for mobile devices.

  • 2: main. This value is suitable for standard-definition devices.

  • 3: high. This value is suitable for high-definition devices.

AudioProfile

String

No

aac_low

The audio encoding profile. Valid values:

  • aac_low

  • aac_he

  • aac_he_v2

  • aac_ld

AudioCodec

String

No

aac

The audio codec. Valid values:

  • aac

  • mp3

Note

If you want to use the Opus codec, you need only to set the Opus parameter to true.

AudioRate

Integer

No

44100

The audio sampling rate. Valid values: 22050 to 96000. The value 44100 is commonly used. Unit: Hz.

Note

If you set AudioProfile to aac_ld, the audio sampling rate cannot exceed 44,100 Hz.

AudioChannelNum

Integer

No

2

The number of sound channels. Valid values:

  • 1: mono

  • 2: stereo

Lazy

String

No

no

Specifies whether to enable triggered transcoding. Valid values:

  • yes: enables triggered transcoding.

  • no: disables triggered transcoding.

Response parameters

Parameter

Type

Example

Description

RequestId

String

16A96B9A-F203-4EC5-8E43-CB92E68F4CD8

The request ID.

Examples

Sample requests

https://live.aliyuncs.com/?Action=AddRtsLiveStreamTranscode
&Domain=example.com
&App=aliyun-test
&Template=ld
&TemplateType=h264
&Height=1280
&Width=720
&FPS=25
&VideoBitrate=2400
&DeleteBframes=false
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<AddLiveStreamTranscodeResponse>
    <RequestId>16A96B9A-F203-4EC5-8E43-CB92E68F4CD8</RequestId>
</AddLiveStreamTranscodeResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestId" : "16A96B9A-F203-4EC5-8E43-CB92E68F4CD8"
}

Error codes

For a list of error codes, see Service error codes.

Special error codes

Error code

Error message

HTTP status code

Description

InvalidDomain.NotFound

The domain provided does not exist in our records.

404

The domain name does not exist or does not belong to your account.

IllegalOperation

Illegal domain operate is not permitted.

403

The current operation is not supported because, for example, the specified domain name is not a domain name in ApsaraVideo Live.

InvalidParameters

Invalid parameters.

400

One or more parameters are invalid. For example, the height or bitrate is too large.

ConfigAlreadyExists

Config has already exist.

400

The configuration already exists.

InternalError

The request processing has failed due to some unknown error.

500

An unknown error occurred.