LVB provides live stream mix feature, which can synchronously mix multiple streams of input sources into a new stream based on the configured stream mix layout for interactive live streaming. In addition, on-cloud stream mix has been connected to TencentCloud API 3.0. For more information, please see CreateCommonMixStream. This document uses examples to describe how to implement live stream mix in different scenarios.
Common templates include 10, 30, 40, 310, 390, 410, 510, and 610. When using them, you do not need to enter the position and length/width parameters of the input stream, and the original image will be scaled proportionally. You only need to pass in the template ID.
Figures of common layout templates:
Template 10 | Template 30 |
---|---|
![]() |
![]() |
Template 40 | Template 310 |
![]() |
![]() |
Template 390 | Template 410 |
![]() |
![]() |
Template 510 | Template 610 | ![]() |
![]() |
For more information, please see CreateCommonMixStream.
This example shows you how to use a preset stream mix template to mix streams.
https://live.tencentcloudapi.com/?Action=CreateCommonMixStream
&MixStreamSessionId=test_room
&MixStreamTemplateId=20
&OutputParams.OutputStreamName=test_stream1
&InputStreamList.0.InputStreamName=test_stream1
&InputStreamList.0.LayoutParams.ImageLayer=1
&InputStreamList.1.InputStreamName=test_stream2
&InputStreamList.1.LayoutParams.ImageLayer=2
&<Common request parameters>
{
"Response": {
"RequestId": "e8fa8015-0892-40d5-95c4-12a4bc06ed31"
}
}
This example shows you how to use a preset stream mix template to mix streams.
https://live.tencentcloudapi.com/?Action=CreateCommonMixStream
&MixStreamSessionId=test_room
&MixStreamTemplateId=390
&OutputParams.OutputStreamName=test_stream2
&InputStreamList.0.InputStreamName=test_stream1
&InputStreamList.0.LayoutParams.ImageLayer=1
&InputStreamList.0.LayoutParams.InputType=3
&InputStreamList.0.LayoutParams.ImageWidth=1920 (canvas width)
&InputStreamList.0.LayoutParams.ImageHeight=1080 (canvas height)
&InputStreamList.0.LayoutParams.Color=0x000000
&InputStreamList.1.InputStreamName=test_stream2
&InputStreamList.1.LayoutParams.ImageLayer=2
&InputStreamList.2.InputStreamName=test_stream3
&InputStreamList.2.LayoutParams.ImageLayer=3
&<Common request parameters>
{
"Response": {
"RequestId": "9d8d5837-2273-4936-8661-781aeab9bc9c"
}
}
Use the custom layout, where the position parameters LocationX
and LocationY
represent the absolute pixel distance between the top-left corner of the small image and that of the background image.
https://live.tencentcloudapi.com/?Action=CreateCommonMixStream
&MixStreamSessionId=test_room
&OutputParams.OutputStreamName=test_stream2
&InputStreamList.0.InputStreamName=test_stream1
&InputStreamList.0.LayoutParams.ImageLayer=1
&InputStreamList.0.LayoutParams.InputType=3
&InputStreamList.0.LayoutParams.ImageWidth = 1920
&InputStreamList.0.LayoutParams.ImageHeight= 1080
&InputStreamList.0.LayoutParams.Color=0x000000
&InputStreamList.1.InputStreamName=test_stream2
&InputStreamList.1.LayoutParams.ImageLayer=2
&InputStreamList.1.LayoutParams.ImageWidth = 640
&InputStreamList.1.LayoutParams.ImageHeight= 360
&InputStreamList.1.LayoutParams.LocationX= 50
&InputStreamList.1.LayoutParams.LocationY= 720
&InputStreamList.2.InputStreamName=test_stream3
&InputStreamList.2.LayoutParams.ImageLayer=3
&InputStreamList.2.LayoutParams.ImageWidth = 640
&InputStreamList.2.LayoutParams.ImageHeight= 360
&InputStreamList.2.LayoutParams.LocationX= 740
&InputStreamList.2.LayoutParams.LocationY= 720
&<Common request parameters>
{
"Response": {
"RequestId": "8c443359-ba07-4b81-add8-a6ff54f9bf54"
}
}
For more information, please see CancelCommonMixStream.
Cancel a stream mix based on SessionId.
https://live.tencentcloudapi.com/?Action=CancelCommonMixStream
&MixStreamSessionId=test_room
{
"Response": {
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}
}
Note:
- The stream mix you apply for cannot be cancelled within 5 seconds.
- After the cancellation, you can apply for a stream mix with the same SessionId at least 30 seconds later.
For on-cloud stream mix API 3.0, most common error codes have been transformed into the style of API 3.0 error code. However, some error codes remain unchanged, which will be provided in the format of err_code [ $code ],msg [ $message ]
in Message
and prompted as an InvalidParameter
error. The causes of specific codes are as detailed below:
Error Code | Reason | Troubleshooting |
---|---|---|
-1 | Incorrect input parsing parameter |
|
-2 | Incorrect input parameter | Check whether overflow of an image parameter occurred. |
-3 | The number of streams is incorrect | Check whether the number of input streams is within the range of [1,16]. |
-4 | Incorrect stream parameter |
|
-11 | Layer error |
|
-20 | The input parameter does not match the API |
|
-21 | The number of input streams for stream mix is incorrect | Check whether there are at least two input streams. |
-28 | Failed to get the background length/width |
|
-29 | Incorrect cropping parameter | Check whether the cropping position is out of the stream length/width range. |
-33 | Incorrect watermark image ID | Check whether the input image ID is set. |
-34 | Failed to get the URL of the watermark image | Check whether the image has been successfully uploaded and whether the URL has been generated. |
-111 | The `OutputStreamName` parameter does not match `OutputStreamType` |
|
-300 | The output stream ID has already been used | Check whether the current output stream belongs to another stream mix task. |
-505 | Failed to find the input stream in `upload` | Check whether stream mix is initiated 5 seconds after the push and whether the stream can be played back. |
-507 | Failed to query the stream length/width parameters |
|
-508 | Incorrect output stream ID | Check whether different output stream IDs are used by the same `MixStreamSessionId`. |
-10031 | Failed to trigger stream mix | We recommend you start stream mix 5 seconds after push starts. |
-30300 -31001 -31002 |
The `sessionid` does not exist when stream mix is canceled | Check whether the `MixStreamSessionId` exists. |
-31003 | The output stream ID does not match that in `session` | Check the output stream ID entered when stream mix is canceled. |
-31004 | The output stream bitrate is invalid | Check whether the output stream bitrate is within the range of [1,50000]. |
Other | For other errors, please contact customer service for assistance. | - |
Note:
For more questions about on-cloud stream mix, see On-cloud Stream Mix FAQs
Was this page helpful?