Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/308.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/sockets/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 弹性转码器_Python_Amazon Web Services_Aws Lambda_Boto3_Amazon Elastic Transcoder - Fatal编程技术网

Python 弹性转码器

Python 弹性转码器,python,amazon-web-services,aws-lambda,boto3,amazon-elastic-transcoder,Python,Amazon Web Services,Aws Lambda,Boto3,Amazon Elastic Transcoder,当我试图使用通过python函数Boto3从Lambda调用的弹性代码转换器时,我犯了以下错误。Cloudwatch日志中的错误是:“调用CreateJob操作时发生错误(ValidationException):检测到1个验证错误:“pipelineId”处的值“PIPE”无法满足约束:成员必须满足正则表达式模式:^\d{13}-\w{6}$” 根据我的代码,我在Elastic Transcoder中将管道ID的名称指定为管道,它不喜欢使用的字符。我尝试过其他一些组合,比如数字和点。以前有人犯

当我试图使用通过python函数Boto3从Lambda调用的弹性代码转换器时,我犯了以下错误。Cloudwatch日志中的错误是:“调用CreateJob操作时发生错误(ValidationException):检测到1个验证错误:“pipelineId”处的值“PIPE”无法满足约束:成员必须满足正则表达式模式:^\d{13}-\w{6}$”

根据我的代码,我在Elastic Transcoder中将管道ID的名称指定为管道,它不喜欢使用的字符。我尝试过其他一些组合,比如数字和点。以前有人犯过这个错误并解决过吗?我使用AWS示例代码作为起点。提前谢谢

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"]}')

我认为您的管道id应采用以下格式:

1704334089176-jhNzi6(13位数字后跟一个“-”,后跟6个字母数字字符)

请在弹性转码器中检查管道ID,以确认正确的管道ID。也许这可以帮助您找到正确的ID:


为什么要将PipelineId设置为“管道”?管道ID不是您选择的标识符;它是一个现有管道资源的ID,您以前应该使用该资源或等效资源创建它,并且弹性代码转换服务为它分配了一个唯一的管道ID,其形式为
^\d{13}-\w{6}$

谢谢!我已更新代码,以包含管道id而不是名称。