TOS 支持将视频截帧后的图片保存到指定存储桶。
以下代码展示如何截取第 1000ms 的视频帧,并将截取后的图片保存至指定存储桶。
// 从STS服务获取的临时访问密钥和安全令牌(AccessKey、SecretKey、SecurityToken) TOSCredential *credential = [[TOSCredential alloc] initWithAccessKey:@"accesskey" secretKey:@"secretkey" securityToken:@"securityToken"]; TOSEndpoint *tosEndpoint = [[TOSEndpoint alloc] initWithURLString:@"endpoint" withRegion:@"region"]; TOSClientConfiguration *config = [[TOSClientConfiguration alloc] initWithEndpoint:tosEndpoint credential:credential]; TOSClient *client = [[TOSClient alloc] initWithConfiguration:config]; TOSGetObjectInput *get = [TOSGetObjectInput new]; get.tosBucket = @"bucket-name"; get.tosKey = @"video-name"; get.tosProcess = @"video/snapshot,t_1000"; get.tosProcessSaveAsBucket = @"target-bucket-name"; get.tosProcessSaveAsObject = @"target-image-name"; TOSTask *task = [client getObject:get]; [task continueWithBlock:^id _Nullable(TOSTask * _Nonnull t) { if (!task.error) { NSLog(@"Get object success."); // 获取转存结果 TOSGetObjectOutput *out = t.result; NSLog(@"%@", [[NSString alloc] initWithData:out.tosContent encoding:NSUTF8StringEncoding]); } else { NSLog(@"Get object failed, error: %@" ,task.error); } return nil; }];
关于视频截帧图片持久化的详细介绍,请参见图片持久化。