logo
Video Call
On this page

Single Stream Transcoding

2024-01-02

Feature Introduction

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

Application Scenarios

  • When developers provide video streams of multiple resolutions for users to watch on demand, they need to convert the original stream into transcoded streams of different clarity. At this time, the single stream transcoding feature can be used.
  • When converting original video streams to different video encoding formats, the single stream transcoding feature 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

Warning

The single stream transcoding feature is currently in beta testing. If you need to access it, please contact ZEGO sales or ZEGO technical support.

Before using the single stream transcoding feature, please ensure:

Note

For scenarios that have already used the stream mixing feature, 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:

  1. Add transcoding template.
  2. Create engine and log in to room.
  3. Pull transcoded stream as needed, choose the playing stream method as L3 Playing Stream, Forward-to-CDN Playing Stream (playing 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.

Warning
  • Currently only video-related parameters are supported for configuration.
  • One AppID supports adding up to 5 transcoding templates. If you need to set more templates, please contact ZEGO technical support.
ParameterDescription
Template IDAn integer greater than 100, the ID must be unique.
It is recommended to name it according to the 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
  • Supported width range: [0, 3000], the value must be a multiple of 2.
  • Supported height range: [0, 3000], the value must be a multiple of 2.
BitrateThe value must be greater than 0, in bps.
Frame RateSupported 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:

  • H.264
  • H.265
  • Keep the video encoding format of the original stream.

2 Create engine and log in to room

For the specific flow, please refer to the Create Engine and Login Room sections of the "Implementing Video Call" document.

Warning

Before implementing single stream transcoding, there needs to be an existing stream in the room.

3 Play transcoded stream

Configure the codecTemplateID property of ZegoPlayerConfig, fill in the transcoding template ID obtained in Step 1 Add Transcoding Configuration Template, and start playing stream.

ZegoPlayerConfig *playerConfig = [[ZegoPlayerConfig alloc] init];
// Configure according to actual business conditions
playerConfig.resourceMode = ZegoStreamResourceModeOnlyL3;
// 101 is the configured template ID, refer to Step 1 Add Transcoding Configuration Template
playerConfig.codecTemplateID = 101;

ZegoCanvas *playCanvas = [ZegoCanvas canvasWithView:self.playView];

// engine is the ZegoExpressEngine object created when creating the engine
[[ZegoExpressEngine sharedEngine] startPlayingStream:@"streamID" canvas:playCanvas config:playerConfig];

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 or server interfaces to trigger.
  • Single stream transcoding is used to implement the transcoding function for a single stream, without developers needing to additionally call client or server interfaces to trigger. It only needs to be triggered by carrying template parameters when playing stream.

Previous

Ultra Low Latency Live Streaming

Next

OBS Streaming with WHIP Protocol

On this page

Back to top