API | 操作名 | 操作描述 |
查询截图 | 用于查询媒体文件在某个时间的截图 |
using COSXML.Model.CI;using COSXML.Auth;using System;using COSXML;namespace COSSnippet{public class GetSnapshotModel {private CosXml cosXml;GetSnapshotModel() {CosXmlConfig config = new CosXmlConfig.Builder().SetRegion("COS_REGION") // 设置默认的地域, COS 地域的简称请参照 https://www.tencentcloud.com/document/product/436/6224.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 GetSnapshot(){// 存储桶名称,此处填入格式必须为 BucketName-APPID, 其中 APPID 获取参考 https://console.tencentcloud.com/developerstring bucket = "examplebucket-1250000000";string key = "video.mp4"; // 媒体文件的对象键,需要替换成桶内存在的媒体文件的对象键float time = 1.5F; // 截取的具体时间,用浮点数表示string destPath = @"temp-source-file"; // 截图文件保存路径, 需要替换成本地具体路径, 例如"/usr/local/"GetSnapshotRequest request = new GetSnapshotRequest(bucket, key, time, destPath);// 执行请求GetSnapshotResult result = cosXml.GetSnapshot(request);Console.WriteLine(result.GetResultInfo());}static void Main(string[] args){GetSnapshotModel m = new GetSnapshotModel();/// 视频截帧m.GetSnapshot();}}}
本页内容是否解决了您的问题?