1. AcsClient インスタンスを作成します。
    1. client = AcsClient(accesskey_id, access_key_secret, mps_region_id);
  2. リクエストを作成して、パラメーターを設定します。
    1. request = SubmitSnapshotJobRequest.SubmitSnapshotJobRequest()request.set_accept_format(‘json’)
  3. スクリーンショットのパラメーターを設定します。
    • Input
      1. job_input = {‘Location’: oss_location, Bucket’: oss_bucket, Object’: quote(head_object) } request.set_Input(json.dumps(job_input))
    • SnapshotConfig
      • OutputFile
        1. job_output = {‘Location’: oss_location, Bucket’: oss_bucket, Object’: quote(oss_output_object) }snapshot_config = {‘OutputFile’: job_output}
      • Time
        1. snapshot_config[‘Time’] = 2
      • Interval/Num
        1. snapshot_config[‘Interval’] = 2snapshot_config[‘Num’] = 3
      • Width/Height
        1. snapshot_config[‘Height’] = 360
  4. API リクエストを開始して、戻り値を表示します。
    1. response_str = client.do_action_with_exception(request)response = json.loads(response_str)print responseprint RequestId is:’, response[‘RequestId’]print JobId is:’, response[‘SnapshotJob’][‘Id’]print http://%s.%s.aliyuncs.com/output_00001.jpg‘ % (oss_bucket, oss_location)print ‘http://%s.%s.aliyuncs.com/output_00002.jpg‘ % (oss_bucket, oss_location)print ‘http://%s.%s.aliyuncs.com/output_00003.jpg‘ % (oss_bucket, oss_location)
コード全体
  1. # -- coding: utf8 --import jsonfrom urllib import quotefrom aliyunsdkcore.client import AcsClientfrom aliyunsdkmts.request.v20140618 import SubmitSnapshotJobRequestaccess_key_id = ‘xxx’access_key_secret = ‘xxx’mps_region_id = ‘cn-hangzhou’pipeline_id = ‘xxx’oss_location = ‘oss-cn-hangzhou’oss_bucket = ‘xxx’oss_input_object = ‘input.mp4’oss_output_object = ‘output{Count}.jpg’# AcsClientclient = AcsClient(access_key_id, access_key_secret, mps_region_id);# requestrequest = SubmitSnapshotJobRequest.SubmitSnapshotJobRequest()request.set_accept_format(‘json’)# Inputjob_input = {‘Location’: oss_location, ‘Bucket’: oss_bucket, ‘Object’: quote(oss_input_object) }request.set_Input(json.dumps(job_input))# SnapshotConfig->OutputFilejob_output = {‘Location’: oss_location, ‘Bucket’: oss_bucket, ‘Object’: quote(oss_output_object) }snapshot_config = {‘OutputFile’: job_output}# SnapshotConfig->Timesnapshot_config[‘Time’] = 2# SnapshotConfig->Interval/Numsnapshot_config[‘Interval’] = 2snapshot_config[‘Num’] = 3# SnapshotConfig->Width/Heightsnapshot_config[‘Height’] = 360# SnapshotConfigrequest.set_SnapshotConfig(json.dumps(snapshot_config))# PipelineIdrequest.set_PipelineId(pipeline_id)# call apiresponse_str = client.do_action_with_exception(request)response = json.loads(response_str)print responseprint ‘RequestId is:’, response[‘RequestId’]print ‘JobId is:’, response[‘SnapshotJob’][‘Id’]print ‘http://%s.%s.aliyuncs.com/output_00001.jpg‘ % (oss_bucket, oss_location)print ‘http://%s.%s.aliyuncs.com/output_00002.jpg‘ % (oss_bucket, oss_location)print ‘http://%s.%s.aliyuncs.com/output_00003.jpg‘ % (oss_bucket, oss_location)
  1. </div>
  2. </article>
  3. </main>