Starting a Mixed Stream Recording Job
Function
Creates and starts a mixed stream recording job.
Both audio-only recording and audio & video recording are supported.
-
Audio-only recording
If encode_template is set to audio_only, the three parties with the loudest voices are dynamically selected during audio stream mixing.
Leave layout_template, layout_panes, and other video-related parameters empty.
-
Audio & video recording (including desktop sharing)
If encode_template is not audio_only, layout_template and layout_panes must not be left empty.
The three parties with the loudest voices are dynamically selected during audio stream mixing.
The name of the stream mixing recording triggered by the API is in the format of {jobtype}_{jobid}_{roomid}, in which the value of jobtype is m, indicating that the stream mixing recording is triggered.
URI
POST /v2/apps/{app_id}/mix-stream-jobs
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
app_id |
Yes |
String |
Application ID. |
Request Parameters
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
Content-Type |
Yes |
String |
Content type. |
X-Auth-Token |
No |
String |
User token. This parameter is mandatory when token authentication is used. It can be obtained by calling the IAM API that is used for obtaining a user token. The value of X-Subject-Token in the response header is the user token. |
Authorization |
No |
String |
Authentication information. This parameter is mandatory when AK/SK-based authentication is used. |
X-Sdk-Date |
No |
String |
Time when the request is sent. This parameter is mandatory when AK/SK-based authentication is used. |
X-Project-Id |
No |
String |
Project ID. This parameter is mandatory when AK/SK-based authentication is used. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
mix_param |
Yes |
MixParam object |
Mixed stream parameters. |
publish_param |
No |
PublishParam object |
Forwarding parameters. |
record_param |
No |
RecordParam object |
Recording parameters. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
room_id |
Yes |
String |
Room ID. |
encode_template |
Yes |
String |
Name of the encoding template.
|
max_idle_time |
No |
Integer |
Maximum duration of an idle channel. The value ranges from 5 to 43200. The default value is 30. Unit: second If the channel is not connected for a period longer than the value of this parameter, the recording program automatically exits. If the start request is called again after the exit, a new recording task is generated. The co-host refers to a joiner or publisher. |
layout_template |
No |
String |
Video layout template ID. If mixed video is not required, this parameter does not need to be transferred.
|
default_user_background_image |
No |
String |
Default user background image address. The image is first uploaded to OBS in the format of s3://bucket/object. By default, proportional scaling and cropping is used to ensure full display. |
screen_background_image |
No |
String |
Background image address of the shared screen. The image must be first uploaded to OBS in the format of s3://bucket/object. In the one-large-multiple-small layout scenario, this parameter is used to specify the background image regardless of whether the large window displays the desktop of a non-specified user (desktop sharer) or the shared desktop of a specified user. |
background_image |
No |
String |
Address of the background image of the canvas. To use the background image function, you need to upload the image to OBS. The format of this parameter must be s3://bucket/object, where bucket and object indicate the bucket and path where the image is located. By default, proportional scaling and cropping is used to ensure full display. |
layout_panes |
No |
Array of MixLayoutPane objects |
List of videos that require mixed streams. If mixed video is not required, this parameter does not need to be transferred. You do not need to set this parameter for the nine_grids_view template. |
user_background_images |
No |
Array of MixUserBackgroundImage objects |
Background image of a user. The priority is higher than that of default_user_background_image. |
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
id |
No |
Integer |
Window ID, which starts from 1. |
user_id |
No |
String |
ID of the user who joins the room. |
video_type |
No |
String |
Video stream type, which can be camera stream or screen sharing stream.
The default value is CAMERASTREAM. |
x |
No |
Float |
X coordinate (normalized percentage), which is a relative value of the horizontal coordinate at the upper left corner of an image on the canvas. The value range is [0.0,1.0]. Left-to-right layout. 0.0 is at the leftmost and 1.0 is at the rightmost. The decimal value range is within float. Set this parameter in custom layout scenarios. |
y |
No |
Float |
Y coordinate (normalized percentage), which is a relative value of the vertical coordinate at the upper left corner of an image on the canvas. The value range is [0.0,1.0]. Top-to-bottom layout. 0.0 is at the top and 1.0 is at the bottom. The decimal value range is within float. Set this parameter in custom layout scenarios. |
width |
No |
Float |
Pane width (normalized percentage). The decimal value range is within float. Set this parameter in custom layout scenarios. |
height |
No |
Float |
Pane height (normalized percentage). The decimal value range is within float. Set this parameter in custom layout scenarios. |
zorder |
No |
Integer |
Stacking sequence. A maximum of 25 floors are supported, with 0 at the bottom. Set this parameter in custom layout scenarios. |
crop_mode |
No |
String |
Tailoring mode. Set this parameter in custom layout scenarios. Two modes are supported:
|
filling_policy |
No |
String |
Filling policy. This parameter is mandatory only in screen sharing templates (including screen_share_right and screen_share_left). The options are as follows:
|
Parameter |
Mandatory |
Type |
Description |
---|---|---|---|
user_id |
Yes |
String |
ID of the user for whom the background image needs to be configured. |
image_uri |
Yes |
String |
Background image address. The image is first uploaded to OBS in the format of s3://bucket/object. |
Response Parameters
Status code: 201
Parameter |
Type |
Description |
---|---|---|
X-request-Id |
String |
Request ID for task tracing. |
Parameter |
Type |
Description |
---|---|---|
job_id |
String |
Job ID, which can be used to modify, view, and stop a mixed stream recording job. |
stream_name |
String |
Stream name. |
app_id |
String |
Application ID. |
room_id |
String |
Room ID. |
mix_param |
MixParam object |
Mixed stream parameters. |
record_param |
RecordParam object |
Recording parameters. |
create_time |
String |
Time when a job is created, for example, 2006-01-02T15:04:05.075Z. The time zone is UTC. |
update_time |
String |
Time when the layout of a job is updated, for example, 2006-01-02T15:04:05.075Z. The time zone is UTC. |
state |
String |
Job status.
|
stop_reason |
String |
Job termination cause. |
description |
String |
Status description, which is the supplementary description of the state field and can be used for manual query. |
start_time |
String |
Time when a job starts, for example, 2006-01-02T15:04:05.075Z. The time zone is UTC. |
stop_time |
String |
Time when a job ends, for example, 2006-01-02T15:04:05.075Z. The time zone is UTC. |
Parameter |
Type |
Description |
---|---|---|
room_id |
String |
Room ID. |
encode_template |
String |
Name of the encoding template.
|
max_idle_time |
Integer |
Maximum duration of an idle channel. The value ranges from 5 to 43200. The default value is 30. Unit: second If the channel is not connected for a period longer than the value of this parameter, the recording program automatically exits. If the start request is called again after the exit, a new recording task is generated. The co-host refers to a joiner or publisher. |
layout_template |
String |
Video layout template ID. If mixed video is not required, this parameter does not need to be transferred.
|
default_user_background_image |
String |
Default user background image address. The image is first uploaded to OBS in the format of s3://bucket/object. By default, proportional scaling and cropping is used to ensure full display. |
screen_background_image |
String |
Background image address of the shared screen. The image must be first uploaded to OBS in the format of s3://bucket/object. In the one-large-multiple-small layout scenario, this parameter is used to specify the background image regardless of whether the large window displays the desktop of a non-specified user (desktop sharer) or the shared desktop of a specified user. |
background_image |
String |
Address of the background image of the canvas. To use the background image function, you need to upload the image to OBS. The format of this parameter must be s3://bucket/object, where bucket and object indicate the bucket and path where the image is located. By default, proportional scaling and cropping is used to ensure full display. |
layout_panes |
Array of MixLayoutPane objects |
List of videos that require mixed streams. If mixed video is not required, this parameter does not need to be transferred. You do not need to set this parameter for the nine_grids_view template. |
user_background_images |
Array of MixUserBackgroundImage objects |
Background image of a user. The priority is higher than that of default_user_background_image. |
Parameter |
Type |
Description |
---|---|---|
id |
Integer |
Window ID, which starts from 1. |
user_id |
String |
ID of the user who joins the room. |
video_type |
String |
Video stream type, which can be camera stream or screen sharing stream.
The default value is CAMERASTREAM. |
x |
Float |
X coordinate (normalized percentage), which is a relative value of the horizontal coordinate at the upper left corner of an image on the canvas. The value range is [0.0,1.0]. Left-to-right layout. 0.0 is at the leftmost and 1.0 is at the rightmost. The decimal value range is within float. Set this parameter in custom layout scenarios. |
y |
Float |
Y coordinate (normalized percentage), which is a relative value of the vertical coordinate at the upper left corner of an image on the canvas. The value range is [0.0,1.0]. Top-to-bottom layout. 0.0 is at the top and 1.0 is at the bottom. The decimal value range is within float. Set this parameter in custom layout scenarios. |
width |
Float |
Pane width (normalized percentage). The decimal value range is within float. Set this parameter in custom layout scenarios. |
height |
Float |
Pane height (normalized percentage). The decimal value range is within float. Set this parameter in custom layout scenarios. |
zorder |
Integer |
Stacking sequence. A maximum of 25 floors are supported, with 0 at the bottom. Set this parameter in custom layout scenarios. |
crop_mode |
String |
Tailoring mode. Set this parameter in custom layout scenarios. Two modes are supported:
|
filling_policy |
String |
Filling policy. This parameter is mandatory only in screen sharing templates (including screen_share_right and screen_share_left). The options are as follows:
|
Parameter |
Type |
Description |
---|---|---|
user_id |
String |
ID of the user for whom the background image needs to be configured. |
image_uri |
String |
Background image address. The image is first uploaded to OBS in the format of s3://bucket/object. |
Status code: 400
Parameter |
Type |
Description |
---|---|---|
X-request-Id |
String |
Request ID for task tracing. |
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Description. |
Status code: 404
Parameter |
Type |
Description |
---|---|---|
X-request-Id |
String |
Request ID for task tracing. |
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Description. |
Status code: 500
Parameter |
Type |
Description |
---|---|---|
X-request-Id |
String |
Request ID for task tracing. |
Parameter |
Type |
Description |
---|---|---|
error_code |
String |
Error code. |
error_msg |
String |
Description. |
Example Requests
-
Sample request for a nine-grid recording
POST https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/mix-stream-jobs { "mix_param" : { "room_id" : "room001", "encode_template" : "1280x720_15_2260", "max_idle_time" : 30, "layout_template" : "nine_grids_view" }, "record_param" : { "record_rule_id" : "5f5e172b9016ed5b0961a43" } }
-
Sample request for a shared screen recording: displaying the shared screen in the main window
POST https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/mix-stream-jobs { "mix_param" : { "room_id" : "room001", "encode_template" : "1280x720_15_2260", "max_idle_time" : 30, "layout_template" : "screen_share_right", "layout_panes" : [ { "id" : 1, "user_id" : "", "video_type" : "SCREENSTREAM", "filling_policy" : "SHARED_SCREEN" } ] }, "record_param" : { "record_rule_id" : "5f5e172b9016ed5b0961a43" } }
-
Sample request for a shared screen recording: displaying the camera in the main window
POST https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/mix-stream-jobs { "mix_param" : { "room_id" : "room001", "encode_template" : "1280x720_15_2260", "max_idle_time" : 30, "layout_template" : "screen_share_right", "layout_panes" : [ { "id" : 1, "user_id" : "user1", "video_type" : "CAMERASTREAM", "filling_policy" : "FIXED_USER" } ] }, "record_param" : { "record_rule_id" : "5f5e172b9016ed5b0961a43" } }
-
Sample request for a customized layout recording
POST https://rtc-api.myhuaweicloud.com/v2/apps/{app_id}/mix-stream-jobs { "mix_param" : { "room_id" : "room001", "encode_template" : "1280x720_15_2260", "max_idle_time" : 30, "layout_template" : "custom", "layout_panes" : [ { "id" : 1, "user_id" : "user1", "video_type" : "CAMERASTREAM", "x" : 0, "y" : 0, "width" : 0.666, "height" : 0.333, "crop_mode" : "KEEP_RATIO_CROP" }, { "id" : 2, "user_id" : "user2", "video_type" : "CAMERASTREAM", "x" : 0.666, "y" : 0, "width" : 0.333, "height" : 0.666, "crop_mode" : "KEEP_RATIO_CROP" } ] }, "record_param" : { "record_rule_id" : "5f5e172b9016ed5b0961a43" } }
Example Responses
Status code: 201
The job is created, and the job summary information is returned.
{ "job_id" : "607824b4fa163e19fe301cc817dda855", "stream_name" : "m_607824b4fa163e19fe301cc817dda855_gigu", "app_id" : "123456789abcdefghijklmno", "room_id" : "gigu", "mix_param" : { "room_id" : "gigu", "encode_template" : "1920x1080_30_4620", "max_idle_time" : 0, "layout_template" : "nine_grids_view" }, "record_param" : { "record_rule_id" : "5f5e172b9016ed5b0961a43" }, "create_time" : "2021-04-16T16:22:44Z", "update_time" : "2021-04-16T16:22:44Z", "state" : "INIT", "start_time" : "2021-04-16T16:22:44Z", "stop_time" : "0001-01-01T00:00:00Z" }
Status code: 400
Failed to create the mixed stream recording job because the request cannot be understood by the server or parameters are incorrect.
{ "error_code" : "RTC.00001003", "error_msg" : "InvalidParameterValue" }
Status code: 404
The application ID does not exist.
{ "error_code" : "RTC.00001003", "error_msg" : "InvalidParameterValue" }
Status code: 500
Failed to create the mixed stream recording job due to server error.
{ "error_code" : "RTC.00002xxx", "error_msg" : "InternalError" }
Status Codes
Status Code |
Description |
---|---|
201 |
The job is created, and the job summary information is returned. |
400 |
Failed to create the mixed stream recording job because the request cannot be understood by the server or parameters are incorrect. |
404 |
The application ID does not exist. |
500 |
Failed to create the mixed stream recording job due to server error. |
Error Codes
See Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot