Set Video Attributes
Feature Overview
During video calls or live streaming, developers can set video attributes as needed to adjust the clarity, smoothness, and mirroring of the video to achieve a better user experience.
Usage Steps
Set Video Attributes
Before publishing stream, call the setVideoConfig interface to set video resolution, frame rate, and bitrate. You can use the preset combination values provided by ZEGO Express SDK, or set the corresponding fields of ZegoVideoConfig yourself.
The preset combination values for ZegoVideoConfigPreset are as follows:
| ZegoVideoConfigPreset | Capture Resolution (Width × Height) | Encode Resolution (Width × Height) | Frame Rate(fps) | Bitrate(kbps) |
|---|---|---|---|---|
| PRESET_180P | 320 × 180 | 320 × 180 | 15 | 300 |
| PRESET_270P | 480 × 270 | 480 × 270 | 15 | 400 |
| PRESET_360P | 640 × 360 | 640 × 360 | 15 | 600 |
| PRESET_540P | 960 × 540 | 960 × 540 | 15 | 1200 |
| PRESET_720P | 1280 × 720 | 1280 × 720 | 15 | 1500 |
| PRESET_1080P | 1920 × 1080 | 1920 × 1080 | 15 | 3000 |
Example code when using preset values:
ZegoExpressSDK::getEngine()->setVideoConfig(ZegoVideoConfig(ZEGO_VIDEO_CONFIG_PRESET_1080P));Example code when setting manually:
ZegoVideoConfig videoConfig;
videoConfig.captureHeight = 360;
videoConfig.captureWidth = 640;
videoConfig.encodeHeight = 360;
videoConfig.encodeWidth = 640;
videoConfig.fps = 15;
videoConfig.bitrate = 600;
ZegoExpressSDK::getEngine()->setVideoConfig(videoConfig);To avoid cropping or stretching of the rendered image, it is recommended to keep the aspect ratio of the capture resolution and encode resolution consistent.
Set Video Mirror Mode
Before publishing stream, call the setVideoMirrorMode interface to set whether to enable mirror mode for local preview video and published video. If enabled, the direction of object movement in the rendered image will be consistent with looking in a mirror; if disabled, it will be the opposite.
The preset combination values for ZegoVideoMirrorMode are as follows:
| ZegoVideoMirrorMode | Preview Screen | Published Screen(Remote Playing Screen) |
|---|---|---|
| ONLY_PREVIEW_MIRROR | Mirror | No Mirror |
| BOTH_MIRROR | Mirror | Mirror |
| NO_MIRROR | No Mirror | No Mirror |
| ONLY_PUBLISH_MIRROR | No Mirror | Mirror |
Example code when using preset values:
ZegoExpressSDK::getEngine()->setVideoMirrorMode(ZEGO_VIDEO_MIRROR_MODE_BOTH_MIRROR);