Single Stream Transcoding
Overview
Single stream transcoding refers to converting a single original stream into transcoded streams with different encoding formats and resolutions in the cloud. In scenarios such as live streaming, viewers can choose streams with different resolutions to watch based on network quality, terminal devices, etc., to ensure playback smoothness.

Application Scenarios
- When developers provide video streams with multiple resolutions for users to watch on demand, they need to convert the original stream into transcoded streams with different definitions. At this time, the single stream transcoding function can be used.
- When converting original video streams into different video encoding formats, the single stream transcoding function can be used. For example, when some devices cannot decode H.265 due to performance issues, they need to be transcoded to H.264.
Prerequisites
The single stream transcoding function is currently in beta testing. For access, please contact ZEGO business personnel or ZEGO technical support.
Before using the single stream transcoding function, please ensure:
- You have created a project in the ZEGOCLOUD Console and applied for a valid AppID and Server address. For details, please refer to Console - Project Information.
- You have integrated ZEGO Express SDK in your project and implemented basic audio/video Stream Publishing and Playing functions. For details, please refer to Quick Start - Integration and Quick Start - Implementation.
- You need to use L3 Stream Playing, CDN forwarding Stream Playing (pull by streamID), or RTC Stream Playing, and not use stream mixing capabilities.
For scenarios that already use stream mixing capabilities, you can directly implement outputting multiple streams with different resolutions based on the stream mixing interface without triggering single stream transcoding.
Implementation Flow
The main flow of single stream transcoding is as follows:
- Add transcoding template.
- Create engine and log in to Room.
- Pull transcoded streams on demand, choose the Stream Playing method as L3 Stream Playing, CDN forwarding Stream Playing (pull by streamID), or RTC as needed, and pass in the transcoding template ID to trigger transcoding.
1 Add Transcoding Template
Please contact ZEGO technical support to add a transcoding template and obtain the corresponding transcoding template ID.
Currently supported transcoding parameters are: template ID, resolution, bitrate, frame rate, and video encoding format.
- Currently only video-related parameters are supported.
- One AppID supports adding up to 5 transcoding templates. To set more templates, please contact ZEGO technical support.
| Parameter | Description |
|---|---|
| Template ID | An integer greater than 100. The ID must be unique. Recommended to name based on output resolution, for example, the template ID for transcoding output resolution of 360P can be named 360. If the transcoding output resolution is less than 100P, you can name it yourself. |
| Resolution |
|
| Bitrate | The value must be greater than 0, in bps. |
| Frame rate | Supported range: [1, 20], in fps. If you need to output a larger frame rate, please contact ZEGO technical support for configuration. |
| Video encoding format | The following video encoding formats are supported:
|
2 Create Engine and Log in to Room
For specific flow, please refer to the Create Engine and Log in to Room sections of the "Implementing Video Call" document.
Before implementing single stream transcoding, there needs to be an existing stream in the Room.
3 Pull Transcoded Stream
Configure the ZegoWebPlayOption > codecTemplateID property, fill in the transcoding template ID obtained in Step 1 Add transcoding configuration template, and start Stream Playing.
CDN Stream Playing must also use the startPlayingStream method and cannot directly use URL to pull streams, otherwise single stream transcoding cannot be triggered.
const stream = await zg.startPlayingStream(streamID, {
codecTemplateID: 360, // Transcoding template ID
}Enable Downgrade Transcoding Function (Optional)
Configure the ZegoWebPlayOption > transcodeOnDecodeFail property to true to enable the downgrade transcoding function. After enabling, normally pull the original stream directly. The SDK will use single stream transcoding to other video encoding when video decoding fails, but Stream Playing detection of video encoding availability will increase retry time.
const stream = await zg.startPlayingStream(streamID, {
codecTemplateID: 360, // Transcoding template ID
// !mark
transcodeOnDecodeFail: true
}FAQ
- Stream mixing is generally used to merge multiple input streams into one, while supporting defining encoding format, resolution, and other parameters for multiple output streams. Stream mixing transcoding requires developers to additionally call client-side or server-side interfaces to trigger.
- Single stream transcoding is used to implement transcoding functionality for a single stream, and developers do not need to additionally call client-side or server-side interfaces to trigger. They only need to pass in the template parameter when Stream Playing to trigger.
