You need to enable JavaScript to run this app.
导航
视频截帧(iOS SDK)
最近更新时间:2024.02.04 18:31:09首次发布时间:2023.11.03 16:08:03

视频截帧功能可以从视频流中截取指定时刻的单帧画面,并按指定大小缩放成图片。

示例代码

以下代码展示如何截取第 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];

TOSGetObjectToFileInput *get = [TOSGetObjectToFileInput new];
get.tosBucket = @"bucket-name";
get.tosKey = @"video-name";
get.tosFilePath = @"your_local_file_path";
get.tosProcess = @"video/snapshot,t_1000";
TOSTask *task = [client getObjectToFile:get];
[task continueWithBlock:^id _Nullable(TOSTask * _Nonnull t) {
    if (!t.error) {
        NSLog(@"Get object to file success.");
    } else {
        NSLog(@"Get object to file failed, error: %@" ,t.error);
    }
    return nil;
}];

相关文档

关于视频截帧的详细介绍,请参见视频截帧