2013-07-30 55 views
2

我正在尝试对某些视频进行转码,但我连接的方式有些问题。你如何连接到AWS Elastic Transcoder?

这里是我的代码:

transcode = layer1.ElasticTranscoderConnection() 
transcode.DefaultRegionEndpoint = 'elastictranscoder.us-west-2.amazonaws.com' 
transcode.DefaultRegionName = 'us-west-2' 
transcode.create_job(pipelineId, transInput, transOutput) 

这里的例外:

{u'message': u'The specified pipeline was not found: account=xxxxxx, pipelineId=xxxxxx.'} 
+0

请你给我的,你做了什么样本?我正在创建一个项目,让博托自动化我的工作,但我甚至找不到一个简单的例子! –

+0

对不起,这是相当晚...这段代码很旧,但也许它会帮助别人https://github.com/eddiem3/automated-uploader/blob/master/main.py –

+0

我不需要它们不管怎么说,但是非常感谢;) –

回答

5

要连接到在博托特定区域,可以使用:

import boto.elastictranscoder 
transcode = boto.elastictranscoder.connect_to_region('us-west-2') 
transcode.create_job(...) 
4

我用刚开始博托前一天,但以前的答案不适合我 - 不知道如果API更改或什么(似乎有点奇怪,如果它是二d,但无论如何)。这是我做到的。

#!/usr/bin/env python 

# Boto 
import boto 

# Debug 
boto.set_stream_logger('boto') 

# Pipeline Id 
pipeline_id = 'lotsofcharacters-393824' 

# The input object 
input_object = { 
    'Key': 'foo.webm', 
    'Container': 'webm', 
    'AspectRatio': 'auto', 
    'FrameRate': 'auto', 
    'Resolution': 'auto', 
    'Interlaced': 'auto' 
} 

# The object (or objects) that will be created by the transcoding job; 
# note that this is a list of dictionaries. 
output_objects = [ 
    { 
     'Key': 'bar.mp4', 
     'PresetId': '1351620000001-000010', 
     'Rotate': 'auto', 
     'ThumbnailPattern': '', 
    } 
] 

# Phone home 
# - Har har. 
et = boto.connect_elastictranscoder() 

# Create the job 
# - If successful, this will execute immediately. 
et.create_job(pipeline_id, input_name=input_object, outputs=output_objects) 

很明显,这是一个人为的例子,只是从一个独立的python脚本运行;它假定你有一个.boto文件在你的证书中。

另一件需要注意的是PresetId;您可以在Presets下的Elastic Transcoder的AWS管理控制台中找到它们。最后,可以填入字典中的值逐字地从以下链接中提取 - 据我所知,它们只是插入到REST调用中(很明显,区分大小写)。

AWS Create Job API

相关问题