本文介绍如何在你的 Android、iOS、macOS、Windows app 中实现声网视频鉴黄。
下图展示在 app 中实现声网视频鉴黄的基本工作流程。
对频道内发流端的视频进行实时鉴黄的流程如下:
enableContentInspect
成功开启视频鉴黄后,客户端 SDK 的鉴黄模块对视频流进行截图并审核,对于审核结果确定的图片,SDK 会触发 onContentInspectResult
回调,并返回鉴黄结果:正常(neutral
)、性感(sexy
)和 色情(porn
)。onContentInspectResult
返回鉴黄结果。开启声网视频鉴黄功能前,请确保满足以下条件:
SDK | 参考文档 | 支持版本 |
---|---|---|
RTC Native 4.x SDK | 实现互动直播 | >= v4.0.0 |
RTC Native 3.x SDK | 实现视频直播 | >= v3.6.2 |
调用 enableContentInspect
方法开启视频鉴黄。将 ContentInspectConfig
中的 type
设置为 MODERATION (1)
,成功调用 enableContentInspect
开启鉴黄功能后,SDK 的鉴黄功能模块会按照设定的频率进行截图,并上传截图至声网云端鉴黄服务器。示例代码如下:
ContentInspectConfig config = new ContentInspectConfig();
config.extraInfo = "YourExtraInfo";
config.moduleCount = 1;
// 功能模块的类型为视频鉴黄。
config.modules[0].type = ContentInspectConfig.CONTENT_INSPECT_TYPE_MODERATION;
// 视频鉴黄的频率为 2 秒每次。
config.modules[0].interval = 2;
mRtcEngine.enableContentInspect(true, config);
let inspectExtraConfig = AgoraContentInspectConfig()
inspectExtraConfig.extraInfo = "YourExtraInfo"
var modules = [AgoraContentInspectModule]()
let module1 = AgoraContentInspectModule()
// 功能模块的类型为视频鉴黄。
module1.type = .moderation
// 视频鉴黄的频率为 2 秒每次。
module1.interval = 2
modules.append(module1)
inspectExtraConfig.modules = modules
agoraKit.enableContentInspect(true, config:inspectExtraConfig)
void CMainFrame::OnBtnEnableContentInspect()
{
if (CAgoraObject::GetEngine() == NULL) {
return;
}
ContentInspectConfig config;
ContentInspectModule module1;
// 功能模块的类型为视频鉴黄。
module1.type = kContentInspectModeration;
// 视频鉴黄的频率为 2 秒每次。
module1.interval = 2;
config.moduleCount = 1;
config.modules[0] = module1;
CAgoraObject::GetEngine()->enableContentInspect(true, config);
}
客户端鉴黄完成后,SDK 会触发 onContentInspectResult
回调,返回鉴黄结果。请参考如下示例代码监听客户端鉴黄回调。
客户端鉴黄结果(
onContentInspectResult
回调)和云端鉴黄结果( HTTP 请求)完全一致。
public void onContentInspectResult(int result) {
}
// OC
(void)rtcEngine:(AgoraRtcEngineKit* _Nonnull)engine contentInspectResult:(AgoraContentInspectResult)result{
}
// Swift
func rtcEngine(_ engine: AgoraRtcEngineKit, contentInspectResult result: AgoraContentInspectResult) {
}
void onContentInspectResult(CONTENT_INSPECT_RESULT result){
}
各平台视频鉴黄动态库名称及集成后 app 增加的体积见下表:
平台 | 架构 | 库名 | 集成后 app 增加的体积(KB) |
---|---|---|---|
Android | arm64-v8a | libagora_ci_extension.so |
1116 |
Android | armeabi-v7a | libagora_ci_extension.so |
986 |
iOS | arm64 | AgoraCIExtension.xcframework |
1344 |
iOS | armv7 | AgoraCIExtension.xcframework |
1104 |
macOS | arm64 | AgoraCIExtension.xcframework |
1328 |
macOS | x86_64 | AgoraCIExtension.xcframework |
1324 |
Windows | x86 | libagora_ci_extension.dll |
2229 |
Windows | x86_64 | libagora_ci_extension.dll |
2633 |