API | Operation | Description |
Querying screenshot | Query the screenshot of media file at some time point |
GetSnapshot
API is supported since v5.4.24. To download the new version of SDK, go to Releases or see Getting Started.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") // Set the default region. For abbreviations of COS regions, visit https://www.tencentcloud.com/document/product/436/6224..Build();string secretId = "SECRET_ID"; // TencentCloud API `SecretId`. For more information on how to get it, visit https://console.tencentcloud.com/cam/capi.string secretKey = "SECRET_KEY"; // TencentCloud API `SecretKey`. For more information on how to get it, visit https://console.tencentcloud.com/cam/capi.long durationSecond = 600; // Validity period of the request signature in secondsQCloudCredentialProvider qCloudCredentialProvider = new DefaultQCloudCredentialProvider(secretId,secretKey, durationSecond);this.cosXml = new CosXmlServer(config, qCloudCredentialProvider);}/// Capture video framespublic void GetSnapshot(){// Bucket name in the format of `BucketName-APPID`. You can get the `APPID` by referring to https://console.tencentcloud.com/developer.string bucket = "examplebucket-1250000000";string key = "video.mp4"; // Object key of the media file, which should be replaced with the actual object key of the media file existing in the bucketfloat time = 1.5F; // Screenshot time point expressed as a floating point numberstring destPath = @"temp-source-file"; // The path to save the screenshot file, which needs to be replaced with a local specific path, such as "/usr/local/"GetSnapshotRequest request = new GetSnapshotRequest(bucket, key, time, destPath);// Execute the requestGetSnapshotResult result = cosXml.GetSnapshot(request);Console.WriteLine(result.GetResultInfo());}static void Main(string[] args){GetSnapshotModel m = new GetSnapshotModel();/// Capture video framesm.GetSnapshot();}}}
Was this page helpful?