无法使用 Amazon Elastic Transcoder 创建预设
Failed to Create preset with Amazon Elastic Transcoder
我正在使用 Amazon Elastic 转码器和 boto 库来创建预设。
此代码对我有用,没有任何问题:
preset1=transcode.create_preset('preset', 'preset', 'mp4', {"Codec":"H.264", "CodecOptions":{"Profile":"baseline", "Level":"3",
"MaxReferenceFrames":"3"}, "KeyframesMaxDist":"200", "FixedGOP":"false", "BitRate":"600", "FrameRate":"10", "Resolution":"640x480",
"AspectRatio":"4:3" }, {"Codec":"AAC","CodecOptions":{"Profile":"AAC-LC"}, "SampleRate":"22050", "BitRate":"32", "Channels":"1" },
{"Format":"png", "Interval":"60", "Resolution":"192x144", "AspectRatio":"4:3"})
但是,当我定义一个具有相同值的变量时:
preset_h264_480p_100kbs_mp4_command='"Name":"preset","Description": "preset", "Container":"mp4","video":
{"Codec":"H.264", "CodecOptions":{"Profile":"baseline", "Level":"3", "MaxReferenceFrames":"3"}, "KeyframesMaxDist":"200",
"FixedGOP":"false", "BitRate":"600", "FrameRate":"10", "Resolution":"640x480", "AspectRatio":"4:3" },"audio":
{"Codec":"AAC","CodecOptions":{"Profile":"AAC-LC"}, "SampleRate":"22050", "BitRate":"32", "Channels":"1" }, "thumbnails":
{"Format":"png", "Interval":"60", "Resolution":"192x144", "AspectRatio":"4:3"}'
我遇到了这个错误:
transcode.create_preset(preset_h264_480p_100kbs_mp4_command)Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/boto/elastictranscoder/layer1.py", line 421, in create_preset
data=json.dumps(params))
File "/usr/local/lib/python2.7/dist-packages/boto/elastictranscoder/layer1.py", line 932, in make_request
raise error_class(response.status, response.reason, body)
boto.elastictranscoder.exceptions.ValidationException: ValidationException: 400 Bad Request
{u'message': u'2 validation errors detected: Value null at \'container\' failed to satisfy constraint: Member must not be null; Value \'"Name":"preset","Description": "preset", "Container":"mp4","video": {"Codec":"H.264", "CodecOptions":{"Profile":"baseline", "Level":"3", "MaxReferenceFrames":"3"}, "KeyframesMaxDist":"200", "FixedGOP":"false", "BitRate":"600", "FrameRate":"10", "Resolution":"640x480", "AspectRatio":"4:3" },"audio": {"Codec":"AAC","CodecOptions":{"Profile":"AAC-LC"}, "SampleRate":"22050", "BitRate":"32", "Channels":"1" }, "thumbnails":{"Format":"png", "Interval":"60", "Resolution":"192x144", "AspectRatio":"4:3"}\' at \'name\' failed to satisfy constraint: Member must have length less than or equal to 40'}
此验证表明 'container' 为空!但它不是空的。
我很困惑发生了什么!
提前致谢
您可以使用 Python 中的 unpacking arg list 功能编写此代码:
preset_h264_480p_100kbs_mp4_command={ "name":"preset","description": "preset", "container":"mp4","video":
{"Codec":"H.264", "CodecOptions":{"Profile":"baseline", "Level":"3", "MaxReferenceFrames":"3"}, "KeyframesMaxDist":"200",
"FixedGOP":"false", "BitRate":"600", "FrameRate":"10", "Resolution":"640x480", "AspectRatio":"4:3" },"audio":
{"Codec":"AAC","CodecOptions":{"Profile":"AAC-LC"}, "SampleRate":"22050", "BitRate":"32", "Channels":"1" }, "thumbnails":
{"Format":"png", "Interval":"60", "Resolution":"192x144", "AspectRatio":"4:3"} }
transcode.create_preset(**preset_h264_480p_100kbs_mp4_command)
我正在使用 Amazon Elastic 转码器和 boto 库来创建预设。 此代码对我有用,没有任何问题:
preset1=transcode.create_preset('preset', 'preset', 'mp4', {"Codec":"H.264", "CodecOptions":{"Profile":"baseline", "Level":"3",
"MaxReferenceFrames":"3"}, "KeyframesMaxDist":"200", "FixedGOP":"false", "BitRate":"600", "FrameRate":"10", "Resolution":"640x480",
"AspectRatio":"4:3" }, {"Codec":"AAC","CodecOptions":{"Profile":"AAC-LC"}, "SampleRate":"22050", "BitRate":"32", "Channels":"1" },
{"Format":"png", "Interval":"60", "Resolution":"192x144", "AspectRatio":"4:3"})
但是,当我定义一个具有相同值的变量时:
preset_h264_480p_100kbs_mp4_command='"Name":"preset","Description": "preset", "Container":"mp4","video":
{"Codec":"H.264", "CodecOptions":{"Profile":"baseline", "Level":"3", "MaxReferenceFrames":"3"}, "KeyframesMaxDist":"200",
"FixedGOP":"false", "BitRate":"600", "FrameRate":"10", "Resolution":"640x480", "AspectRatio":"4:3" },"audio":
{"Codec":"AAC","CodecOptions":{"Profile":"AAC-LC"}, "SampleRate":"22050", "BitRate":"32", "Channels":"1" }, "thumbnails":
{"Format":"png", "Interval":"60", "Resolution":"192x144", "AspectRatio":"4:3"}'
我遇到了这个错误:
transcode.create_preset(preset_h264_480p_100kbs_mp4_command)Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "/usr/local/lib/python2.7/dist-packages/boto/elastictranscoder/layer1.py", line 421, in create_preset
data=json.dumps(params))
File "/usr/local/lib/python2.7/dist-packages/boto/elastictranscoder/layer1.py", line 932, in make_request
raise error_class(response.status, response.reason, body)
boto.elastictranscoder.exceptions.ValidationException: ValidationException: 400 Bad Request
{u'message': u'2 validation errors detected: Value null at \'container\' failed to satisfy constraint: Member must not be null; Value \'"Name":"preset","Description": "preset", "Container":"mp4","video": {"Codec":"H.264", "CodecOptions":{"Profile":"baseline", "Level":"3", "MaxReferenceFrames":"3"}, "KeyframesMaxDist":"200", "FixedGOP":"false", "BitRate":"600", "FrameRate":"10", "Resolution":"640x480", "AspectRatio":"4:3" },"audio": {"Codec":"AAC","CodecOptions":{"Profile":"AAC-LC"}, "SampleRate":"22050", "BitRate":"32", "Channels":"1" }, "thumbnails":{"Format":"png", "Interval":"60", "Resolution":"192x144", "AspectRatio":"4:3"}\' at \'name\' failed to satisfy constraint: Member must have length less than or equal to 40'}
此验证表明 'container' 为空!但它不是空的。
我很困惑发生了什么!
提前致谢
您可以使用 Python 中的 unpacking arg list 功能编写此代码:
preset_h264_480p_100kbs_mp4_command={ "name":"preset","description": "preset", "container":"mp4","video":
{"Codec":"H.264", "CodecOptions":{"Profile":"baseline", "Level":"3", "MaxReferenceFrames":"3"}, "KeyframesMaxDist":"200",
"FixedGOP":"false", "BitRate":"600", "FrameRate":"10", "Resolution":"640x480", "AspectRatio":"4:3" },"audio":
{"Codec":"AAC","CodecOptions":{"Profile":"AAC-LC"}, "SampleRate":"22050", "BitRate":"32", "Channels":"1" }, "thumbnails":
{"Format":"png", "Interval":"60", "Resolution":"192x144", "AspectRatio":"4:3"} }
transcode.create_preset(**preset_h264_480p_100kbs_mp4_command)