logo
Live Streaming
On this page

Publishing Stream Video Enhancement

2025-01-20

Feature Introduction

ZEGO Express SDK provides various video pre-processing enhancement capabilities. Developers can adjust the picture effects at the publishing end according to business needs.

FeatureFeature DescriptionFeature AdvantagesEffect Display
Basic AI EffectsAdjust the levels of whitening, smoothing, sharpening, and rosyness according to user and business needs, easily implementing basic AI effects, presenting good skin condition to users and creating unique and natural AI effect results.Covers high-frequency AI effect capabilities.
Low Light EnhancementWhen ambient light is dark and the brightness of the image captured by the camera does not meet the requirements for seeing faces clearly or cannot perform business needs such as face recognition, enhance the image brightness.
  • Lightweight, covers all device models.
  • Supports auto mode, intelligently enables or disables the algorithm based on the lighting conditions of the image.
  • Supports traditional algorithms and AI-level algorithms, intelligently selects algorithm types based on device performance.
Video Noise ReductionPoor camera capture results, low ambient light brightness, and other situations may cause obvious noise in the image. The video noise reduction feature can reduce image noise.
  • Determines whether to enable based on image noise conditions, avoiding unnecessary image damage.
  • Adjustable noise reduction intensity.
Color EnhancementDue to camera characteristics, the captured video may have insufficient saturation. Using the color enhancement feature, enhance undersaturated colors while protecting skin tones, making image colors more realistic and more in line with human visual perception.
  • Protects skin tone, avoiding enhancement of human skin tone.
  • Protects lip color, making lip color more natural when using AI effects and wearing makeup.

Prerequisites

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

Usage Steps

1 Initialize and login room

For the specific process of initializing and logging in to the room, please refer to "Create Engine" and "Login Room" in the implementation video call documentation.

2 Set publishing stream video enhancement effects

Please configure the corresponding features according to your needs.

Note

This feature is the basic AI effects feature of ZEGO Effects SDK built into the ZEGO Express SDK, which only includes four types of AI effects: whitening, rosyness, smoothing, and sharpening. If you need to use more advanced AI effects features, please refer to Integration of Real-time Audio and Video with AI Effects.

Initialize basic AI effects environment

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

// Create AI effects environment
[[ZegoExpressEngine sharedInstance] startEffectsEnv];

After initializing the AI effects environment, the SDK internally uses a fixed video frame data type for transmission. If you need to use custom video preprocessing while using the basic AI effects 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 takes the value "ZegoVideoBufferTypeCVPixelBuffer".

Enable basic AI effects

Note

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

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

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

Set basic AI effects parameters

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

  • smoothIntensity: Smoothing, perform smoothing while retaining facial details, such as retaining moles on the face.
  • whitenIntensity: Whitening, increase the overall brightness of the picture to whiten the face.
  • rosyIntensity: Rosyness, perform warm color processing on the overall picture.
  • sharpenIntensity: Sharpening, perform sharpening processing on the overall picture. When the picture is slightly blurry, you can slightly increase sharpening to make the outline clear.

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

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

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

// Set AI effects parameters
[[ZegoExpressEngine sharedInstance] setEffectsBeautyParam:beautyParam];

(Optional) Destroy basic AI effects environment

When calling the enableEffectsBeauty interface and setting it to "false", the AI effects will be turned off, but the AI effects 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 before preview and publishing stream to destroy the AI effects environment.

Note

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

// Destroy AI effects environment
[[ZegoExpressEngine sharedInstance] stopEffectsEnv];

ZEGO provides two ways of 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 the captured picture.
For example: The developer enables and sets the adaptive frame rate range to [10, 25]. When the ambient light is sufficient, the capture frame rate is still 25 frames. When the ambient light brightness is low, the capture frame rate will be dynamically adjusted between [10, 25] to extend the exposure time of each frame to enhance the brightness of the captured picture.
Algorithm enhances the brightness of the captured picture
  • Manual control: The developer controls the algorithm switch independently.
  • Smart control: Intelligently enable or disable the algorithm based on the lighting conditions of the picture.

The two processing methods can be used independently or simultaneously, and both are compatible with AI effects features.

Set low light enhancement switch

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 that the SDK includes the video internal capture and video internal filter modules.
  • If the business uses external capture video streams, only specific data types CVPixelBuffer and PIXEL_BUFFER_TYPE_MEM are supported.
EnumerationDescription
ZegoLowlightEnhancementModeOffTurn off low light enhancement feature.
ZegoLowlightEnhancementModeOnTurn on low light enhancement feature, controlled by the developer.
ZegoLowlightEnhancementModeAutoSmart control of low light enhancement feature, intelligently enable or disable the feature based on picture lighting conditions.

The low light enhancement type ZegoExpLowlightEnhancementType includes the following types:

EnumerationDescription
ZegoExpLowlightEnhancementTypeNormalConventional low light enhancement.
ZegoExpLowlightEnhancementTypeAIAI low light enhancement. If you need to use this feature, please contact ZEGO 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 the ambient light brightness 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 picture 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, dynamically adjust the camera capture frame rate according to the ambient brightness to improve the picture 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 setVideoDenoiseParams interface to set video noise reduction parameters ZegoVideoDenoiseParams, including: video noise reduction mode ZegoVideoDenoiseMode and video noise reduction strength ZegoVideoDenoiseStrength.

Warning
  • Before using the setVideoDenoiseParams interface, ensure that the SDK includes the video internal capture and video internal filter modules.
  • If the business uses external capture video streams, only specific data types CVPixelBuffer and PIXEL_BUFFER_TYPE_MEM are supported.
  • Video noise reduction feature is not enabled by default, that is, the default value of ZegoVideoDenoiseMode is ZegoVideoDenoiseMode.off.

Taking automatic noise reduction as an example:

ZegoVideoDenoiseParams *p = [[ZegoVideoDenoiseParams alloc] init];
p.mode = ZegoVideoDenoiseModeAuto;
p.strength = ZegoVideoDenoiseStrengthLight;
[[ZegoExpressEngine sharedEngine] setVideoDenoiseParams:p channel:ZegoPublishChannelMain];

Call the enableColorEnhancement interface, set color enhancement parameters ZegoColorEnhancementParams (parameter properties are as 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

The 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

The 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

The 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 degree. Default value: 1.
p.lipColorProtectionLevel = 1f;//Value range: [0,1], the larger the value, the greater the lip color protection degree. Default value: 0.
[[ZegoExpressEngine sharedEngine]enableColorEnhancement:YES params:p channel:ZegoPublishChannelMain];//Enable color enhancement

3 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];

4 Start publishing stream

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

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

The above completes the video enhancement feature before publishing stream.

Previous

Video Large/Small Stream and Layered Encoding

Next

Media Player