Reputation: 90
I am using Amazon Elastic transcoder and boto library to create a preset. This code works for me without any problem:
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"})
But, when I define a var with same value :
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"}'
I get into this error :
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'}
This validation is telling that the 'container' is null! But it is not null.
Upvotes: 1
Views: 164
Reputation: 1419
You can write this using unpacking arg list feature in Python:
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)
Upvotes: 2