Feature Description
TRTC can use the RTCBeautyPlugin to help developers easily implement basic beauty filter features. Users can adjust beauty filter parameters in the plugin to achieve natural beauty filter effects. Click here to experience the effect.
Browser | Version |
---|---|
Chrome | 65+ |
Firefox | 70+ |
Safari | 12+ |
Edge | 80+ |
Mobile browser | Not supported |
WeChat built-in browser | Not supported |
Note
- Only the listed platforms are supported.
- The calculation and rendering of beauty and portrait segmentation are performance-consuming, so if the user's device performance is not enough to support the calculation, it is recommended not to enable the beauty and portrait segmentation functions.
- Performance data for a device with a 2.6 GHz hexa-core Intel Core i7 16G memory processor.
- For a 480p 15 fps video, the CPU usage is about 10% more than a normal audio/video call when using the beauty process.
- Performance data for a device with a 2.6 GHz hexa-core Intel Core i7 16G memory processor.
Integration Instructions
Prerequisites
To use the beauty capabilities of RTCBeautyPlugin, please upgrade the TRTC SDK to v4.11.1 and above.
Install the RTCBeautyPlugin in the project:
npm install rtc-beauty-plugin
Step 1. Create an RTCBeautyPlugin instance
One RTCBeautyPlugin instance can be used to process only one local audio/video stream.
const beautyPlugin = new RTCBeautyPlugin();
Step 2. Use the RTCBeautyPlugin instance to process the stream to be published
const beautyStream = beautyPlugin.generateBeautyStream(localStream);
// Publish the retouched stream
await client.publish(beautyStream);
API Description
generateBeautyStream(localStream)
This API is used to convert a local stream (localStream) into a retouched stream (beautyStream).
// Initialize the RTCBeautyPlugin
const beautyPlugin = new RTCBeautyPlugin();
await localStream.initialize();
// Generate a retouched stream
const beautyStream = beautyPlugin.generateBeautyStream(localStream);
// Publish the retouched stream
await client.publish(beautyStream);
setBeautyParam(options)
Feature: adjust beauty filter parameters in the RTCBeautyPlugin.
To disable beautification, you only need to set all the three parameters listed in the table below to 0
.
Parameters
Name | Type | Description |
---|---|---|
beauty | number |
Strength of the beauty filter (value range: 0-1; default value: 0.5) |
brightness | number |
Strength of the brightening filter (value range: 0-1; default value: 0.5) |
ruddy | number |
Strength of the rosy skin filter (value range: 0-1; default value: 0.5) |
beautyPlugin.setBeautyParam({ beauty: 0.5, brightness: 0.5, ruddy: 0.5 });
// To disable beautification, you only need to set all the three parameters to `0`. To enable beautification, you only need to set any one of the parameters to a value greater than 0.
beautyPlugin.setBeautyParam({ beauty: 0, brightness: 0, ruddy: 0 });
destroy()
Feature: terminate the RTCBeautyPlugin.
Usage: after publishing is completed, you can terminate the RTCBeautyPlugin to stop memory usage and performance consumption.
await client.leave();
beautyPlugin.destroy();
FAQs
-
One RTCBeautyPlugin instance can be used to process only one local audio/video stream.
-
The
replaceTrack
operation will cause the beauty filter effects oflocalStream
to disappear. Please perform it with caution.