《阿里云AI产品必知必会系列电子书》——阿里云视觉智能开放平台——视频理解QuickStart使用教程(2) https://developer.aliyun.com/article/1232494?groupCode=supportservice
三、通过Python-SDK调用视频理解-检测视频快照
1、pip install
pip install aliyun-python-sdk-videorecog==1.0.4
2、创建DetectVideoShot
from aliyunsdkcore.client import AcsClient from aliyunsdkcore.client import AcsClient from aliyunsdkcore.auth.credentials import AccessKeyCredential from aliyunsdkvideorecog.request.v20200320.DetectVideoShotRequest import DetectVideoShotRequest credentials = AccessKeyCredential('accesskey', 'accesskeysecret') client = AcsClient(region_id='cn-shanghai', credential=credentials) request = DetectVideoShotRequest() request.set_accept_format('json') request.set_VideoUrl("url") response = client.do_action_with_exception(request) print(str(response, encoding='utf-8'))
3、返回异步任务请求ID
{ "RequestId": "02F***8-DD5C-5538-B605-89***2114A" }
4、查询异步任务结果
from aliyunsdkcore.client import AcsClient from aliyunsdkcore.auth.credentials import AccessKeyCredential from aliyunsdkvideorecog.request.v20200320.GetAsyncJobResultRequest import GetAsyncJobResultRequest credentials = AccessKeyCredential('accesskey', 'accesskeysecret') client = AcsClient(region_id='cn-shanghai', credential=credentials) request = GetAsyncJobResultRequest() request.set_accept_format('json') request.set_JobId("02F***8-DD5C-5538-B605-89***2114A") response = client.do_action_with_exception(request) print(str(response, encoding='utf-8'))
5、获取异步结果数据返回
{ "RequestId": "7D***D-C75A-5DC3-946D-0D5F***91", "Data": { "Status": "PROCESS_SUCCESS", "JobId": "02F***8-DD5C-5538-B605-89***2114A", "Result": "{\"ShotFrameIds\":[0,108,156,181,222,254,313,358,414,450,483,513,537,576]}" } }
《阿里云AI产品必知必会系列电子书》——阿里云视觉智能开放平台——视频理解QuickStart使用教程(4) https://developer.aliyun.com/article/1232490?groupCode=supportservice