1. Create AcsClient instance.
    client = AcsClient(access_key_id, access_key_secret, mps_region_id);
  2. Create request, and set parameters.
    request = SubmitJobsRequest.SubmitJobsRequest()
    request.set_accept_format('json')
  3. Transcoding parameters.
    • Input
      job_input = {'Location': oss_location,
                    'Bucket': oss_bucket,
                    'Object': quote(oss_input_object) }
      request.set_Input(json.dumps(job_input))
    • Output
      output = {'OutputObject': quote(oss_output_object)}
      • Container
        output['Container'] = {'Format': 'mp4'}
      • Video
        output['Video'] = {'Codec': 'H. 264',
                              'Bitrate': 1500,
                              'Width': 1280,
                              'Fps': 25}
      • Audio
        output['Audio'] = {'Codec': 'AAC',
                              'Bitrate': 128,
                              'Channels': 2,
                              'Samplerate': 44100}
      • TemplateId
        output['TemplateId'] = template_id
    • PipelineId
      request.set_PipelineId(pipeline_id)
  4. Initiate API request and display returned value.
    response_str = client.do_action_with_exception(request)
    response = json.loads(response_str)
    print 'RequestId is:', response['RequestId']
    if response['JobResultList']['JobResult'][0]['Success']:
    print 'JobId is:', response['JobResultList']['JobResult'][0]['Job']['JobId']
    else:
    print ('SubmitJobs Failed code:',
          response['JobResultList']['JobResult'][0]['Code'],
          ' message:',
          response['JobResultList']['JobResult'][0]['Message'])
Full code
# -*- coding: utf8 -*-
import json
from urllib import quote
from aliyunsdkcore.client import AcsClient
from aliyunsdkmts.request.v20140618 import SubmitJobsRequest
access_key_id = 'xxx'
access_key_secret = 'xxx'
mps_region_id = 'cn-hangzhou'
pipeline_id = 'xxx'
template_id = 'S00000001-200010'
oss_location = 'oss-cn-hangzhou'
oss_bucket = 'xxx'
oss_input_object = 'input.mp4'
oss_output_object = 'output.mp4'
Create AcsClient instance
client = AcsClient(access_key_id, access_key_secret, mps_region_id);
Create request,and set parameters
request = SubmitJobsRequest.SubmitJobsRequest()
request.set_accept_format('json')
# Input
job_input = {'Location': oss_location,
             'Bucket': oss_bucket,
             'Object': quote(oss_input_object) }
request.set_Input(json.dumps(job_input))
# Output
output = {'OutputObject': quote(oss_output_object)}
# Ouput->Container
output['Container'] = {'Format': 'mp4'}
# Ouput->Video
output['Video'] = {'Codec': 'H. 264',
                   'Bitrate': 1500,
                   'Width': 1280,
                   'Fps': 25}
# Ouput->Audio
output['Audio'] = {'Codec': 'AAC',
                   'Bitrate': 128,
                   'Channels': 2,
                   'Samplerate': 44100}
# Ouput->TemplateId
output['TemplateId'] = template_id
outputs = [output]
request.set_Outputs(json.dumps(outputs))
request.set_OutputBucket(oss_bucket)
request.set_OutputLocation(oss_location)
# PipelineId
request.set_PipelineId(pipeline_id)
Initiate API request and diaplay returned value
response_str = client.do_action_with_exception(request)
response = json.loads(response_str)
print 'RequestId is:', response['RequestId']
if response['JobResultList']['JobResult'][0]['Success']:
    print 'JobId is:', response['JobResultList']['JobResult'][0]['Job']['JobId']
else:
    print ('SubmitJobs Failed code:',
           response['JobResultList']['JobResult'][0]['Code'],
           ' message:',
           response['JobResultList']['JobResult'][0]['Message'])