Common Video Configuration
Feature Overview
During video calls or live streaming, developers can specify video-related configurations for stream publishing and playing 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" (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.
Demo Source Code Download
Please refer to Download Demo Source Code to obtain the source code.
For related source code, please check the files in the assets/topics/publish_stream/ directory.
Prerequisites
Before setting video configurations, please ensure:
- You have created a project in the ZEGO Console and applied for a valid AppID and AppSign. For details, please refer to Console - Project Information.
- You have integrated the ZEGO Express SDK in your project and implemented basic audio/video streaming functions. For details, please refer to Quick Start - Integration and Quick Start - Implementation.
Usage Steps
1 Modify video configuration
Call the setVideoConfig interface to modify video configurations. Users can customize parameters or use preset values for settings.
You need to set the relevant video configurations before stream publishing (startPublishingStream) or preview (startPreview). After publishing streams, only encoding resolution and bitrate modifications are supported.
Custom parameter settings
Call the setVideoConfig interface to modify stream publishing video configurations. 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 apply the resolution, bitrate, and frame rate suitable for the selected scenario based on 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, please contact technical support. For details, please refer to Does ZEGO Express SDK support pulling 60-frame streams?
Taking setting the video capture resolution to 360p, encoding resolution to 360p, bitrate to 600 kbps, and frame rate to 15 fps as an example:
let videoConfig = new ZegoVideoConfig()
videoConfig.captureWidth = 640
videoConfig.captureHeight = 360
videoConfig.encodeWidth = 640
videoConfig.encodeHeight = 360
videoConfig.bitrate = 600
videoConfig.fps = 15
// Set video configuration
this.engine.setVideoConfig(videoConfig)Use preset value settings
In addition to custom parameter settings, 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 | 320 × 180 | 320 × 180 | 15 | 300 |
| Preset270P | 480 × 270 | 480 × 270 | 15 | 400 |
| Preset360P | 640 × 360 | 640 × 360 | 15 | 600 |
| Preset540P | 960 × 540 | 960 × 540 | 15 | 1200 |
| Preset720P | 1280 × 720 | 1280 × 720 | 15 | 1500 |
| Preset1080P | 1920 × 1080 | 1920 × 1080 | 15 | 3000 |
Example code for calling the setVideoConfig interface using preset values:
// Use presets for video settings
let videoConfig = new ZegoVideoConfig(ZegoVideoConfigPreset.Preset1080P)
this.engine.setVideoConfig(videoConfig)