Common Video Configuration
Function Overview
This document applies to the following platforms: Android, iOS, Windows, Web, where 2 Modify Video View Mode and 3 Set Mirror Mode do not currently support the Web platform.
In video calls or live streaming, developers can specify publishing and playing video-related configurations as needed, such as video capture resolution, video encoding output resolution, video frame rate, bitrate, view mode, and mirror mode.
- Resolution:
- Video resolution: A parameter used to measure the amount of data in an image, usually expressed as ppi.
- Capture resolution: The screen resolution provided by capture devices such as cameras.
- Encoding resolution: The resolution of the screen after encoding processing.
- Bitrate: The number of bits transmitted per second, in bps (bit per second).
- Frame Rate: A measure of the number of video frames displayed per unit time, measured in "frames per second" (Frame Per Second, fps).
Setting appropriate video resolution, frame rate, and bitrate can provide users with a better experience in audio/video scenarios. Choosing the appropriate mirror mode and view mode allows developers to provide personalized video display modes.
Example Source Code Download
Please refer to Download Example Source Code to get the source code.
For related source code, please check the files in the "/lib/topics/CommonFunctions/common_video_config" directory.
Prerequisites
Before setting video configuration, please ensure:
- A project has been created in the ZEGOCLOUD Console and valid AppID and AppSign have been applied. For details, please refer to Console - Project Information.
- ZEGO Express SDK has been integrated in the project and basic audio/video publishing and playing functions have been implemented. For details, please refer to Quick Start - Integration and Quick Start - Implementation.
Usage Steps
1 Modify Video Configuration
By calling the setVideoConfig interface to modify video configuration, users can customize parameters or use preset values for setting.
Need to set relevant video configurations before publishing (startPublishingStream) or preview (startPreview). After publishing, only encoding resolution and bitrate modification are supported.
Custom Parameter Setting
Call the setVideoConfig interface to modify publishing video configuration. Through this interface, you can set video frame rate, bitrate, video capture resolution, and video encoding output resolution. If no special settings are made, the SDK will automatically set resolution, bitrate, and frame rate suitable for the selected scenario according to the selected scenario to obtain the best experience effect. For details, please refer to Scenario-based Audio/Video Configuration.
If the playing end needs to pull 60-frame streams, you need to contact technical support. For details, please refer to Does ZEGO Express SDK support pulling 60-frame streams?
Taking setting video capture resolution to 360p, encoding resolution to 360p, bitrate to 600 kbps, and frame rate to 15 fps as an example:
ZegoVideoConfig videoConfig = ZegoVideoConfig(360, 640, 360, 640, 15, 600, ZegoVideoCodecID.Default);
// Set video configuration
ZegoExpressEngine.instance.setVideoConfig(videoConfig);The width and height resolution of mobile devices is opposite to that of PC devices. For example, the resolution of 360p on mobile devices is 360 × 640, while the resolution of 360p on PC devices is 640 × 360.
Use Preset Value Setting
In addition to setting by yourself, you can also use the preset combination values provided by ZEGO Express SDK. The preset combination values of ZegoVideoConfigPreset are as follows:
| ZegoVideoConfigPreset | Capture Resolution (Width × Height) | Encoding Resolution (Width × Height) | Frame Rate(fps) | Bitrate(kbps) |
|---|---|---|---|---|
| Preset180P | 180 × 320 | 180 × 320 | 15 | 300 |
| Preset270P | 270 × 480 | 270 × 480 | 15 | 400 |
| Preset360P | 360 × 640 | 360 × 640 | 15 | 600 |
| Preset540P | 540 × 960 | 540 × 960 | 15 | 1200 |
| Preset720P | 720 × 1280 | 720 × 1280 | 15 | 1500 |
| Preset1080P | 1080 × 1920 | 1080 × 1920 | 15 | 3000 |
When calling the setVideoConfig interface to use preset values, the example code is as follows:
// Use preset for video setting
ZegoVideoConfig videoConfig = ZegoVideoConfig.preset(ZegoVideoConfigPreset.Preset1080P);
ZegoExpressEngine.instance.setVideoConfig(videoConfig);2 Modify Video View Mode
Before setting the video view mode, you need to stop preview or stop playing first, otherwise it will not take effect.
By modifying the "viewMode" parameter of the view object ZegoCanvas, you can modify the view mode of the video. Currently supports three video rendering fill modes:
| Enumeration | Description |
|---|---|
| AspectFit | Scale proportionally, may have black edges. |
| AspectFill | Scale proportionally to fill the entire View, some parts may be cropped. |
| ScaleToFill | Fill the entire View, the image may be stretched. |
The effects of the three video rendering fill modes are shown in the figure:

- The original video resolution shown in the figure above is 300 × 300 (width × height), and the view size is 300 × 500 (width × height).
- In the figure above, the height of the original video is equal to the width, and the height of the view is greater than the width. Therefore, in "AspectFit" rendering mode, black edges appear above and below the video. If the view width is greater than the height at this time, black edges will appear on the left and right sides of the video in "AspectFit" rendering mode.
Taking setting the preview view mode to "AspectFit" and starting preview as an example:
// previewID is the ID obtained through createCanvasView
// Set view mode to AspectFit
previewCanvas = new ZegoCanvas(previewID, viewMode: ZegoViewMode.AspectFit);
// Start preview
ZegoExpressEngine.instance.startPreview(previewCanvas);3 Set Mirror Mode
This function can be set before or after publishing, and takes effect immediately after setting.
Before publishing or after stopping publishing, you can call setVideoMirrorMode to set whether the local preview video and published video enable mirror mode. Currently supports the following four mirror modes:
| Enumeration | Description |
|---|---|
| NoMirror | Neither the local preview nor the video seen by the playing end is a mirrored image. |
| OnlyPreviewMirror | Only the local preview is a mirrored image, this mode is used by default. |
| OnlyPublishMirror | Only the video seen by the playing end is a mirrored image. |
| BothMirror | Both the local preview and the video seen by the playing end are mirrored images. |
The effects of the four mirror modes are as follows:

Taking setting the playing end mirror and local preview non-mirror as an example:
// Set mirror mode to only the video seen by the playing end is a mirrored image
ZegoExpressEngine.instance.setVideoMirrorMode(ZegoVideoMirrorMode.OnlyPublishMirror);