tencent cloud

Cloud Streaming Services

Release Notes and Announcements
Announcements
User Guide
Product Introduction
Overview
CSS Products
Concepts
Features
Use Cases
Strengths
Use Limits
Purchase Guide
Billing Overview
Basic Service Fee
Value-Added Service Fee
Prepaid plan
Purchase Process
Changing Billing Modes
Refund Policy
Viewing Bills
Renewal
Processing for Overdue Payments
Billing FAQs
Live Video Broadcasting (LVB)
Overview
Use Cases
Getting Started
SDK Integration
Live Event Broadcasting (LEB)
Overview
LEB Versus LVB
Use Cases
Getting Started
SDK Integration
Live Video Caster
Overview
Application Scenarios
Feature Area Introduction
Managing Live Video Caster
General Cloud Director
Configuring Program Lists and Automated Broadcasting
Console Guide
Console Overview
Overview
Domain Management
Stream Management
Package Management
AI Features
Feature Configuration
Relay
Billing Usage Statistics
Monitoring
Toolkit
OOTB live
CAM-Based Access Control
Feature Guide
Push and Playback
Features
Practices in Typical Scenarios
Cloud Native Recording
Live Streaming Security
Global CSS Service
Callback Notifications
User Guides for Common Third-Party Tools
SDK Guide
0. SDK Integration Guide
1. Stream Push
2. Playback
3. Advanced Features
API Documentation
History
Introduction
API Category
Making API Requests
Live Pad APIs
Live Stream Mix APIs
Time Shifting APIs
Monitoring Data Query APIs
Billing Data Query APIs
Live Transcoding APIs
Delayed Playback Management APIs
Domain Name Management APIs
Watermark Management APIs
Certificate Management APIs
Stream Pulling APIs
Recording Management APIs
Live Callback APIs
Screencapturing and Porn Detection APIs
Authentication Management APIs
Live Stream Management APIs
Data Types
Error Codes
Ops Guide
Video Stuttering
Troubleshooting Push Failure
Troubleshooting Playback Failure
CLS Assists in Live Stream Troubleshooting
Troubleshooting High Latency
Troubleshooting Poor Quality of Pulled Video
Authorizing CSS to Store Screenshots in a COS Bucket
Troubleshooting
Live Stream Mixing Error `InvalidParameter.OtherError`
About Pushing
Generating Push URLs
PC Push
Playing Method
Web Player
Live Streaming Quiz
FAQs
Service Region
Live Streaming Basics
Push and Playback
CSS Billing
Global CSS Service
Live Recording
On-Cloud Stream Mix
Domain Configuration
Related to Live Video Caster
Compatibility with Apple ATS
Difference Between Stream Interruption and Stream Suspension
SLA
CSS Service Level Agreement
CSS Policy
Privacy Policy
Data Processing And Security Agreement
Glossary

Stream Mix

PDF
Focus Mode
Font Size
Last updated: 2025-11-14 15:41:20
CSS 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, the stream mix feature 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.

Notes

Using stream mix will incur transcoding fees. For details, please see Live Transcoding (Watermarking, Stream Mixing).
To use the mixing and cropping feature, the value of the cropping parameter cannot exceed the value of input stream parameter.

Supported Features

Up to 16 concurrent streams can be mixed.
Up to 5 types of input sources (audio and video, pure audio, pure video, image, and canvas) can be mixed.
Mixed streams can be output as a new stream.
Cropping and watermarking are supported.
Template configuration is supported.
Recording based on stream mix is supported.
Stream mix types and positions can be switched in real time.
Stream mix can be started/canceled seamlessly.

Common Layout Templates

Common templates include 10, 30, 40, 310,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 auto-scaled. You only need to pass in the template ID.
Figures of common layout templates:
Template 10 Preview Image
Template 30 Preview Image






Template 40 Preview Image
Template 310 Preview Image






Template 410 Preview Image
Template 510 Preview Image






Template 610 Preview Image




Creating Stream Mix Session

Parameters

For more information, please see CreateCommonMixStream.

Scenario 1. Applying for stream mix - using template 20

This example shows you how to use a preset stream mix template to mix streams.

Sample input code

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>

Sample output code

{
"Response": {
"RequestId": "e8fa8015-0892-40d5-95c4-12a4bc06ed31"
}
}

Stream mix effect for mic connect


img



Scenario 2. Applying for stream mix - using template 390

This example shows you how to use a preset stream mix template to mix streams.

Sample input code

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>

Sample output code

{
"Response": {
"RequestId": "9d8d5837-2273-4936-8661-781aeab9bc9c"
}
}

Stream mix effect for host competition


img



Scenario 3. Custom stream mix

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.




Sample input code

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>

Sample output code

{
"Response": {
"RequestId": "8c443359-ba07-4b81-add8-a6ff54f9bf54"
}
}

Custom stream mix effect





Canceling Stream Mix

Parameters

For more information, please see CancelCommonMixStream.

Examples

This example shows you how to cancel a stream mix by session ID.

Sample input code

https://live.tencentcloudapi.com/?Action=CancelCommonMixStream
&MixStreamSessionId=test_room

Sample output code

{
"Response": {
"RequestId": "3c140219-cfe9-470e-b241-907877d6fb03"
}
}
Note:
After applying for canceling stream mix, wait at least for 5s before canceling it.
After canceling the stream mix, wait at least for half a minute before you can apply for stream mix using the same session ID.

Error Codes

For 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
An error occurred while parsing the input parameters
Check whether the JSON format of the request body is correct.
Check whether `InputStreamList` is empty.
-2
Incorrect input parameter
Check whether the image parameter is too large.
-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
Check whether the length/width of the input/output stream are within the range of (0,3000).
Check whether the number of input streams is within the range of (0,16].
Check whether the input stream carries `LayoutParams`.
Check whether `InputType` is supported (valid values: 0, 2, 3, 4, 5).
Check whether the stream ID length is within the range of (1,80).
-11
Layer error
Check whether the number of layers is the same as the number of input streams.
Check whether the layer ID is duplicate.
Check whether the layer ID is within the range of (0,16].
-20
The input parameter does not match the API
Check whether the number of input streams matches the template ID.
Check whether the color parameter is correct.
-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
Check whether the canvas length and width are set when setting the canvas.
Check whether the background stream exists (stream mix needs to start 5 seconds after push starts).
-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`
If `OutputStreamType` is set to `0`, `OutputStreamName` should be in `InputStreamList`.
If `OutputStreamType` is set to `1`, `OutputStreamName` should not be in `InputStreamList`.
-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
Check whether the canvas length and width are set.
Check whether the push succeeds. We recommend you start stream mix 5 seconds after push starts.
-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].
Others
For other errors, please contact customer service for assistance.
-

FAQs

Note:
For more FAQs about stream mix, please see On-cloud Stream Mix.

Help and Support

Was this page helpful?

Help us improve! Rate your documentation experience in 5 mins.

Feedback