简体   繁体   English

弹性转码器 Boto3 Lambda

[英]Elastic Transcoder Boto3 Lambda

I am tearing my hear out with the following error when trying to use Elastic Transcoder invoked from Lambda via a python function Boto3.尝试使用通过 python 函数 Boto3 从 Lambda 调用的 Elastic Transcoder 时,我听到以下错误消息。 The error in Cloudwatch Logs is: "An error occurred (ValidationException) when calling the CreateJob operation: 1 validation error detected: Value 'PIPE' at 'pipelineId' failed to satisfy constraint: Member must satisfy regular expression pattern: ^\\d{13}-\\w{6}$" Cloudwatch 日志中的错误是:“调用 CreateJob 操作时发生错误 (ValidationException):检测到 1 个验证错误:‘pipelineId’处的值‘PIPE’未能满足约束:成员必须满足正则表达式模式:^\\d{13 }-\\w{6}$"

As per my code, I specify the name of my Pipeline ID in Elastic Transcoder as PIPE and it doesn't like the characters used.根据我的代码,我在 Elastic Transcoder 中将我的管道 ID 的名称指定为 PIPE 并且它不喜欢使用的字符。 I have tried a few other combinations such as a number and dot.我尝试了一些其他组合,例如数字和点。 Has anyone had this error and solved it before?有没有人遇到过这个错误并解决过它? I have used AWS example code as my starting point.我使用 AWS 示例代码作为我的起点。 Thanks in advance!提前致谢!

import boto3
from botocore.exceptions import ClientError

def lambda_handler(event, context):

    # Job configuration settings. Set these values before running the script.
    pipeline_id = 'PIPE'         # ID of an existing Elastic Transcoder pipeline
    input_file = 'ChiliChallenge.mp4'          # Name of an existing file in the S3 input bucket
    output_file = 'output'  # Desired root name of the transcoded output files

    # Other job configuration settings. Optionally change as desired.
    output_file_prefix = 'elastic-transcoder-samples/output/hls/'  # Prefix for all output files
    segment_duration = '2'                                         # Maximum segment duration in seconds

    # Elastic Transcoder presets used to create HLS multi-segment
    # output files in MPEG-TS format
    hls_64k_audio_preset_id = '1351620000001-200071'    # HLS Audio 64kb/second
    hls_0400k_preset_id = '1351620000001-200050'        # HLS 400k
    hls_0600k_preset_id = '1351620000001-200040'        # HLS 600k
    hls_1000k_preset_id = '1351620000001-200030'        # HLS 1M
    hls_1500k_preset_id = '1351620000001-200020'        # HLS 1.5M
    hls_2000k_preset_id = '1351620000001-200010'        # HLS 2M

    # Define the various outputs
    outputs = [
        {
            'Key': 'hlsAudio/' + output_file,
            'PresetId': hls_64k_audio_preset_id,
            'SegmentDuration': segment_duration,
        },
        {
            'Key': 'hls0400k/' + output_file,
            'PresetId': hls_0400k_preset_id,
            'SegmentDuration': segment_duration,
        },
        {
            'Key': 'hls0600k/' + output_file,
            'PresetId': hls_0600k_preset_id,
            'SegmentDuration': segment_duration,
        },
        {
            'Key': 'hls1000k/' + output_file,
            'PresetId': hls_1000k_preset_id,
            'SegmentDuration': segment_duration,
        },
        {
            'Key': 'hls1500k/' + output_file,
            'PresetId': hls_1500k_preset_id,
            'SegmentDuration': segment_duration,
        },
        {
            'Key': 'hls2000k/' + output_file,
            'PresetId': hls_2000k_preset_id,
            'SegmentDuration': segment_duration,
        },
    ]

    # Define the playlist
    playlists = [
        {
            'Name': 'hls_' + output_file,
            'Format': 'HLSv3',
            'OutputKeys': [x['Key'] for x in outputs]
        }
    ]

    # Create an HLS job in Elastic Transcoder
    etc_client = boto3.client('elastictranscoder')
    response = etc_client.create_job(PipelineId=pipeline_id,
                                         Input={'Key': input_file},
                                         Outputs=outputs,
                                         OutputKeyPrefix=output_file_prefix,
                                         Playlists=playlists)

    # Output job ID and exit. Do not wait for the job to finish.
    print(f'Created Amazon Elastic Transcoder HLS job {job_info["Id"]}')

On entering your regex at https://regexr.com/https://regexr.com/输入您的正则表达式

I think your pipeline_id should be of the format:我认为您的 pipeline_id 应该是以下格式:

1704334089176-jhNzi6 (13 digits followed by a '-' followed by 6 alphanumeric chars). 1704334089176-jhNzi6(13 位数字后跟“-”后跟 6 个字母数字字符)。

Do check your Pipeline ID in Elastic Transcoder to confirm the correct pipe ID.请务必在 Elastic Transcoder 中检查您的管道 ID,以确认正确的管道 ID。 Maybe this can help you find out the correct ID:也许这可以帮助您找出正确的 ID:

https://docs.aws.amazon.com/elastictranscoder/latest/developerguide/list-pipelines.html https://docs.aws.amazon.com/elastictranscoder/latest/developerguide/list-pipelines.html

Why have you set PipelineId to 'PIPE'?为什么将 PipelineId 设置为“PIPE”? The pipeline ID is not an identifier that you choose;管道 ID 不是您选择的标识符; it's the ID of an existing pipeline resource, one that you should have previously created using create_pipeline() or equivalent and to which the Elastic Transcoder service assigned a unique pipeline ID of the form ^\\d{13}-\\w{6}$ .它是现有管道资源的 ID,您之前应该使用create_pipeline()或等效方法创建该资源,并且 Elastic Transcoder 服务为其分配了一个唯一的管道 ID,形式为^\\d{13}-\\w{6}$ .

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM