API | 操作描述 |
用于提交一个视频审核任务 | |
用于查询指定的视频审核任务 |
using COSXML.Model.CI;using COSXML.Auth;using System;using System.Threading;using COSXML;namespace COSSnippet{public class SubmitVideoCensorJobModel {private CosXml cosXml;SubmitVideoCensorJobModel() {CosXmlConfig config = new CosXmlConfig.Builder().SetRegion("COS_REGION") // 设置默认的地域, COS 地域的简称请参照 https://www.tencentcloud.com/document/product/436/6224?from_cn_redirect=1.Build();string secretId = "SECRET_ID"; // 云 API 密钥 SecretId, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capistring secretKey = "SECRET_KEY"; // 云 API 密钥 SecretKey, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capilong durationSecond = 600; //每次请求签名有效时长,单位为秒QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,secretKey, durationSecond);this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);}// 提交视频审核任务public string SubmitVideoCensorJob(){// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000"; // 注意:此操作需要 bucket 开通内容审核相关功能SubmitVideoCensorJobRequest request = new SubmitVideoCensorJobRequest(bucket);request.SetCensorObject("video.mp4"); // 媒体文件的对象键,需要替换成桶内存在的媒体文件的对象键// 审核的场景类型,有效值:Porn(涉黄)、Ads(广告),可以传入多种类型,不同类型以逗号分隔,例如:Porn,Adsrequest.SetDetectType("Porn,Ads");// 视频画面的审核通过视频截帧能力截取出一定量的截图,通过对截图逐一审核而实现的,该参数用于指定视频截帧的配置。request.SetSnapshotMode("Average"); // 截帧模式。Interval 表示间隔模式;Average 表示平均模式;Fps 表示固定帧率模式。request.SetSnapshotCount("100"); // 视频截帧数量,范围为(0, 10000]request.SetSnapshotTimeInterval("1.0"); // 视频截帧频率,范围为(0, 60],单位为秒,支持 float 格式,执行精度精确到毫秒// 执行请求SubmitCensorJobResult result = cosXml.SubmitVideoCensorJob(request);Console.WriteLine(result.GetResultInfo());Console.WriteLine(result.censorJobsResponse.JobsDetail.JobId);Console.WriteLine(result.censorJobsResponse.JobsDetail.State);Console.WriteLine(result.censorJobsResponse.JobsDetail.CreationTime);return result.censorJobsResponse.JobsDetail.JobId;}static void Main(string[] args){SubmitVideoCensorJobModel m = new SubmitVideoCensorJobModel();// 提交审核任务,JobId唯一标识了本次提交的审核任务的结果string JobId = m.SubmitVideoCensorJob();// 打印 JobIdConsole.WriteLine("JobId : " + JobId);}}}
using COSXML.Model.CI;using COSXML.Auth;using System;using System.Threading;using COSXML;namespace COSSnippet{public class SubmitVideoCensorJobModel {private CosXml cosXml;SubmitVideoCensorJobModel() {CosXmlConfig config = new CosXmlConfig.Builder().SetRegion("COS_REGION") // 设置默认的区域, COS 地域的简称请参照 https://www.tencentcloud.com/document/product/436/6224?from_cn_redirect=1.Build();string secretId = "SECRET_ID"; // 云 API 密钥 SecretId, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capistring secretKey = "SECRET_KEY"; // 云 API 密钥 SecretKey, 获取 API 密钥请参照 https://console.tencentcloud.com/cam/capilong durationSecond = 600; //每次请求签名有效时长,单位为秒QCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,secretKey, durationSecond);this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);}// 查询视频审核任务结果public void GetVideoCensorJobResult(string JobId){// 存储桶名称,此处填入格式必须为 bucketname-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000"; // 注意:此操作需要 bucket 开通内容审核相关功能GetVideoCensorJobRequest request = new GetVideoCensorJobRequest(bucket, JobId);// 执行请求GetVideoCensorJobResult result = cosXml.GetVideoCensorJob(request);Console.WriteLine(result.GetResultInfo());// 读取审核结果Console.WriteLine(result.resultStruct.JobsDetail.JobId);Console.WriteLine(result.resultStruct.JobsDetail.State);Console.WriteLine(result.resultStruct.JobsDetail.CreationTime);Console.WriteLine(result.resultStruct.JobsDetail.Object);Console.WriteLine(result.resultStruct.JobsDetail.SnapshotCount);Console.WriteLine(result.resultStruct.JobsDetail.Result);Console.WriteLine(result.resultStruct.JobsDetail.PornInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.PornInfo.Count);Console.WriteLine(result.resultStruct.JobsDetail.AdsInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.AdsInfo.Count);// 审核视频截图内容for(int i = 0; i < result.resultStruct.JobsDetail.Snapshot.Count; i++){Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].Url);Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].Text);Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].SnapshotTime);Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].PornInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].PornInfo.Score);Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].PornInfo.Label);Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].PornInfo.SubLabel);Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].AdsInfo.HitFlag);Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].AdsInfo.Score);Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].AdsInfo.Label);Console.WriteLine(result.resultStruct.JobsDetail.Snapshot[i].AdsInfo.SubLabel);}}static void Main(string[] args){SubmitVideoCensorJobModel m = new SubmitVideoCensorJobModel();// 输入在提交审核任务时获取的JobIdstring JobId = "xxx";// 查询审核任务m.GetVideoCensorJobResult(JobId);}}}
本页内容是否解决了您的问题?