All Products
Search
Document Center

ApsaraVideo Live:StartLiveMPUTask (new)

Last Updated:Nov 17, 2023

Creates a mixed-stream relay task.

Usage notes

By default, you can create up to 200 single-stream relay tasks and up to 40 mixed-stream relay tasks for an application. To increase the quota, submit a ticket.

QPS limit

You can call this operation up to 500 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 StartLiveMPUTask

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

AppId String Yes yourAppId

The application ID. You can specify only one application ID. The ID can be up to 64 characters in length and can contain letters, digits, underscores (_), and hyphens (-).

ChannelId String Yes yourChannelId

The channel ID. You can specify only one channel ID. The ID can be up to 64 characters in length and can contain letters, digits, underscores (_), and hyphens (-).

TaskId String Yes yourTaskId

The task ID. You can specify only one task ID. The ID can be up to 55 characters in length and can contain letters, digits, underscores (_), and hyphens (-). The ID must be unique.

MixMode String Yes 0

The stream mixing mode. Valid values:

  • 0: the single-stream relay mode. In this mode, the service only relays the original single stream, but does not transcode mixed streams. You do not need to set parameters for mixed-stream transcoding.
  • 1 (default): the mixed-stream relay mode.
StreamURL String Yes rtmp://example.com/live/stream

The ingest URL. You can specify only one URL. For information about the generation rules of ingest URLs, see Ingest and streaming URLs.

Note
  • If the URL is under a domain name for which hotlink protection is enabled, you must include an access token in the ingest URL.
  • You cannot use the same ingest URL in different tasks.
  • You cannot use the same ingest URL within 10 seconds after a task is stopped.
Region String No CN-Shanghai

The region in which the streams are mixed. Valid values:

  • CN-Shanghai
  • AP-Singapore (default)
  • EMAA-Saudi
SingleSubParams Object No

The single-stream relay parameters. These parameters are required if you set MixMode to 0.

UserId String Yes yourSubUserId

The user ID. In the single-stream relay mode, you can relay only one stream in a request.

StreamType String No 0

The type of the stream that you want to relay. Valid values:

  • 0 (default): original stream
  • 1: audio stream
  • 2: video stream
SourceType String No camera

The type of the video source. This parameter is valid only when you set StreamType to 2. Valid values:

  • camera (default)
  • shareScreen
TranscodeParams Object No

The mixed-stream relay parameters. These parameters are required if you set MixMode to 1.

UserInfos Array No

The information about the user. If you leave this parameter empty, streams from all users are mixed.

UserId String Yes yourSubUserId

The user ID.

StreamType String No 0

The type of the stream that you want to relay. Valid values:

  • 0 (default): original stream
  • 1: audio stream
  • 2: video stream
SourceType String No camera

The type of the video source. This parameter is valid only when you set StreamType to 2. Valid values:

  • camera (default)
  • shareScreen
EncodeParams Object No

The encoding parameters for the output stream.

AudioOnly String No false

Specifies whether the output stream is an audio-only stream. Valid values:

  • true: The output stream is an audio-only stream. If you set this parameter to true, you need to configure only audio-related parameters.
  • false (default): The output stream is not an audio-only stream. If you set this parameter to false, you need to configure all parameters.
VideoWidth String No 1920

The width of the video. Valid values: [0,1920]. Unit: pixels.

VIdeoHeight String No 1080

The height of the video. Valid values: [0,1920]. Unit: pixels.

VideoFramerate String No 25

The frame rate of the video. Valid values: [1,60]. Unit: frames per second (FPS).

VideoBitrate String No 3500

The bitrate of the video. Valid values: [1,10000]. Unit: Kbit/s.

VideoGop String No 20

The group of pictures (GOP) size of the video. Valid values: [1,60].

AudioSampleRate String No 44100

The audio sampling rate. Valid values: 8000, 16000, 32000, 44100, and 48000. Unit: Hz.

AudioBitrate String No 128

The bitrate of the audio. Valid values: [8,500]. Unit: Kbit/s.

AudioChannels String No. 2

The number of sound channels. Valid values: 1 and 2.

Layout Object No

The video layout information.

Note You must specify this parameter for audio and video transcoding. Leave this parameter empty if the stream is an audio-only stream.
UserPanes Array No

The information about the pane.

UserInfo Object No

The information about the user whose stream is played in the pane. If you leave this parameter empty, the system automatically sets this parameter based on the order in which streamers join the channel. This parameter is valid only when you set StreamType to 0 or 2.

UserId String No yourSubUserId

The user ID.

SourceType String No camera

The type of the video source. This parameter is valid only when you set StreamType to 2. Valid values:

  • camera (default)
  • shareScreen
X String No 0.2456

The x-coordinate of the pane. The value is normalized.

Y String No 0.3789

The y-coordinate of the pane. The value is normalized.

Width String No 0.3564

The width of the pane. The value is normalized.

Height String No 0.2632

The height of the pane. The value is normalized.

ZOrder String No 0

The layer in which the pane resides. A value of 0 indicates the bottom layer. A value of 1 indicates the upper layer of the bottom layer. By analogy, you can obtain the specific layer indicated by a specific value.

BackgroundImageUrl String No yourImageUrl

The URL of the background image of the pane. This image is displayed if the user disables the camera or has not joined the channel.

RenderMode String No 1

The display mode of the pane. Valid values:

  • 0: scales the video proportionally to fit the view, with black bars displayed.
  • 1: crops the video to fit the view.
SeiParams Object No

The supplemental enhancement information (SEI) parameters.

LayoutVolume Object No

The layout and volume SEI. If you leave this parameter empty, the default layout and volume SEI is used.

FollowIdr String No 0

Specifies whether to include the SEI in an Instantaneous Decoder Refresh (IDR) frame. Valid values:

  • 0: does not include the SEI.
  • 1: includes the SEI.
Interval String No 1000

The interval at which the SEI is sent. Valid values: [1000,5000]. Unit: milliseconds.

PayloadType String No 5

The payload_type of the SEI message. Set the value to 5.

PassThrough Object No

Specifies whether to pass through the SEI.

PayloadContent String No yourPayloadContent

The payload content of the SEI.

FollowIdr String No 0

Specifies whether to include the SEI in an IDR frame. Valid values:

  • 0: does not include the SEI.
  • 1: includes the SEI.
Interval String No 1000

The interval at which the SEI is sent. Valid values: [1000,5000]. Unit: milliseconds.

PayloadType String No 5

The payload_type of the SEI message. Set the value to 5.

Layout and volume SEI

Parameter

Description

canvas

The information about the canvas. The following fields are included:

  • w: the width of the canvas. Unit: pixels.
  • h: the height of the canvas. Unit: pixels.
  • bgnd: the background color of the canvas, which is an RGB value in the format of a hexadecimal integer.

stream

The information about the video stream. The following fields are included:

  • uid: the user ID of the streamer.
  • paneid: the sequence number of the area in the pane. Valid values: [0,8].
  • zorder: the layer of the area. Valid values: [0,99].
  • x: the x-coordinate of the area in the canvas. The value is normalized.
  • y: the y-coordinate of the area in the canvas. The value is normalized.
  • w: the width of the area. The value is normalized.
  • h: the height of the area. The value is normalized.
  • type: the type of the video stream in the area. Valid values: 0 (camera) and 1 (screen sharing).
  • status: the status of the video stream in the area. Valid values: 0 (not pulled) and 1 (pulled).
  • muted: the mute status of the streamer. Valid values: 0 (not muted) and 1 (muted). For example, when two streamers (Streamer A and Streamer B) have a battle, if Streamer A mutes Streamer B, the muted field displayed for Streamer B is 1.
  • vol: the volume of the streamer. Valid values: [0,255]. Unit: dB.
  • vad: detects human voice. Valid values: [0,150]. 150 indicates that human voice is detected and a value other than 150 indicates the period of time during which the volume of human voice decreases to 0.

ts

The operating system timestamp when the SEI is generated. Unit: milliseconds.

ver

The version of the SEI. For example, the current version is 1.0.0.20220915.

udd

The custom scenario-based event that is sent by using the PassThrough parameter. The content of the event is specified by the PayloadContent parameter.

The following example shows a co-streaming scenario:

If a single streamer is streaming, the SEI message that viewers receive contains information about only one participant. If co-streaming or battle occurs, the SEI message that viewers receive contains information about multiple participants.

For example, when the streamer whose user ID is 111 is streaming, an SEI frame in the following format is sent to the viewer side:

{"canvas":{"w":1920,"h":1080,"bgnd":0},"stream":[{"uid":"111","paneid":-1,"zorder":0,"x":0,"y":0,"w":0,"h":0,"type":0,"status":1,"muted":0,"vol":0,"vad":0}],"ver":"1.0.0.20220915","ts":1697696105170}

When the streamer whose user ID is 111 is co-streaming with a co-streamer whose user ID is 222, an SEI frame in the following format is sent to the viewer side:

{"canvas":{"w":1920,"h":1080,"bgnd":0},"stream":[{"uid":"111","paneid":0,"zorder":1,"x":0,"y":0.25,"w":0.5,"h":0.5,"type":0,"status":1,"muted":0,"vol":1,"vad":119},{"uid":"222","paneid":1,"zorder":1,"x":0.5018382,"y":0.25,"w":0.5,"h":0.5,"type":0,"status":1,"muted":0,"vol":60,"vad":123}],"ver":"1.0.0.20220915","ts":1697696106230}

Viewers can determine whether a streaming layout changes based on the number of stream arrays. If only one stream array exists, a single streamer is streaming. If more than one stream array exists, co-streaming or battle occurs. The layout information of the participants indicates the position of each participant in the mixed stream.

Pass through the SEI

  • To configure custom SEI, call the StartLiveMPUTask operation to start a mixed-stream relay task and specify the PayloadContent parameter under the PassThrough parameter, or call the UpdateLiveMPUTask operation to update a mixed-stream relay task and specify the PayloadContent parameter under the PassThrough parameter.
  • Custom SEI can be sent periodically. You can use the Interval parameter under the PassThrough parameter to specify the interval in milliseconds.
  • Custom SEI can also be sent with keyframes by specifying the FollowIdr parameter under the PassThrough parameter.
    • You can configure settings to periodically send the custom SEI and send the custom SEI with keyframes at the same time. For example, you can set the Interval parameter to 1000 and the FollowIdr parameter to 1 to send the custom SEI every 1,000 milliseconds and include the custom SEI in keyframes.
    • If you do not specify the Interval parameter and the FollowIdr parameter, the custom SEI is sent only once when you call the operation.

For example, the streamer whose user ID is 111 ingests a stream and calls the UpdateLiveMPUTask operation to specify periodic SEI. In the operation, the Interval parameter is set to 1000, the FollowIdr parameter is set to 0, and the PayloadContent parameter is set to "hello world". In this case, the custom SEI is sent every 1,000 milliseconds. The SEI frame received on the viewer side is in the following format:

{"canvas":{"w":1920,"h":1080,"bgnd":0},"stream":[{"uid":"111","paneid":-1,"zorder":0,"x":0,"y":0,"w":0,"h":0,"type":0,"status":1,"muted":0,"vol":0,"vad":0}],"ver":"1.0.0.20220915","ts":1697696109876,"udd":"hello world"}

Response parameters

Parameter

Type

Example

Description

RequestId String 0F72851F-5DC1-1979-9B2C-450040316C3E

The request ID.

Examples

Sample requests

http(s)://live.aliyuncs.com?Action=StartLiveMPUTask
&AppId=yourAppId
&ChannelId=yourChannelId
&TaskId=yourTaskId
&MixMode=0
&StreamURL=rtmp://example.com/live/stream
&Region=CN-Shanghai
&SingleSubParams={"UserId":"yourSubUserId","StreamType":"0","SourceType":"camera"}
&TranscodeParams={"UserInfos":[{"UserId":"yourSubUserId","StreamType":"0","SourceType":"camera"}],"EncodeParams":{"AudioOnly":"false","VideoWidth":"1920","VIdeoHeight":"1080","VideoFramerate":"25","VideoBitrate":"3500","VideoGop":"20","AudioSampleRate":"44100","AudioBitrate":"128","AudioChannels":"2"},"Layout":{"UserPanes":[{"UserInfo":{"UserId":"yourSubUserId","SourceType":"camera"},"X":"0.2456","Y":"0.3789","Width":"0.3564","Height":"0.2632","ZOrder":"0","BackgroundImageUrl":"yourImageUrl","RenderMode":"1"}]}}
&SeiParams={"LayoutVolume":{"FollowIdr":"0","Interval":"1000","PayloadType":"5"},"PassThrough":{"PayloadContent":"yourPayloadContent","FollowIdr":"0","Interval":"1000","PayloadType":"5"}}
&<Common request parameters>

Sample success responses

XML format

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

<StartLiveMPUTaskResponse>
    <RequestId>0F72851F-5DC1-1979-9B2C-450040316C3E</RequestId>
</StartLiveMPUTaskResponse>

JSON format

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

{
  "RequestId" : "0F72851F-5DC1-1979-9B2C-450040316C3E"
}

Error codes

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