有奖捉虫:云通信与企业服务文档专题,速来> HOT

简介

内容审核功能是由 数据万象(Cloud Infinite,CI)提供的,数据万象将处理能力与 COS SDK 完全结合,您可以直接按照本篇文档指引进行使用。
说明
使用内容审核服务需拥有数据万象使用权限:
主账号请 单击此处 进行角色授权。
子账号请参见 授权子账号接入数据万象服务 文档。
本文档提供关于视频审核的相关的 API 概览以及 SDK 示例代码。
API
操作描述
用于提交一个视频审核任务
用于查询指定的视频审核任务

创建任务

PutVideoAuditingJob 接口用于提交一个视频审核任务。您可以通过主动设置回调地址接收审核信息,也可以通过 JobId 进行查询。

方法原型

func (s *CIService) PutVideoAuditingJob(ctx context.Context, opt *PutVideoAuditingJobOptions) (*PutVideoAuditingJobResult, *Response, error)

请求示例

// 将 examplebucket-1250000000 和 COS_REGION修改为真实的信息
// CI 任务需要提供CIURL
bu, _ := url.Parse("https://examplebucket-1250000000.cos.COS_REGION.myqcloud.com")
cu, _ := url.Parse("https://examplebucket-1250000000.ci.COS_REGION.myqcloud.com")
b := &cos.BaseURL{BucketURL: bu, CIURL: cu}
c := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: os.Getenv("SECRETID"),
SecretKey: os.Getenv("SECRETKEY"),
}
})
opt := &cos.PutVideoAuditingJobOptions{
InputObject: "demo.mp4",
Conf: &cos.VideoAuditingJobConf{
Snapshot: &cos.PutVideoAuditingJobSnapshot{
Mode: "Interval",
TimeInterval: 50.5,
Count: 100,
},
},
}
res, _, err := c.CI.PutVideoAuditingJob(context.Background(), opt)

参数说明

type PutVideoAuditingJobOptions struct {
InputObject string
InputUrl string
InputDataId string
InputUserInfo *UserExtraInfo
Conf *VideoAuditingJobConf
Type string
}
type UserExtraInfo struct {
TokenId string
Nickname string
DeviceId string
AppId string
Room string
IP string
Type string
}
type VideoAuditingJobConf struct {
Snapshot *PutVideoAuditingJobSnapshot
Callback string
CallbackVersion string
CallbackType int
BizType string
DetectContent int
}
type PutVideoAuditingJobSnapshot struct {
Mode string
Count int
TimeInterval float32
}
参数名称
参数描述
类型
是否必填
InputObject
当前 COS 存储桶中的视频文件名称,例如在目录 test 中的文件 video.mp4,则文件名称为 test/video.mp4。Object 和 Url 只能选择其中一种。
String
InputUrl
视频文件的链接地址,例如 http://examplebucket-1250000000.cos.ap-shanghai.myqcloud.com/test.mp4。Object 和 Url 只能选择其中一种。
String
InputDataId
视频标识,该字段在结果中返回原始内容,长度限制为512字节。
String
InputUserInfo
用户业务字段。
Object
Type
审核的任务类型,直播流审核固定为 live_video。
String
Conf
审核规则配置。
Struct
BizType
审核策略,不填写则使用默认策略。可在控制台进行配置,详情请参见 设置审核策略
String
Snapshot
视频画面的审核通过视频截帧能力截取出一定量的截图,通过对截图逐一审核而实现的,该参数用于指定视频截帧的配置。
Struct
Callback
审核结果以回调形式发送至您的回调地址,支持以 http:// 或者 https:// 开头的地址,例如:http://www.callback.com
String
CallbackVersion
回调内容的结构,有效值:Simple(回调内容包含基本信息)、Detail(回调内容包含详细信息)。默认为 Simple。
String
CallbackType
回调片段类型,有效值:1(回调全部截帧和音频片段)、2(仅回调违规截帧和音频片段)。默认为 1。
Integer
DetectContent
用于指定是否审核视频声音,当值为0时:表示只审核视频画面截图;值为1时:表示同时审核视频画面截图和视频声音。默认值为0。
Integer
Mode
截帧模式,默认值为Interval。Interval 表示间隔模式;Average 表示平均模式;Fps 表示固定帧率模式。Interval 模式:TimeInterval,Count 参数生效。当设置 Count,未设置 TimeInterval 时,表示截取所有帧,共 Count 张图片。Average 模式:Count 参数生效。表示整个视频,按平均间隔截取共 Count 张图片。Fps 模式:TimeInterval 表示每秒截取多少帧,未设置 TimeInterval 时,表示截取所有帧,Count 表示共截取多少帧。
String
Count
视频截帧数量,范围为(0, 10000]。
Integer
TimeInterval
视频截帧频率,范围为(0, 60],单位为秒,支持 float 格式,执行精度精确到毫秒。
Float

结果说明

调用 PutVideoAuditingJob 函数,会解析 api 返回的 xml 内容到 PutVideoAuditingJobResult 结构,具体返回参数可查看 提交视频审核任务 文档。

查询任务

GetVideoAuditingJob 接口用来查询指定的视频审核任务。您可以根据视频审核任务的 JobId 来查询视频审核结果。

方法原型

func (s *CIService) GetVideoAuditingJob(ctx context.Context, jobid string) (*GetVideoAuditingJobResult, *Response, error)

请求示例

// 将 examplebucket-1250000000 和 COS_REGION修改为真实的信息
// CI 任务需要提供CIURL
bu, _ := url.Parse("https://examplebucket-1250000000.cos.COS_REGION.myqcloud.com")
cu, _ := url.Parse("https://examplebucket-1250000000.ci.COS_REGION.myqcloud.com")
b := &cos.BaseURL{BucketURL: bu, CIURL: cu}
c := cos.NewClient(b, &http.Client{
Transport: &cos.AuthorizationTransport{
SecretID: os.Getenv("SECRETID"),
SecretKey: os.Getenv("SECRETKEY"),
}
})
jobId := "avce25f391a72e11eb99f********"
res, _, err := c.CI.GetVideoAuditingJob(context.Background(), jobId)

参数说明

参数名称
参数描述
类型
jobId
任务 ID
String

结果说明

调用 GetVideoAuditingJob 函数,会解析 api 返回的 xml 内容到 GetVideoAuditingJobResult 结构,具体返回参数可查看 查询视频审核任务结果 文档。