logo
Video Call
On this page

Publishing Stream Video Enhancement

2025-01-20

Introduction

ZEGO Express SDK provides various video pre-processing enhancement capabilities. Developers can adjust the visual effects on the publishing side according to business needs.

FeatureDescriptionAdvantagesEffect Display
Basic AI EffectsAdjust the degree of whitening, smoothing, sharpening, and rosy tones according to user and business needs, easily implement basic beauty effects, present good skin condition to users, and create unique and natural beauty effects.Covers high-frequency beauty capabilities.
Low Light EnhancementWhen the ambient light is dark and the brightness of the captured visuals does not meet business needs such as seeing faces clearly or performing face recognition, enhance the visual brightness.
  • Minimal performance overhead, covers all device models.
  • Supports automatic enhancement mode, automatically recognizes low-light environments.
Color EnhancementDue to camera characteristics, captured video may have insufficient saturation. Use color enhancement to enhance under-saturated colors while protecting skin tones, making visual colors more realistic and more in line with human visual perception.
  • Protects skin tones to avoid enhancement of skin tones.
  • Protects lip color, making lip color more natural when using beauty effects and wearing makeup.

Prerequisites

Before using the publishing stream video enhancement feature, please ensure:

Usage Steps

Initialize and login room

For the specific process of initialization and room login, please refer to "Create Engine" and "Login Room" in the implementing video call documentation.

Set publishing stream video enhancement effects

Please configure according to your needs by selecting the corresponding features.

Note

This feature is the basic beauty feature of ZEGO Effects SDK built into ZEGO Express SDK, which only includes four beauty effects: whitening, rosy tones, smoothing, and sharpening. For more advanced beauty features, please refer to Using Real-time Audio and Video with AI Effects.

Initialize basic beauty environment

If you need to use the basic beauty feature, you must call the startEffectsEnv interface to initialize the beauty environment before startPreview starts preview and startPublishingStream starts publishing stream.

// Create beauty environment
[[ZegoExpressEngine sharedInstance] startEffectsEnv];

After initializing the beauty environment, the SDK will use a fixed video frame data type for transmission internally. If you need to use custom video pre-processing while using the basic beauty feature, you can only configure the corresponding video frame data type:

iOS and macOS platforms: Only support CVPixelBuffer type data, that is, the bufferType of ZegoCustomVideoCaptureConfig is set to "ZegoVideoBufferTypeCVPixelBuffer".

Enable basic beauty effects

Warning

There is no order requirement for calling the enableEffectsBeauty interface and the setEffectsBeautyParam interface.

After initializing the beauty environment, you can call the enableEffectsBeauty interface before or after publishing stream to enable or disable beauty effects in real time.

// Toggle beauty effects
[[ZegoExpressEngine sharedInstance] enableEffectsBeauty:true];

Set basic beauty effect parameters

After initializing the beauty environment, you can call the setEffectsBeautyParam interface before or after publishing stream to set beauty effect parameters in real time.

  • smoothIntensity: Smoothing, performs smoothing while retaining facial details, such as retaining moles on the face.
  • whitenIntensity: Whitening, increases the overall brightness of the visuals to whiten the face.
  • rosyIntensity: Rosy tones, applies warm color processing to the overall visuals.
  • sharpenIntensity: Sharpening, applies sharpening processing to the overall visuals. When the visuals are slightly blurry, you can slightly increase sharpening to make contours clearer.

The value range of the above four parameters is 0 to 100. The larger the value, the higher the degree of beauty effects. The default value is 50.

// Create beauty parameter object
ZegoEffectsBeautyParam *beautyParam = [[ZegoEffectsBeautyParam alloc] init];

// Whitening, rosy tones, smoothing, sharpening
beautyParam.whitenIntensity = 50;
beautyParam.rosyIntensity = 50;
beautyParam.smoothIntensity = 50;
beautyParam.sharpenIntensity = 50;

// Set beauty parameters
[[ZegoExpressEngine sharedInstance] setEffectsBeautyParam:beautyParam];

(Optional) Destroy basic beauty environment

When the enableEffectsBeauty interface is called and set to "false", the beauty effects will be disabled, but the beauty module will still occupy resources and consume performance. If you want to completely release resources and save performance consumption, you need to call the stopEffectsEnv interface to destroy the beauty environment before preview and publishing stream.

Warning

When calling destroyEngine to destroy the engine, the SDK will automatically destroy the beauty environment.

// Destroy beauty environment
[[ZegoExpressEngine sharedInstance] stopEffectsEnv];

ZEGO provides two methods for low light enhancement:

MethodDescription
Enable adaptive frame rate for enhancementDynamically reduce the capture frame rate within the set frame rate range to extend the exposure time of each frame, achieving the effect of enhancing the brightness of captured visuals.
For example: The developer enables and sets the adaptive frame rate range to [10, 25]. When ambient light is sufficient, the capture frame rate remains 25 fps. When ambient light is low, the capture frame rate will be dynamically adjusted between [10, 25] to extend the exposure time of each frame and enhance the brightness of captured visuals.
Algorithm enhances captured visual brightness
  • Manual control: Developer controls the algorithm on/off independently.
  • Smart control: Automatically enables or disables the algorithm based on visual lighting conditions.

The two processing methods can be used independently or simultaneously, both compatible with beauty features.

Set low light enhancement mode

RTC SDK supports different algorithm low light enhancement modes. Call the setLowlightEnhancement interface to set the low light enhancement mode ZegoLowlightEnhancementMode:

Note
  • Before using the setLowlightEnhancement interface, ensure the SDK includes the video internal capture and video internal filter modules.
  • If the business uses external video stream capture, only specific data types CVPixelBuffer and PIXEL_BUFFER_TYPE_MEM are supported.
Enumeration ValueDescription
ZegoLowlightEnhancementModeOffDisable low light enhancement feature.
ZegoLowlightEnhancementModeOnEnable low light enhancement feature, controlled by developer.
ZegoLowlightEnhancementModeAutoSmart control of low light enhancement feature, automatically enables or disables the feature based on visual lighting conditions.

The low light enhancement type ZegoExpLowlightEnhancementType includes the following types:

Enumeration ValueDescription
ZegoExpLowlightEnhancementTypeNormalRegular low light enhancement.
ZegoExpLowlightEnhancementTypeAIAI low light enhancement. To use this feature, you need to contact ZEGOCLOUD Technical Support.

Taking enabling automatic low light enhancement feature as an example:

ZegoExpLowlightEnhancementParams *params = [[ZegoExpLowlightEnhancementParams alloc] init];
params.mode = ZegoLowlightEnhancementModeAuto;
params.type = ZegoExpLowlightEnhancementTypeAI;
[[ZegoExpressEngine sharedEngine] setLowlightEnhancementParams:params channel:ZegoPublishChannelMain];

(Optional) Enable camera adaptive frame rate

When ambient light is low and the camera capture frame rate is too high, the exposure time of each frame is insufficient, which may cause the captured video visuals to be dark. At this time, you can enable camera adaptive frame rate through enableCameraAdaptiveFPS. The SDK will match the capture frame rate range supported by the camera according to the set frame rate range. Within this range, it will dynamically adjust the camera capture frame rate according to ambient brightness to improve visual brightness when the set frame rate is too high.

//Set minimum frame rate
int minCamFPS = 15;
//Set maximum frame rate
int maxCamFPS = 35;
[[ZegoExpressEngine sharedEngine] enableCameraAdaptiveFPS:YES minFPS:minCamFPS maxFPS:maxCamFPS channel:ZegoPublishChannelMain];

Call the enableColorEnhancement interface, set the color enhancement parameters ZegoColorEnhancementParams (parameter attributes are shown in the table below), and other parameters to enable the color enhancement feature. Color enhancement feature is not enabled by default.

Color Enhancement ParameterDescription
intensity

Intensity of color enhancement, value range [0.0, 1.0], default is 0.0.

The larger the value, the greater the color enhancement effect.

skinToneProtectionLevel

Intensity of skin tone protection, value range [0.0, 1.0], default is 1.0.

The larger the value, the better the protection effect.

lipColorProtectionLevel

Intensity of lip color protection, value range [0.0, 1.0], default is 0.0.

The larger the value, the better the protection effect.

ZegoColorEnhancementParams *p = [[ZegoColorEnhancementParams alloc]init];
p.intensity = 1f;//Value range: [0,1], the larger the value, the greater the color enhancement intensity. Default value: 0.
p.skinToneProtectionLevel = 1f;//Value range: [0,1], the larger the value, the greater the skin tone protection. Default value: 1.
p.lipColorProtectionLevel = 1f;//Value range: [0,1], the larger the value, the greater the lip color protection. Default value: 0.
[[ZegoExpressEngine sharedEngine]enableColorEnhancement:YES params:p channel:ZegoPublishChannelMain];//Enable color enhancement

Start preview

After calling the startPreview interface to start preview, you can set different video enhancement features and experience the effects in real time.

ZegoCanvas *previewCanvas = [ZegoCanvas canvasWithView:preview];
[[ZegoExpressEngine sharedEngine] startPreview:previewCanvas];

Start publishing stream

When the preview effect meets expectations, you can call the startPublishingStream interface to start publishing stream. The publishing stream visual effect will be consistent with the preview effect.

[[ZegoExpressEngine sharedEngine] startPublishingStream:@"STREAM_ID"];

The above implements the video enhancement feature before publishing stream.

Previous

Video Large/Small Stream and Layered Encoding

Next

Stream Mixing