CreateMixStream

Updated at:

Creates a stream mixing task.

Operation description

Important Cloud-based stream mixing is a paid feature. It is currently in public preview and available for free. After the public preview ends, standard billing will apply. The specific billing start date will be announced separately.
Call this operation to create a stream mixing task. Currently, this operation supports preset layouts and custom layouts.

QPS limit

The QPS limit for a single user is 10 calls per second. If the limit is exceeded, API calls are throttled, which may affect your business. Make API calls at a reasonable rate.

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

live:CreateMixStream

create

*Domain

acs:live:*:{#accountId}:domain/{#DomainName}

None None

Request parameters

Parameter

Type

Required

Description

Example

RegionId

string

No

The region ID.

cn-shanghai

DomainName

string

Yes

The streaming domain of the streamer.

Important Currently, only domain names in the China (Shanghai) and China (Beijing) areas are supported.

example.com

LayoutId

string

Yes

The layout ID. Valid values:

  • MixStreamLayout-1-1

  • MixStreamLayout-2-1

  • MixStreamLayout-2-2

  • MixStreamLayout-2-3

  • MixStreamLayout-3-1

  • MixStreamLayout-3-2

  • MixStreamLayout-4-1

  • USERDEFINED: custom layout. Set the value to USERDEFINED if you do not use the preceding preset layouts.

Note

For more information, see Preset layouts for stream mixing.

MixStreamLayout-1-1

InputStreamList

string

Yes

The list of input streams for mixing. The value is a JSON array.

Refer to InputStreamConfig below.

[{"LayoutChildId":1,"ResourceType":"live","ResourceValue":"rtmp://example.net/live/f2139ec2b8d6a191068cd****ea9064d?auth_key=1600947017-0-0-0b5645fe35d21a65ab92b394bd4d****","LayoutConfig":{"FillMode":"fit","PositionRefer":"topLeft","FillPositionNormalized":[0,0],"FillSizeNormalized":[1,1]}}]

OutputConfig

string

Yes

The output configuration for stream mixing. The value is a JSON string.

Refer to OutputConfig below.

{"AppName":"liveApp****","StreamName":"9a78fb3f5c508be0122746f677a3****","MixStreamTemplate":"lp_hd_v","ExpireDuration":"86400"}

CallbackConfig

string

No

The callback URLs. The value is a JSON array. When an event is generated, the ApsaraVideo Live server sends an HTTP POST request to the URLs, and the specific content is delivered in the HTTP body.

{"CallbackUrl":"http://aliyundoc.com"}

InputStreamConfig

NameTypeDescription
ResourceTypeStringThe resource type.
live: streaming URL of a live stream.
url: streaming URL of a file stream.




ResourceValueStringThe resource URL.
If ResourceType is set to live, this parameter specifies streaming URL of a live stream. Live stream URLs support the RTMP, FLV, and HLS protocols, but do not support the ARTC protocol.
If ResourceType is set to url, this parameter specifies streaming URL of a file stream.




LayoutChildIdStringThe ID of the layout grid, which also indicates the overlay order of the mixed stream.
LayoutConfigLayoutConfig[]A JSON array that specifies layout information such as the position and fill mode.
If you use a preset layout, you do not need to specify this parameter.
If this parameter is specified, the preset layout information corresponding to LayoutChildId is ignored.




LayoutConfig

NameTypeRequiredDescription
FillSizeNormalizedJSON array of floatsYesThe normalized size of the layer element to be filled.
[w,h]: The values of w and h range from 0 to 1. The width and height are normalized.
Example: [0.2,0.3] indicates that the horizontal proportion is 20% and the vertical proportion is 30%.




FillPositionNormalizedArray of floatsYesThe normalized position of the fill area for the layer element.
[x,y]: The values of x and y range from 0 to 1.
Example: [0.1,0.1] indicates a horizontal offset of 10% and a vertical offset of 10% from the upper-left corner.




PositionReferStringNoThe reference coordinate for the position of the element.
We recommend that you set this parameter to topLeft, which indicates the upper-left corner.

FillModeStringNoThe fill mode of the element.
none: no fill.
fit: scales the element to fit the longest side to the boundary, which may add black bars to the shortest side.
fill: scales the element proportionally based on the maximum ratio of width to height, and then crops it to ensure full fill.
We recommend that you set this parameter to fit.










OutputConfig

NameTypeRequiredDescription
AppNameStringYesThe name of the output application. Special characters such as # and ? are not supported.
StreamNameStringYesThe name of the output stream. Special characters such as # and ? are not supported.
MixStreamTemplateStringYesThe ID of the output specification template for stream mixing. Pass only the template ID, such as lp_ld.
Valid values:
lp_ld (resolution: 640×360),
lp_sd (resolution: 854×480),
lp_hd (resolution: 1280×720),
lp_ud (resolution: 1920×1080),
lp_ld_v (resolution: 640×360),
lp_sd_v (resolution: 854×480),
lp_hd_v (resolution: 1280×720),
lp_ud_v (resolution: 1920×1080),
lp_ld_v_optm (resolution: 640×360),
lp_sd_v_optm (resolution: 854×480),
lp_hd_v_optm (resolution: 1280×720),
lp_ud_v_optm (resolution: 1920×1080).
_v indicates a portrait template, _optm indicates a low-latency template, and the value in parentheses indicates the resolution of the template.








































ExpireDurationLongNoThe expiration time of the task. Unit: seconds. Valid values: 1 to 31536000 (one year).
If you do not specify this parameter, the task is cleared after it expires in 7 days by default.

Response elements

Element

Type

Description

Example

object

MixStreamId

string

The ID of the stream mixing task. You can use this ID as a request parameter to query the list of stream mixing tasks or delete a stream mixing task.

5b2a046e-74d7-385e-253f-8a5b87e4****

RequestId

string

The request ID.

0D715397-2E66-4AE1-694h-C546628AD145

Examples

Success response

JSON format

{
  "MixStreamId": "5b2a046e-74d7-385e-253f-8a5b87e4****",
  "RequestId": "0D715397-2E66-4AE1-694h-C546628AD145"
}

Error codes

HTTP status code

Error code

Error message

Description

400 InvalidUserId.Malformed %s, please check userId. The userId passed in is invalid, please check.
400 InvalidParameter.Malformed There are invalid parameters: %s. There are invalid parameters: %s.
400 MissingParameter %s. Missing parameter
401 IllegalOperation %s, please check and try again later. Operation not allowed, please check and try again.
500 InternalError %s, please try again later. Internal error, please try again later.
403 MixStreamAlreadyExist %s, please check and try again later. The confluence task already exists, please check and try again.
403 MixStreamNotExist %s, please check and try again later. The confluous task does not exist. Please check and try again.
403 UserQuotaExceed Quota exceeded: %s. Quota exceeded: %s.
404 InvalidDomainName.NotFound %s, please check and try again later. Domain name does not exist, please check and try again.

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.