Basic Beauty
Feature Overview
ZEGO provides basic beauty functionality, presenting users with good skin condition and creating unique natural beauty effects. This functionality is commonly used in video calls, live streaming, and other scenarios.
Developers can enable the beauty switch, then adjust the degree of whitening, smoothing, sharpening, and rosy effects as needed to easily achieve basic beauty functionality.
Browsers that support beauty functionality are as follows:
| Browser | Compatible Version |
|---|---|
| Chrome | 65 and above |
| Firefox | 70 and above |
| Safari | 12 ~14 or 15.2 and above |
| Edge | 80 and above |
| Mobile Browser | Not supported |
| WeChat Embedded Webpage | Not supported |
Example Source Code Download
Please refer to Download Example Source Code to get the source code.
For related source code, please check files in the "src/Examples/Others/EffectsBeauty" directory.
Prerequisites
Before implementing beauty functionality, please ensure:
- A project has been created in ZEGOCLOUD Console, and valid AppID and Server address have been obtained. For details, please refer to Console - Project Information.
- ZEGO Express SDK has been integrated into the project, and basic audio/video streaming functionality has been implemented. For details, please refer to Quick Start - Integration and Quick Start - Implementation.
Usage Steps
- Call the createZegoStream interface to obtain a ZegoLocalStream instance object. After Capturing the stream, call the setEffectsBeauty interface through the ZegoExpressEngine instance to enable basic beauty functionality, and set beauty effects as needed through 4 parameters of ZegoEffectsBeautyParam.
- smoothIntensity: Smoothing, which smoothes while retaining facial details, such as moles on the face will be retained.
- whitenIntensity: Whitening, which brightens the overall picture to whiten the face.
- rosyIntensity: Rosy, which applies warm color processing to the overall picture.
- sharpenIntensity: Sharpening, which sharpens the overall picture. When the picture is slightly blurry, you can increase sharpening slightly to make contours clear.
The value range of all four parameters above is 0 ~ 100. The larger the value, the higher the degree of beauty. The default value is 50.
- If beauty is enabled before publishing, you need to wait for beauty to be enabled before calling the startPublishingStream interface to publish the stream.
- Beauty effects are bound to the corresponding MediaStream. When calling the useVideoDevice interface, it will not change the beauty effects of the MediaStream.
- Beauty processing consumes resources and performance. When beauty is not needed, please call
zg.setEffectsBeauty(localStream,false)to disable it in time. - When calling destroyStream to destroy the stream, SDK will also disable beauty effects. In other cases, SDK will not automatically disable beauty. You need to call
zg.setEffectsBeauty(localStream,false)to disable it yourself.
// Create stream, zg is the ZegoExpressEngine instance object.
const localStream = await zg.createZegoStream();
const enable = true;
// Enable beauty
// setEffectsBeauty is a Promise asynchronous method. Beauty is enabled only after the asynchronous function completes execution.
await zg.setEffectsBeauty(
localStream,
enable,
{
sharpenIntensity: 50,
whitenIntensity: 50,
rosyIntensity: 50,
smoothIntensity: 50
}
)
// Start publishing stream
// If beauty is enabled before publishing, you need to wait for beauty to be enabled before publishing the stream.
zg.startPublishingStream("stream1", localStream);
// Disable beauty
await zg.setEffectsBeauty(localStream, false);