在AWS Elemental MediaConvert中,远程输入与S3输入有一些不同之处。下面是一个包含代码示例的解决方法:
import boto3
# 创建IAM角色
def create_input_role(role_name):
iam_client = boto3.client('iam')
assume_role_policy_document = {
"Version": "2012-10-17",
"Statement": [
{
"Effect": "Allow",
"Principal": {
"Service": "mediaconvert.amazonaws.com"
},
"Action": "sts:AssumeRole"
}
]
}
role = iam_client.create_role(
RoleName=role_name,
AssumeRolePolicyDocument=json.dumps(assume_role_policy_document)
)
# 为角色添加所需的权限
iam_client.attach_role_policy(
RoleName=role_name,
PolicyArn='arn:aws:iam::aws:policy/AWSMediaConvertFullAccess'
)
return role
# 创建远程输入角色
input_role_name = 'MediaConvert-Remote-Input-Role'
input_role = create_input_role(input_role_name)
print(input_role['Role']['Arn'])
import boto3
# 创建远程输入模板
def create_remote_input_template(role_arn, bucket_name, file_key):
mediaconvert_client = boto3.client('mediaconvert')
response = mediaconvert_client.create_job_template(
Name='Remote-Input-Template',
Role=role_arn,
Settings={
'Inputs': [
{
'FileInput': f's3://{bucket_name}/{file_key}'
}
]
}
)
return response
# 创建远程输入模板
input_role_arn = 'arn:aws:iam::123456789012:role/MediaConvert-Remote-Input-Role'
bucket_name = 'my-bucket'
file_key = 'input-file.mp4'
response = create_remote_input_template(input_role_arn, bucket_name, file_key)
print(response['JobTemplate']['Arn'])
在上面的代码示例中,创建了一个远程输入角色和一个远程输入模板。远程输入角色用于访问远程输入文件,而远程输入模板定义了使用远程输入的作业模板。
请确保替换示例代码中的正确角色名称、ARN、存储桶名称和文件键值,以适应您的实际情况。
上一篇:AWS Elemental MediaConvert - 输出对象由不同的帐户拥有
下一篇:AWS Elemental MediaConvert MPEG-DASH:无法使用清单配置文件“urn:mpeg:dash:profile:isoff-on-demand:2011”创建 mpd。