RTC SDK 提供与智能美化特效(CV)SDK 联合方案,你可以通过调用 RTC SDK 提供的美颜处理接口,快速接入 CV 功能,对本地采集的视频添加美颜、滤镜、贴纸等特效,相较于通过 RTC 自定义视频前处理功能接入第三方美颜,集成更快捷、使用更方便、效果更佳。
本文介绍如何在 RTC 应用中接入 CV 功能。
本功能需付费使用,请联系美颜技术支持团队获取 v4.4.2+ 的 Standard/Lite 版本特效 SDK 及符合业务功能需求的 License 和素材资源包。
已在项目中集成 3.50 及以上版本的 RTC SDK 并实现 RTC 视频通话功能。为保证你可以体验所有新增特性,推荐使用 最新版本 RTC SDK。
操作系统需满足以下要求:
Android: Android 5.0+
iOS: iOS 11+(不支持模拟器)
macOS: macOS 10.10+
Windows: Win 7+
下载并解压 Android SDK,获取智能美化特效库 effectAAR-release_V4.x.xLite.aar 文件。
将特效库文件添加至 Android 项目中的 app/libs 文件夹中。注意,若对特效库文件进行重命名,则需确保特效库名在 Android 工程中一致。此处以重命名为 ByteEffect.aar 为例。

在项目根目录下 <yourprojectname>/app/build.gradle 文件的 depencencies 中使用 implementation 字段添加智能美化特效库,并点击 Sync 按钮同步。
dependencies {
//...
implementation(name: 'ByteEffect', ext: 'aar')
implementation 'com.volcengine:VolcEngineRTC:3.xx.xxx'
}
java
注意:
LicenseBag.bundle 中存放特效证书,其他 bundle 中存放各类型的素材资源文件。
特效证书的包名需与项目的包名保持一致,否则证书无法生效。


通过下方示例中 getExternalResourcePath() 函数可以获取指定的资源拷贝路径,指定的路径可以自定义。copyAssetFolder() 会将 assets 路径下的资源拷贝到指定的资源路径下,这里需要保证资源路径和拷贝路径都正确。
/**
* 初始化美颜资源文件
* 将安装包内的资源文件拷贝到外部存储上
*/
public static void initVideoEffectResource() {
Context context = mAppCxt;
File licensePath = new File(getExternalResourcePath(), "LicenseBag.bundle");
licensePath.deleteOnExit();
copyAssetFolder(context, "Effect/LicenseBag.bundle", licensePath.getAbsolutePath());
File modelPath = new File(getExternalResourcePath(), "ModelResource.bundle");
if (!modelPath.exists()) {
copyAssetFolder(context, "Effect/ModelResource.bundle", modelPath.getAbsolutePath());
}
File stickerPath = new File(getExternalResourcePath(), "StickerResource.bundle");
if (!stickerPath.exists()) {
copyAssetFolder(context, "Effect/StickerResource.bundle", stickerPath.getAbsolutePath());
}
File filterPath = new File(getExternalResourcePath(), "FilterResource.bundle");
if (!filterPath.exists()) {
copyAssetFolder(context, "Effect/FilterResource.bundle", filterPath.getAbsolutePath());
}
File composerPath = new File(getExternalResourcePath(), "ComposeMakeup.bundle");
if (!composerPath.exists()) {
copyAssetFolder(context, "Effect/ComposeMakeup.bundle", composerPath.getAbsolutePath());
}
File virtualPicturePath = new File(getExternalResourcePath(), "virtual_background.png");
if (!virtualPicturePath.exists()) {
copyAssetFile(context, "virtual_background.png", virtualPicturePath.getAbsolutePath());
}
}
public static String getExternalResourcePath() {
return mAppCxt.getExternalFilesDir("assets").getAbsolutePath() + "/Effect/";
}
public static String getEffectPortraitPath() {
return getStickerPathByName("matting_bg");
}
public static String getStickerPathByName(String name) {
return mAppCxt.getExternalFilesDir("assets").getAbsolutePath() + "/Effect/StickerResource.bundle/stickers/" + name;
}
public static String getFilterPathByName(String name) {
return mAppCxt.getExternalFilesDir("assets").getAbsolutePath() + "/Effect/FilterResource.bundle/Filter/" + name;
}
public static String getBeautyPath() {
return mAppCxt.getExternalFilesDir("assets").getAbsolutePath() + "/Effect/ComposeMakeup.bundle/ComposeMakeup/beauty_Android_lite";
}
public static String getStylePathByName(String name) {
return mAppCxt.getExternalFilesDir("assets").getAbsolutePath() + "/Effect/ComposeMakeup.bundle/ComposeMakeup/style_makeup/" + name;
}
java集成完成后,可通过调用 initCVResource(),查看返回值,判断是否集成成功。
private void configEffect(){
//EffectManager 为自定义封装的美颜工具类
EffectManager.initVideoEffectResource();
String licPath = EffectManager.getLicensePath();
String modelPath = EffectManager.getModelPath();
IVideoEffect effect = mRTCVideo.getVideoEffectInterface();
int result = effect.initCVResource(licPath, modelPath);
result = effect.enableVideoEffect();
}
java关闭所有美颜特效。
effect.disableVideoEffect();
java美颜特效素材存放在 ComposeMakeup.bundle 文件中,你需使用 setEffectNodes 设置素材路径并使用 updateEffectNode 更新特效强度才会显示美颜效果。updateEffectNode 可以设置的素材 key 可以参考素材key对应说明。
注意:资源路径需要指定到 ../ComposeMakeup.bundle/ComposeMakeup/beauty_Android_lite 这层。
private void configEffect(){
//...省略美颜资源初始化和美颜配置代码
//美颜设置
String composePath = EffectManager.getBeautyPath();
List<String> nodes = Arrays.asList(composePath);
result = effect.setEffectNodes(nodes);
result = effect.updateEffectNode(composePath,"smooth",0.8f);
}
java贴纸特效素材存放在 StickerResource.bundle 文件中,你需使用的接口为 setEffectNodes 设置素材路径后方可显示贴纸效果。
注意:贴纸路径需要指定到特定贴纸名,例如 ../StickerResource.bundle/stickers/stickers_zhaocaimao
private void configEffect(){
//...省略美颜资源初始化和美颜配置代码
//贴纸
String stickerPath = EffectManager.getStickerPathByName("stickers_zhaocaimao");
List<String> nodes = Arrays.asList(stickerPath);
result = effect.setEffectNodes(nodes);
}
java风格妆特效素材存放在 ComposeMakeup.bundle 文件中,你需使用 setEffectNodes 设置素材路径并使用 updateEffectNode 更新特效强度方可显示风格妆效果。updateEffectNode 可以设置的素材 key 可以参考素材key对应说明。
注意:风格妆路径需要指定到特定风格妆名,例如 ../ComposeMakeup.bundle/ComposeMakeup/style_makeup/aidou
private void configEffect(){
//...省略美颜资源初始化和美颜配置代码
//风格妆
String stylePath = EffectManager.getStylePathByName("nuannan");
List<String> nodes = Arrays.asList(stylePath);
result = effect.setEffectNodes(nodes);
result = effect.updateEffectNode(composePath,"Filter_ALL",0.8f);
result = effect.updateEffectNode(composePath,"Makeup_ALL",0.8f);
}
java滤镜特效素材存放在 FilterResource.bundle 文件中,你需使用 setColorFilter 设置素材路径并使用 setColorFilterIntensity 设置滤镜强度后方可显示滤镜效果。
注意:滤镜路径需要指定到特定滤镜名,例如 ../FilterResource.bundle/Filter/Filter_01_38
private void configEffect(){
//...省略美颜资源初始化和美颜配置代码
effect.setColorFilter(filterPath);
effect.setColorFilterIntensity(0.8f);
}
java你需使用 enableVirtualBackground(bg_sticker_res, source) 开启虚拟背景特效,参数 bg_sticker_res 为背景贴纸素材的绝对路径,参数 source 为期望设置的背景,当你期望设置一张自定义图片作为背景时,需将 sourceType 指定为 SourceTypeImage,并通过 sourcePath 设置自定义背景图片的绝对路径。
注意:虚拟背景的贴纸特效素材类型必须选择为“matting_bg”。
private void configEffect(){
//...省略美颜资源初始化和美颜配置代码
//开启虚拟背景
VirtualBackgroundSource backgroundSource = new VirtualBackgroundSource();
backgroundSource.sourceType = VirtualBackgroundSourceType.SourceTypeImage;
backgroundSource.sourcePath = EffectManager.getExternalResourcePath() + File.separator + "virtual_background.png";
String portraitPath = EffectManager.getEffectPortraitPath();
effect.enableVirtualBackground(portraitPath,backgroundSource);
//关闭虚拟背景
effect.disableVirtualBackground();
}
java智能美化特效相关接口自 3.50 版本起由 RTCVideo 类迁移至 IVideEffect 类。若你使用 3.50 之前版本的 RTC SDK,你需通过 RTCVideo 实例调用智能美化特效相关接口。强烈建议你使用最新版 RTC SDK 以体验更加丰富而全面的智能美化特效功能,旧版接口也将在 3.56 版本删除。

private void configEffect(){
EffectManager.initVideoEffectResource();
String licPath = EffectManager.getLicensePath();
String modelPath = EffectManager.getModelPath();
//美颜
String composePath = EffectManager.getBeautyPath();
//滤镜
String filterPath = EffectManager.getFilterPathByName("Filter_01_38");
//贴纸
String stickerPath = EffectManager.getStickerPathByName("stickers_zhaocaimao");
//妆容
String stylePath = EffectManager.getStylePathByName("nuannan");
List<String> nodes = Arrays.asList(composePath,stickerPath);
int result = mRTCVideo.checkVideoEffectLicense(EffectManager.getApplicationContext(),licPath);
mRTCVideo.setVideoEffectAlgoModelPath(modelPath);
result = mRTCVideo.enableVideoEffect(true);
result = mRTCVideo.setVideoEffectNodes(nodes);
result = mRTCVideo.updateVideoEffectNode(composePath,"smooth",0.8f);
mRTCVideo.setVideoEffectColorFilter(filterPath);
mRTCVideo.setVideoEffectColorFilterIntensity(0.8f);
mRTCVideo.updateVideoEffectNode(stylePath,"Filter_ALL",0.8f);
mRTCVideo.updateVideoEffectNode(stylePath,"Makeup_ALL",0.8f);
//开启虚拟背景
VirtualBackgroundSource backgroundSource = new VirtualBackgroundSource();
backgroundSource.sourceType = VirtualBackgroundSourceType.SourceTypeImage;
backgroundSource.sourcePath = EffectManager.getExternalResourcePath() + File.separator + "virtual_background.png";
String portraitPath = EffectManager.getEffectPortraitPath();
mRTCVideo.setBackgroundSticker(portraitPath,backgroundSource);
//关闭
mRTCVideo.setBackgroundSticker(null,backgroundSource);
}
java下载并解压 iOS SDK,获取智能美化特效库 effect-sdk.framework 文件。
将 effect-sdk.framework 文件手动拖入项目工程中,并在 General 中将其 embed 属性设置为 Embed & Sign 模式。

将获取到的素材资源手动添加至工程中。

注意:特效证书的包名需与项目的 bundle Identifier 保持一致,否则无法生效。

调用 createRTCVideo 创建引擎并开启视频采集后,你需先初始化美颜资源,并设置美颜资源和证书路径,方可开启美颜,在本地预览画面中看到美颜效果。注意,你需设置完整的证书文件路径,即指定到具体的证书文件;模型文件路径指定到 ModelResource.bundle 这层即可。
集成完成后,可通过调用 initCVResource:withAlgoModelDir:,查看返回值,判断是否集成成功。
- (void)configEffect {
NSString *bunldePath = [[NSBundle mainBundle] pathForResource:@"LicenseBag" ofType:@"bundle"];
NSString *licensePath = [NSString stringWithFormat:@"%@/%@", bunldePath, @"xxxx.licbag"];
NSString *modelBunldePath = [[NSBundle mainBundle] pathForResource:@"ModelResource" ofType:@"bundle"];
ByteRTCVideoEffect *effect = [self.video getVideoEffectInterface];
int result = [effect initCVResource:licensePath withAlgoModelDir:modelBunldePath];
result = [effect enableVideoEffect];
}
objectivec关闭所有美颜特效。
[effect disableVideoEffect];
objectivec美颜特效素材存放在 ComposeMakeup.bundle 文件中,你需使用 setEffectNodes 设置素材路径并使用 updateEffectNode 更新特效强度才会显示美颜效果。updateEffectNode 可以设置的素材 key 可以参考素材key对应说明。
注意:资源路径需要指定到 ../ComposeMakeup.bundle/ComposeMakeup/beauty_IOS_lite 这层。
- (void)configEffect {
//...省略美颜资源初始化和美颜配置代码
NSString *beautyPrefix = [[NSBundle mainBundle] pathForResource:@"ComposeMakeup" ofType:@"bundle"];
NSString *beautyPath = [NSString stringWithFormat:@"%@/ComposeMakeup/%@", beautyPrefix, @"beauty_IOS_lite"];
result = [effect setEffectNodes:@[beautyStylePath]];
[effect updateEffectNode:beautyPath key:@"smooth" value:0.8];
}
objectivec贴纸特效素材存放在 StickerResource.bundle 文件中,你需使用的接口为 setEffectNodes 设置素材路径后方可显示贴纸效果。
注意:贴纸路径需要指定到特定贴纸名,例如 ../StickerResource.bundle/stickers/stickers_zhaocaimao
- (void)configEffect {
//...省略美颜资源初始化和美颜配置代码
NSString *portraitPrefix = [[NSBundle mainBundle] pathForResource:@"StickerResource" ofType:@"bundle"];
NSString *stickerPath = [NSString stringWithFormat:@"%@/stickers/%@", portraitPrefix, @"stickers_zhaocaimao"];
result = [effect setEffectNodes:@[stickerPath]];
}
objectivec风格妆特效素材存放在 ComposeMakeup.bundle 文件中,你需使用 setEffectNodes 设置素材路径并使用 updateEffectNode 更新特效强度方可显示风格妆效果。updateEffectNode 可以设置的素材 key 可以参考素材key对应说明。
注意:风格妆路径需要指定到特定风格妆名,例如 ../ComposeMakeup.bundle/ComposeMakeup/style_makeup/aidou
- (void)configEffect {
//...省略美颜资源初始化和美颜配置代码
NSString *beautyPrefix = [[NSBundle mainBundle] pathForResource:@"ComposeMakeup" ofType:@"bundle"];
NSString *beautyStylePath = [NSString stringWithFormat:@"%@/ComposeMakeup/%@", beautyPrefix, @"style_makeup/yuanqi"];
result = [effect setEffectNodes:@[beautyStylePath]];
[effect updateEffectNode:beautyStylePath key:@"Filter_ALL" value:0.8];
[effect updateEffectNode:beautyStylePath key:@"Makeup_ALL" value:0.8];
}
objectivec滤镜特效素材存放在 FilterResource.bundle 文件中,你需使用 setColorFilter 设置素材路径并使用 setColorFilterIntensity 设置滤镜强度后方可显示滤镜效果。
注意:滤镜路径需要指定到特定滤镜名,例如 ../FilterResource.bundle/Filter/Filter_01_38
- (void)configEffect {
//...省略美颜资源初始化和美颜配置代码
NSString *filterPath = [NSString stringWithFormat:@"%@/Filter/%@", filterPrefix, @"Filter_26_Po4"];
[effect setColorFilter:filterPath];
[effect setColorFilterIntensity:1];
}
objectivec你需使用 enableVirtualBackground: bg_sticker_path :source 开启虚拟背景特效,参数 bg_sticker_path 为背景贴纸素材的绝对路径,参数 source 为期望设置的背景,当你期望设置一张自定义图片作为背景时,需将 sourceType 指定为 ByteRTCVirtualBackgroundSourceTypeImage,并通过 sourcePath 设置自定义背景图片的绝对路径。
注意:虚拟背景的贴纸特效素材类型必须选择为“matting_bg”。
- (void)configEffect {
//...省略美颜资源初始化和美颜配置代码
//开启虚拟背景
ByteRTCVirtualBackgroundSource *source = [[ByteRTCVirtualBackgroundSource alloc] init];
NSString *sourcePath = [[NSBundle mainBundle] pathForResource:@"virtual_background" ofType:@"png"];
source.sourceType = ByteRTCVirtualBackgroundSourceTypeImage;
source.sourcePath = sourcePath;
NSString *bgPath = [NSString stringWithFormat:@"%@/stickers/%@", portraitPrefix, @"matting_bg"];
[effect enableVirtualBackground:bgPath withSource:source];
//关闭虚拟背景
[effect disableVirtualBackground];
}
objectivec智能美化特效相关接口自 3.50 版本起由 ByteRTCVideo 类迁移至 ByteRTCVideoEffect 类。若你使用 3.50 之前版本的 RTC SDK,你需通过 ByteRTCVideo 实例调用智能美化特效相关接口。强烈建议你使用最新版 RTC SDK 以体验更加丰富而全面的智能美化特效功能,旧版接口也将在 3.56 版本删除。

- (void)configEffect {
NSString *bunldePath = [[NSBundle mainBundle] pathForResource:@"LicenseBag" ofType:@"bundle"];
NSString *licensePath = [NSString stringWithFormat:@"%@/%@", bunldePath, @"xxxxx.licbag"];
NSString *modelBunldePath = [[NSBundle mainBundle] pathForResource:@"ModelResource" ofType:@"bundle"];
NSString *portraitPrefix = [[NSBundle mainBundle] pathForResource:@"StickerResource" ofType:@"bundle"];
NSString *beautyPrefix = [[NSBundle mainBundle] pathForResource:@"ComposeMakeup" ofType:@"bundle"];
NSString *filterPrefix = [[NSBundle mainBundle] pathForResource:@"FilterResource" ofType:@"bundle"];
NSString *beautyPath = [NSString stringWithFormat:@"%@/ComposeMakeup/%@", beautyPrefix, @"beauty_IOS_lite"];
NSString *beautyStylePath = [NSString stringWithFormat:@"%@/ComposeMakeup/%@", beautyPrefix, @"style_makeup/yuanqi"];
NSString *stickerPath = [NSString stringWithFormat:@"%@/stickers/%@", portraitPrefix, @"stickers_zhaocaimao"];
NSString *filterPath = [NSString stringWithFormat:@"%@/Filter/%@", filterPrefix, @"Filter_26_Po4"];
[self.video checkVideoEffectLicense:licensePath];
[self.video setVideoEffectAlgoModelPath:modelBunldePath];
[self.video enableVideoEffect:YES];
//贴纸
[self.video setVideoEffectNodes:@[beautyStylePath]];
[self.video updateVideoEffectNode:beautyStylePath nodeKey:@"Filter_ALL" nodeValue:0.8];
[self.video updateVideoEffectNode:beautyStylePath nodeKey:@"Makeup_ALL" nodeValue:0.8];
// 更新美颜强度,美颜默认强度为0没效果
[self.video updateVideoEffectNode:beautyPath nodeKey:@"smooth" nodeValue:0.8];
int result = [self.video setVideoEffectColorFilter:filterPath];
NSLog(@"-----------------setVideoEffectColorFilter result---------------:%d",result);
result = [self.video setVideoEffectColorFilterIntensity:0.9];
NSLog(@"-----------------setVideoEffectColorFilterIntensity result---------------:%d",result);
//开启和配置虚拟背景
ByteRTCVirtualBackgroundSource *source = [[ByteRTCVirtualBackgroundSource alloc] init];
NSString *sourcePath = [[NSBundle mainBundle] pathForResource:@"virtual_background" ofType:@"png"];
source.sourceType = ByteRTCVirtualBackgroundSourceTypeImage;
source.sourcePath = sourcePath;
NSString *bgPath = [NSString stringWithFormat:@"%@/stickers/%@", portraitPrefix, @"matting_bg"];
[self.video setBackgroundSticker:bgPath source:source];
//关闭虚拟背景
[self.video setBackgroundSticker:nil source:source];
}
objectivec下载并解压 Windows SDK,获取 effect.dll 文件。文件路径为 VolcEngineRTC/bin/Win32(x64)/effect.dll。
如果已经集成 RTC SDK,可以将 effect.dll 文件拷贝到工程目录的 RTC 动态库文件夹中;如果尚未集成 RTC SDK,可以将 VolcEngineRTC 整个目录拷贝至工程目录中。
手动添加素材资源到工程中。无路径限制,可置于工程目录下任意位置。

调用 createRTCVideo 创建引擎并开启视频采集后,你需先初始化美颜资源,并设置美颜资源和证书路径,方可开启美颜,在本地预览画面中看到美颜效果。注意,你需设置完整的证书文件路径,即指定到具体的证书文件;模型文件路径指定到 ModelResource.bundle 这层即可。
集成完成后,可通过调用 initCVResource,查看返回值,判断是否集成成功。
auto video_effect = video->getVideoEffectInterface();
auto ret = video_effect->initCVResource(license_path_ptr, model_path_ptr);
video_effect->enableVideoEffect();
cpp关闭所有美颜特效。
auto ret = video_effect->disableVideoEffect();
cpp美颜特效素材存放在 ComposeMakeup.bundle 文件中,你需使用 setEffectNodes 设置素材路径并使用 updateEffectNode 更新特效强度才会显示美颜效果。updateEffectNode 可以设置的素材 key 可以参考素材key对应说明。
注意:资源路径需要指定到 ../ComposeMakeup.bundle/ComposeMakeup/beauty_Android_lite 这层。
ret = video_effect->setEffectNodes(reinterpret_cast<const char**>(&effect_node_paths[0]), data.nodeNum);
std::string node_path = GetFilePath("cvlab_for_pc/" + data.nodePath);
ret = video_effect->updateEffectNode(node_path.c_str(), data.nodeKey.c_str(), data.nodeValue);
cpp贴纸特效素材存放在 StickerResource.bundle 文件中,你需使用的接口为 setEffectNodes 设置素材路径后方可显示贴纸效果。
注意:贴纸路径需要指定到特定贴纸名,例如 ../StickerResource.bundle/stickers/stickers_zhaocaimao
ret = video_effect->setEffectNodes(reinterpret_cast<const char**>(&effect_node_paths[0]), data.nodeNum);
cpp风格妆特效素材存放在 ComposeMakeup.bundle 文件中,你需使用 setEffectNodes 设置素材路径并使用 updateEffectNode 更新特效强度方可显示风格妆效果。updateEffectNode 可以设置的素材 key 可以参考素材key对应说明。
注意:风格妆路径需要指定到特定风格妆名,例如 ../ComposeMakeup.bundle/ComposeMakeup/style_makeup/aidou
ret = video_effect->setEffectNodes(reinterpret_cast<const char**>(&effect_node_paths[0]), data.nodeNum);
std::string node_path = GetFilePath("cvlab_for_pc/" + data.nodePath);
ret = video_effect->updateEffectNode(node_path.c_str(), "Makeup_ALL", data.nodeValue);
cpp滤镜特效素材存放在 FilterResource.bundle 文件中,你需使用 setColorFilter 设置素材路径并使用 setColorFilterIntensity 设置滤镜强度后方可显示滤镜效果。
注意:滤镜路径需要指定到特定滤镜名,例如 ../FilterResource.bundle/Filter/Filter_01_38
std::string res_path = GetFilePath("cvlab_for_pc/" + data.resPath);
auto ret = 0;
ret = video_effect->setColorFilter(res_path.c_str());
ret = video_effect->setColorFilterIntensity(data.intensity);
cpp你需使用 enableVirtualBackground(bg_sticker_path, source) 开启虚拟背景特效,参数 bg_sticker_path 为背景贴纸素材的绝对路径,参数 source 为期望设置的背景,当你期望设置一张自定义图片作为背景时,需将 source_type 指定为 kVirtualBackgroundSourceImage,并通过 sourcePath 设置自定义背景图片的绝对路径。
注意:虚拟背景的贴纸特效素材类型必须选择为“matting_bg”。
//开启虚拟背景
std::string bg_sticker_path = GetFilePath("cvlab_for_pc/" + data.bg_model_path);
std::string source_path = GetFilePath(data.source.source_path);
const char* source_path_ptr = source_path.c_str();
bytertc::VirtualBackgroundSource source;
source.source_color = data.source.source_color;
source.source_path = source_path_ptr;
source.source_type = data.source.source_type;
auto ret = video_effect->enableVirtualBackground(bg_sticker_path_ptr, source);
//关闭虚拟背景
video_effect->disableVirtualBackground;
cpp智能美化特效相关接口自 3.50 版本起由 IRTCVideo 类迁移至 IVideoEffect 类。若你使用 3.50 之前版本的 RTC SDK,你需通过 IRTCVideo 实例调用智能美化特效相关接口。强烈建议你使用最新版 RTC SDK 以体验更加丰富而全面的智能美化特效功能,旧版接口也将在 3.56 版本删除。

auto ret = video->checkLicense(nullptr, nullptr, license_path_ptr);
video_effect->setAlgoModelPath(model_path.c_str());
ret = video->setVideoEffectNodes(reinterpret_cast<const char**>(&effect_node_paths[0]), data.nodeNum);
ret = video->updateVideoEffectNode(node_path.c_str(), data.nodeKey.c_str(), data.nodeValue);、
ret = video->setVideoEffectColorFilter(res_path.c_str());
auto ret = video->setVideoEffectColorFilterIntensity(data.intensity);
//开启虚拟背景
std::string bg_sticker_path = GetFilePath("cvlab_for_pc/" + data.bg_model_path);
std::string source_path = GetFilePath(data.source.source_path);
const char* source_path_ptr = source_path.c_str();
bytertc::VirtualBackgroundSource source;
source.source_color = data.source.source_color;
source.source_path = source_path_ptr;
source.source_type = data.source.source_type;
ret = video->setBackgroundSticker(bg_sticker_path_ptr, source);
//关闭虚拟背景
ret = video->setBackgroundSticker(null, source);
cpp| 关键流程 | 业务逻辑 | Android | iOS | macOS | Windows | 备注 |
|---|---|---|---|---|---|---|
| 【必须】初始化资源 | 检查智能美化特效证书,设置算法模型路径,并初始化特效模块。 | initCVResource | initCVResource:withAlgoModelDir: | initCVResource:withAlgoModelDir: | initCVResource | 关于许可证的相关问题,参看授权相关。 |
| 【可选】使用特效处理 | 开启特效。 | enableVideoEffect | enableVideoEffect: | enableVideoEffect: | enableVideoEffect | / |
| 设置智能美化特效素材包。 | setEffectNodes | setEffectNodes: | setEffectNodes: | setEffectNodes | / | |
| 设置特效强度。 | updateEffectNode | updateEffectNode:key:value: | updateEffectNode:key:value: | updateEffectNode | / | |
| 设置颜色滤镜。 | setColorFilter | setColorFilter: | setColorFilter: | setColorFilter | 在选择滤镜素材时,请参看 滤镜素材对应序号。 | |
| 设置已启用颜色滤镜的强度。 | setColorFilterIntensity | setColorFilterIntensity: | setColorFilterIntensity: | setColorFilterIntensity | / | |
| 关闭特效。 | disableVideoEffect | disableVideoEffect | disableVideoEffect | disableVideoEffect | 虚拟背景、人脸检测不受特效关闭影响。 | |
| 【可选】使用虚拟背景 | 开启虚拟背景。 | enableVirtualBackground | enableVirtualBackground:withSource: | enableVirtualBackground:withSource: | enableVirtualBackground | 虚拟背景功能使用参看背景分割。 |
| 关闭虚拟背景。 | disableVirtualBackground | disableVirtualBackground | disableVirtualBackground | disableVirtualBackground |
Q:调用接口可能返回的错误码有哪些?
A:参考接口返回错误码。
Q:如何判断 Android 的美颜资源是否拷贝到指定路径上?
A:在集成测试阶段可以通过 adb 工具去查看。如果没有 adb 工具,需自行下载安装。
指令:adb shell、ls、cd
//1. 先 adb shell
~/ adb shell
//2. cd 到指定的路径
cupid:/ $ cd /storage/emulated/0/Android/data/com.ss.rtc.demo.advanced/
//3. 通过ls查看文件夹下的文件,在通过cd进入文件夹
cupid:/storage/emulated/0/Android/data/com.ss.rtc.demo.advanced/files/assets $
ls
Effect
cupid:/storage/emulated/0/Android/data/com.ss.rtc.demo.advanced/files/assets $
cd Effect
cupid:/storage/emulated/0/Android/data/com.ss.rtc.demo.advanced/files/assets/Effect $ ls
ComposeMakeup.bundle LicenseBag.bundle StickerResource.bundle
FilterResource.bundle ModelResource.bundle
javaQ:-121 错误怎么处理?
A:先检查下文件路径是否正确,然后在检查下指定的资源名称是否正确。
Q:如果资源路径正确,代码调用顺序正确,但是美颜没效果如何处理?
A:完成如下自检
检查包名是否和证书匹配。
检查调用的接口是否有返回错误码,跟进错误码进行处理。
确保有没有新旧智能美化特效接口没有混用。
若仍无法解决,请联系技术支持。
Q:测试证书能否上线?
A:测试证书无法上线,需替换为正式证书。正式证书需联系CV技术支持获取。
Q:更新 App 或者需要上马甲包是否需要重新申请美颜证书?
A:包名和证书不匹配,需联系 CV 技术支持重新申请。
Q:iOS 虚拟背景使用 png 图片为何不生效?
A:Xcode 会对 png 图片进行压缩处理,点击对应的图片,修改 Type 为 Data。

Q:Android 怎么实现智能美化特效 SDK 不被混淆?
Q:美颜资源太大、美颜证书会过期、美颜类型新增和删除等都需要更新 App 比较麻烦,如何处理?
A:建议将美颜素材资源存储在云端进行管理,App 使用时按需从云端下载资源到本地,以节省包大小、方便素材的新增/删除/升级。