AWS Elemental MediaConvert:不支持mov文件。
创始人
2024-11-16 00:31:44
0

要解决"AWS Elemental MediaConvert:不支持mov文件"的问题,您可以使用AWS SDK for Python(Boto3)来转换不支持的mov文件格式为AWS Elemental MediaConvert支持的格式,如MP4。以下是一个使用Boto3的示例代码:

import boto3

def convert_mov_to_mp4(input_bucket, input_key, output_bucket, output_key):
    # 创建MediaConvert客户端
    client = boto3.client('mediaconvert', region_name='us-west-2') # 根据您的区域设置正确的区域名称

    # 设置输入和输出媒体文件的S3位置
    input_url = f's3://{input_bucket}/{input_key}'
    output_url = f's3://{output_bucket}/{output_key}'

    # 创建MediaConvert作业
    response = client.create_job(
        Role='arn:aws:iam::123456789012:role/MediaConvertRole', # 替换为您的角色ARN
        Settings={
            'Inputs': [
                {
                    'FileInput': input_url
                },
            ],
            'OutputGroups': [
                {
                    'OutputGroupSettings': {
                        'Type': 'FILE_GROUP_SETTINGS',
                        'FileGroupSettings': {
                            'Destination': {
                                'DestinationRefId': 'destination'
                            }
                        }
                    },
                    'Outputs': [
                        {
                            'VideoDescription': {
                                'CodecSettings': {
                                    'Codec': 'H_264', # 根据您的要求选择正确的编解码器
                                    'H264Settings': {
                                        'Bitrate': 5000000, # 根据您的要求设置正确的比特率
                                        'CodecLevel': 'AUTO',
                                        'CodecProfile': 'MAIN',
                                        'RateControlMode': 'CBR'
                                    }
                                },
                                'Height': 720, # 根据您的要求设置正确的分辨率
                                'Width': 1280,
                                'ScalingBehavior': 'DEFAULT',
                                'TimecodeInsertion': 'DISABLED'
                            },
                            'OutputSettings': {
                                'Extension': 'mp4', # 指定输出文件的扩展名
                                'NameModifier': '_output'
                            },
                            'Extension': 'mp4',
                            'NameModifier': '_output',
                            'Preset': 'System-Avc_16x9_720p_29_97fps_5000kbps', # 根据您的要求选择正确的预设
                            'VideoDescription': {
                                'ScalingBehavior': 'DEFAULT',
                                'TimecodeInsertion': 'DISABLED'
                            }
                        },
                    ],
                    'OutputGroupSettings': {
                        'Type': 'FILE_GROUP_SETTINGS',
                        'FileGroupSettings': {
                            'Destination': {
                                'DestinationRefId': 'destination'
                            }
                        }
                    }
                },
            ],
            'AdAvailOffset': 0,
            'Inputs': [
                {
                    'AudioSelectors': {
                        'Audio Selector 1': {
                            'Offset': 0,
                            'DefaultSelection': 'NOT_DEFAULT',
                            'ProgramSelection': 1
                        }
                    },
                    'VideoSelector': {
                        'ColorSpace': 'FOLLOW',
                        'Rotate': 'DEGREE_0',
                        'AlphaBehavior': 'DISCARD'
                    },
                    'FileInput': input_url
                },
            ],
            'OutputGroups': [
                {
                    'OutputGroupSettings': {
                        'Type': 'FILE_GROUP_SETTINGS',
                        'FileGroupSettings': {
                            'Destination': {
                                'DestinationRefId': 'destination'
                            }
                        }
                    },
                    'Outputs': [
                        {
                            'Preset': 'System-Avc_16x9_720p_29_97fps_5000kbps',
                            'NameModifier': '_output',
                            'Extension': 'mp4',
                            'VideoDescription': {
                                'ScalingBehavior': 'DEFAULT',
                                'TimecodeInsertion': 'DISABLED'
                            }
                        },
                    ]
                },
            ],
            'TimecodeConfig': {
                'Source': 'EMBEDDED'
            }
        }
    )

    # 获取作业ID
    job_id = response['Job']['Id']
    print(f'转换作业已创建,作业ID: {job_id}')

    # 等待作业完成
    waiter = client.get_waiter('job_complete')
    waiter.wait(Id=job_id)

    print('转换完成!')

# 示例用法:
convert_mov_to_mp4('input-bucket', 'input.mov', 'output-bucket', 'output.mp4')

相关内容

热门资讯

AWSECS:访问外部网络时出... 如果您在AWS ECS中部署了应用程序,并且该应用程序需要访问外部网络,但是无法正常访问,可能是因为...
AWSElasticBeans... 在Dockerfile中手动配置nginx反向代理。例如,在Dockerfile中添加以下代码:FR...
AWR报告解读 WORKLOAD REPOSITORY PDB report (PDB snapshots) AW...
AWS管理控制台菜单和权限 要在AWS管理控制台中创建菜单和权限,您可以使用AWS Identity and Access Ma...
银河麒麟V10SP1高级服务器... 银河麒麟高级服务器操作系统简介: 银河麒麟高级服务器操作系统V10是针对企业级关键业务...
北信源内网安全管理卸载 北信源内网安全管理是一款网络安全管理软件,主要用于保护内网安全。在日常使用过程中,卸载该软件是一种常...
群晖外网访问终极解决方法:IP... 写在前面的话 受够了群晖的quickconnet的小水管了,急需一个新的解决方法&#x...
​ToDesk 远程工具安装及... 目录 前言 ToDesk 优势 ToDesk 下载安装 ToDesk 功能展示 文件传输 设备链接 ...
Azure构建流程(Power... 这可能是由于配置错误导致的问题。请检查构建流程任务中的“发布构建制品”步骤,确保正确配置了“Arti...
不能访问光猫的的管理页面 光猫是现代家庭宽带网络的重要组成部分,它可以提供高速稳定的网络连接。但是,有时候我们会遇到不能访问光...