Need help creating Job Settings for AWS MediaConvert in php - php

I have been trying to create a MediaConverter job using the latest AWS SDK for PHP (7.4.2) and I'm getting really stuck at creating the job settings correctly. I was wondering if anyone could look at this php code and tell me if I'm just completely on the wrong track. The response I'm getting is:
Error executing "CreateJob" on "https://asdf.mediaconvert.us-east-1.amazonaws.com/2017-08-29/jobs"; AWS HTTP error: Client error: POST https://asdf.mediaconvert.us-east-1.amazonaws.com/2017-08-29/jobs resulted in a 400 Bad Request response: { "errorType": "BadRequestException", "httpStatus" : 400, "requestId" : "388473f1-92af-4253-940c-00307b7c2a79", (truncated...) BadRequestException (client): The request could not be interpreted. - { "errorType": "BadRequestException", "httpStatus" : 400, "requestId" : "388473f1-92af-4253-940c-00307b7c2a79", "message" : "The request could not be interpreted.", "settingsValidationErrorsJsonBlob" : "" }
I actually copied the JSON for the settings directly out of MediaConvert, so I assume that my issue lies in trying to convert this into an object in PHP for the purposes of sending it to AWS. The settings below make it through the AWS SDK and up to the server, which I suppose is a good start. But I can't figure out what is wrong.
"OutputGroups" => [
[
"CustomName" => "Thumbnails",
"Name" => "File Group",
"Outputs" => [
"ContainerSettings" => [
"Container" => "RAW"
],
"VideoDescription" => [
"Width" => 1280,
"ScalingBehavior" => "DEFAULT",
"Height" => 720,
"TimecodeInsertion" => "DISABLED",
"AntiAlias" => "ENABLED",
"Sharpness" => 50,
"CodecSettings" => [
"Codec" => "FRAME_CAPTURE",
"FrameCaptureSettings" => [
"FramerateNumerator" => 30,
"FramerateDenominator" => 540,
"MaxCaptures" => 18,
"Quality" => 70
]
],
"DropFrameTimecode" => "ENABLED",
"ColorMetadata" => "INSERT"
],
["Extension" => "jpg"],
["NameModifier" => "-thumb"]
],
"OutputGroupSettings" => [
"Type" => "FILE_GROUP_SETTINGS",
"FileGroupSettings" => [
"Destination" => "s3://me/my-folder/"
]
]
],
[
"CustomName" => "720p",
"Name" => "File Group",
"Outputs" => [
"ContainerSettings" => [
"Container" => "MP4",
"Mp4Settings" => [
"CslgAtom" => "INCLUDE",
"CttsVersion" => 0,
"FreeSpaceBox" => "EXCLUDE",
"MoovPlacement" => "PROGRESSIVE_DOWNLOAD"
]
],
"VideoDescription" => [
"Width" => 1280,
"ScalingBehavior" => "DEFAULT",
"Height" => 720,
"VideoPreprocessors" => [
"ImageInserter" => [
"InsertableImages" => [
"Width" => 200,
"Height" => 36,
"imageX" => 50,
"imageY" => 634,
"FadeIn" => 2000,
"Layer" => 2,
"ImageInserterInput" => "s3://me-again/My-Watermark.tga",
"StartTime" => "00:00:05;01",
"Opacity" => 50
]
]
],
"TimecodeInsertion" => "DISABLED",
"AntiAlias" => "ENABLED",
"Sharpness" => 50,
"CodecSettings" => [
"Codec" => "H_264",
"H264Settings" => [
"InterlaceMode" => "PROGRESSIVE",
"NumberReferenceFrames" => 3,
"Syntax" => "DEFAULT",
"Softness" => 0,
"GopClosedCadence" => 1,
"GopSize" => 90,
"Slices" => 1,
"GopBReference" => "DISABLED",
"SlowPal" => "DISABLED",
"SpatialAdaptiveQuantization" => "ENABLED",
"TemporalAdaptiveQuantization" => "ENABLED",
"FlickerAdaptiveQuantization" => "DISABLED",
"EntropyEncoding" => "CABAC",
"Bitrate" => 1800000,
"FramerateControl" => "INITIALIZE_FROM_SOURCE",
"RateControlMode" => "CBR",
"CodecProfile" => "MAIN",
"Telecine" => "NONE",
"MinIInterval" => 0,
"AdaptiveQuantization" => "HIGH",
"CodecLevel" => "AUTO",
"FieldEncoding" => "PAFF",
"SceneChangeDetect" => "ENABLED",
"QualityTuningLevel" => "SINGLE_PASS",
"FramerateConversionAlgorithm" => "DUPLICATE_DROP",
"UnregisteredSeiTimecode" => "DISABLED",
"GopSizeUnits" => "FRAMES",
"ParControl" => "INITIALIZE_FROM_SOURCE",
"NumberBFramesBetweenReferenceFrames" => 2,
"RepeatPps" => "DISABLED",
"DynamicSubGop" => "STATIC"
]
],
"AfdSignaling" => "NONE",
"DropFrameTimecode" => "ENABLED",
"RespondToAfd" => "NONE",
"ColorMetadata" => "INSERT"
],
"AudioDescriptions" => [
"AudioTypeControl" => "FOLLOW_INPUT",
"AudioSourceName" => "Audio Selector 1",
"CodecSettings" => [
"Codec" => "AAC",
"AacSettings" => [
"AudioDescriptionBroadcasterMix" => "NORMAL",
"Bitrate" => 96000,
"RateControlMode" => "CBR",
"CodecProfile" => "LC",
"CodingMode" => "CODING_MODE_2_0",
"RawFormat" => "NONE",
"SampleRate" => 48000,
"Specification" => "MPEG4"
]
],
"LanguageCodeControl" => "FOLLOW_INPUT"
],
["Extension" => "mp4"],
["NameModifier" => "-720p"]
],
"OutputGroupSettings" => [
"Type" => "FILE_GROUP_SETTINGS",
"FileGroupSettings" => [
"Destination" => "s3://me/my-folder"
]
]
]
],
"AdAvailOffset" => 0,
"Inputs" => [
[
"AudioSelectors" => [
"Audio Selector 1" => [
"Offset" => 0,
"DefaultSelection" => "DEFAULT",
"ProgramSelection" => 1
]
],
"FilterEnable" => "AUTO",
"PsiControl" => "USE_PSI",
"FilterStrength" => 0,
"DeblockFilter" => "DISABLED",
"DenoiseFilter" => "DISABLED",
"TimecodeSource" => "EMBEDDED",
"FileInput" => "s3://me-again/my-folder/my-video.mp4"
]
],
"AccelerationSettings" => [
"Mode" => "DISABLED"
],
"StatusUpdateInterval" => "SECONDS_60",
"Priority" => 0
];```

I solved this.
I took the JSON that I got from MediaConvert and then I created my PHP in five steps:
Replace all { with array(
Replace all : with =>
Replace all [ with array(
Replace all } with )
Replace all ] with )
After doing this it worked perfectly, first time.

Related

Altering textFormat of a cell breaks hyperlinks in Google sheet

I'm creating a Google Sheet adding content like: =HYPERLINK("https://example.com","Example")
Which works fine until I try to alter the cell -> userEnteredFormat -> textFormat
Here's an example of broken links
Cell formatting works (see the second sheet).
If I change my config from
"cell" => [
"userEnteredFormat" => [
"backgroundColor" => [
"red" => 1.0,
"green" => 1.0,
"blue" => 1.0
],
"horizontalAlignment" => "LEFT",
"wrapStrategy" => "WRAP",
"textFormat" => [
"foregroundColor" => [
"red" => 0.0,
"green" => 0.0,
"blue" => 0.5
],
"fontSize" => 10,
"bold" => true
]
]
],
"fields" => "userEnteredFormat(backgroundColor,textFormat,horizontalAlignment,wrapStrategy)"
To
"cell" => [
"userEnteredFormat" => [
"backgroundColor" => [
"red" => 1.0,
"green" => 1.0,
"blue" => 1.0
],
"horizontalAlignment" => "LEFT",
"wrapStrategy" => "WRAP",
"textFormat" => [
]
]
],
"fields" => "userEnteredFormat(backgroundColor,textFormat,horizontalAlignment,wrapStrategy)"
The issue goes away.
I thought that from your request body, I thought that the reason of your issue might be due to fields. So, in your situation, how about modifying the value of fields as follows?
From:
"fields" => "userEnteredFormat(backgroundColor,textFormat,horizontalAlignment,wrapStrategy)"
To:
"fields" => "userEnteredFormat(backgroundColor,textFormat(foregroundColor,fontSize,bold),horizontalAlignment,wrapStrategy)"
Reference:
Method: spreadsheets.batchUpdate

Dynamic array into a static array

I have this static code today that works fine, now i need to make the
order line dynamic. The code is from a e-commerce store.
$order = [
"purchase_country" => "SE",
"purchase_currency" => "SEK",
"locale" => "sv-SE",
"order_amount" => 10000,
"order_tax_amount" => 2000,
"order_lines" => [
[
"type" => "physical",
"reference" => "123050",
"name" => "Tomatoes",
"quantity" => 10,
"quantity_unit" => "kg",
"unit_price" => 600,
"tax_rate" => 2500,
"total_amount" => 6000,
"total_tax_amount" => 1200
],
[
"type" => "physical",
"reference" => "543670",
"name" => "Bananas",
"quantity" => 1,
"quantity_unit" => "bag",
"unit_price" => 5000,
"tax_rate" => 2500,
"total_amount" => 4000,
"total_discount_amount" => 1000,
"total_tax_amount" => 800
]
],
"merchant_urls" => [
"terms" => "https://www.example.com/villkor.php",
"cancellation_terms" => "https://www.example.com/terms/cancellation.html",
"checkout" => "https://www.example.com/_script/checkout.php",
"confirmation" => "https://www.example.com/_script/checkout.php",
// Callbacks
"push" => "https://www.example.com/api/push",
"validation" => "https://www.example.com/api/validation",
"shipping_option_update" => "https://www.example.com/api/shipment",
"address_update" => "https://www.example.com/api/address",
"notification" => "https://www.example.com/api/pending",
"country_change" => "https://www.example.com/api/country"
]
];
Now I need to make order_lines dynamic.
I have tried this code:
$order = [
"purchase_country" => "SE",
"purchase_currency" => "SEK",
"locale" => "sv-SE",
"order_amount" => 10000,
"order_tax_amount" => 2000,
"order_lines" => [
$cartsql="select a, b, c, d from lux_cart WHERE status = 0 ORDER BY a DESC";
if ($result=mysqli_query($mysqli,$cartsql)){
while ($cartrow=mysqli_fetch_row($result)){
$itemid = $cartrow[0];
$prodTitel = $cartrow[1];
$antalcart = $cartrow[2];
$prodPris = $cartrow[3];
[
"type" => "physical",
"reference" => "$itemid",
"name" => "$prodTitel",
"quantity" => $antalcart,
"unit_price" => $prodPris,
"tax_rate" => 2500,
"total_amount" => $prodPris,
"total_tax_amount" => 1200
],
}
}
"merchant_urls" => [
"terms" => "https://www.example.com/villkor.php",
"cancellation_terms" => "https://www.example.com/terms/cancellation.html",
"checkout" => "https://www.example.com/_script/checkout.php",
"confirmation" => "https://www.example.com/_script/checkout.php",
// Callbacks
"push" => "https://www.example.com/api/push",
"validation" => "https://www.example.com/api/validation",
"shipping_option_update" => "https://www.example.com/api/shipment",
"address_update" => "https://www.example.com/api/address",
"notification" => "https://www.example.com/api/pending",
"country_change" => "https://www.example.com/api/country"
]
];
But the page broken without any error message. I think I need to make some array ore something to resolve this issue. Can someone help me figure out what I am doing wrong here?
You can't execute PHP code inside an array definition like that. That's causing a parse error that's the reason your page is broken with no error. (You can change settings on your development server to show these errors as well.) Instead, define the array with an empty array for order_lines
$order = [
"purchase_country" => "SE",
"purchase_currency" => "SEK",
"locale" => "sv-SE",
"order_amount" => 10000,
"order_tax_amount" => 2000,
"order_lines" => [],
"merchant_urls" => [
"terms" => "https://www.example.com/villkor.php",
"cancellation_terms" => "https://www.example.com/terms/cancellation.html",
"checkout" => "https://www.example.com/_script/checkout.php",
"confirmation" => "https://www.example.com/_script/checkout.php",
// Callbacks
"push" => "https://www.example.com/api/push",
"validation" => "https://www.example.com/api/validation",
"shipping_option_update" => "https://www.example.com/api/shipment",
"address_update" => "https://www.example.com/api/address",
"notification" => "https://www.example.com/api/pending",
"country_change" => "https://www.example.com/api/country"
]
];
Then fill that key with values from your query.
$cartsql="select a, b, c, d from lux_cart WHERE status = 0 ORDER BY a DESC";
if ($result=mysqli_query($mysqli,$cartsql)){
while ($cartrow=mysqli_fetch_row($result)){
$itemid = $cartrow[0];
$prodTitel = $cartrow[1];
$antalcart = $cartrow[2];
$prodPris = $cartrow[3];
// Use [] to append the rows to the existing key
$order['order_lines'][] = [
"type" => "physical",
"reference" => "$itemid",
"name" => "$prodTitel",
"quantity" => $antalcart,
"unit_price" => $prodPris,
"tax_rate" => 2500,
"total_amount" => $prodPris,
"total_tax_amount" => 1200
];
}
}

Unexpected token while deserializing object: when using Click and Drop API - Royal Mail

I am making a POST request to create an order for Royal Mail Click and Drop:
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'Authorization' => 'Bearer secret-123'
])->post('https://api.parcel.royalmail.com/api/v1/orders/', [
'items' => [
'recipient' => [
'address' => [
"fullName" => 'Tom',
"companyName" => "Test",
"addressLine1" => "150",
"addressLine2" => "Valley Close",
"addressLine3" => "Elmdom",
"city" => "Birmingham",
"county" => "West Midlands",
"postcode" => "B12 2YT",
"countryCode" => "GB"
],
"emailAddress" => "test#test.com"
],
"billing" => [
"address" => [
"fullName" => 'Tom',
"companyName" => "Test",
"addressLine1" => "150",
"addressLine2" => "Valley Close",
"addressLine3" => "Elmdom",
"city" => "Birmingham",
"county" => "West Midlands",
"postcode" => "B12 2YT",
"countryCode" => "GB"
],
"phoneNumber" => "42425 5252552",
"emailAddress" => "test#test.com"
],
"orderDate" => "2021-05-18T16:39:01Z",
"subtotal" => 0,
"shippingCostCharged" => 0,
"total" => 0,
]
])->json();
dd($response);
but keep getting
'Unexpected token while deserializing object: PropertyName. Path 'items.recipient', line 1, position 22. Failed to deserialize following order request'
I keep getting the same error for all required fields...
API docs do not provide much details https://api.parcel.royalmail.com/. The same payload works in Insomnia. I am using Laravel Http client.
The API shows that items is an array of objects.
items": [
{
"orderReference": "string",
"recipient": {},
"sender": {},
"billing": {},
"packages": [],
"orderDate": "2019-08-24T14:15:22Z",
"plannedDespatchDate": "2019-08-24T14:15:22Z",
"specialInstructions": "string",
"subtotal": 0,
"shippingCostCharged": 0,
"otherCosts": 0,
"customsDutyCosts": 0,
"total": 0,
"currencyCode": "str",
"postageDetails": {},
"tags": [],
"label": {}
}
]
So you just need to wrap everything in items in another set of brackets.
$response = Http::withHeaders([
'Content-Type' => 'application/json',
'Authorization' => 'Bearer secret-123'
])->post('https://api.parcel.royalmail.com/api/v1/orders/', [
'items' => [[
'recipient' => [
'address' => [
"fullName" => 'Tom',
"companyName" => "Test",
"addressLine1" => "150",
"addressLine2" => "Valley Close",
"addressLine3" => "Elmdom",
"city" => "Birmingham",
"county" => "West Midlands",
"postcode" => "B12 2YT",
"countryCode" => "GB"
],
"emailAddress" => "test#test.com"
],
"billing" => [
"address" => [
"fullName" => 'Tom',
"companyName" => "Test",
"addressLine1" => "150",
"addressLine2" => "Valley Close",
"addressLine3" => "Elmdom",
"city" => "Birmingham",
"county" => "West Midlands",
"postcode" => "B12 2YT",
"countryCode" => "GB"
],
"phoneNumber" => "42425 5252552",
"emailAddress" => "test#test.com"
],
"orderDate" => "2021-05-18T16:39:01Z",
"subtotal" => 0,
"shippingCostCharged" => 0,
"total" => 0,
]]
])->json();

PHP MongoDB\Client updateOne add new field to existing document array

I'm struggling to update a document and add new elements (fields) into it's existing array without losing the array elements on update.
This is my code which inserts a new document into the collection if it doesn't already exist (upsert):
$updateResult = $collection->findOneAndUpdate(
[
'recording-id' => $out['recording']->id
],
['$set' => [
'release' => [
'id' => $out['release']->id,
'title' => $out['release']->title,
'date' => $out['release']->date,
'country' => $out['release']->country
],
'artist' => [
'id' => $out['artist']->id,
'name' => $out['artist']->name,
],
'recording' => [
'id' => $out['recording']->id,
'title' => $out['recording']->title,
'score' => $out['recording']->score,
'length' => $out['recording']->length,
'release-count' => count($out['recording']->releases),
],
'release-group' => [
'id' => $out['release-group']['id'],
'title' => $out['release-group']['title'],
'first-release-date'=>$out['release-group']['first-release-date'],
'primary-type' => $out['release-group']['primary-type'],
'musicbrainz' => $out['release-group']['musicbrainz'],
'url-rels' => $out['release-group']['url-rels'],
'coverart' => $out['release-group']['coverart']
],
'execution' => [
'firstfind' => $out['execution']->time
]
]
],
['upsert' => true,
'projection' =>
[
'_id' => 0,
'release' => 1,
'artist' => 1,
'recording' => 1,
'release-group' => 1,
'execution' => 1
],
'returnDocument' => MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER,
]
);
So now I have an existing document in a collection:
{
"_id" : ObjectId("5d1a6aaf5ecc8001ee858f6c"),
"recording-id" : "d0d439f9-5324-4728-8706-2da39adb89c5",
"artist" : {
"id" : "9d97b077-b28d-4ba8-a3d9-c71926e3b2b6",
"name" : "Gordon Lightfoot"
},
"recording" : {
"id" : "d0d439f9-5324-4728-8706-2da39adb89c5",
"title" : "Sundown",
"score" : 100,
"length" : 184000,
"release-count" : 2
},
"release" : {
"id" : "0c008d76-2bc9-44a3-854b-0a08cde89337",
"title" : "All Live",
"date" : "2012-04-24",
"country" : "CA"
},
"release-group" : {
"id" : "0a5d5f33-8e9d-4fa4-b622-a95e4218a3c4",
"title" : "All Live",
"first-release-date" : "2012-04-24",
"primary-type" : "Album",
"musicbrainz" : "https://musicbrainz.org/release-group/0a5d5f33-8e9d-4fa4-b622-a95e4218a3c4",
"url-rels" : "https://musicbrainz.org/ws/2/release-group/0a5d5f33-8e9d-4fa4-b622-a95e4218a3c4?inc=url-rels&fmt=json",
"coverart" : null
}
}
Now, I would like to update this document, and add new fields into the arrays. The new fields are to be added to certain fields.
Here is the code doing that:
$collection = (new MongoDB\Client)->stream->musicbrainz;
$updateResult = $collection->updateOne(
[
'recording-id' => $out['recording']['id']
],
['$addToSet' => [
'artist' => [
'wikiQiD' => $out['artist']['qid'],
'wiki-extract' => $out['artist']['wiki-extract'],
'wiki-pageid' => $out['artist']['pageid'],
],
'release-group' => [
'wikiQiD' => $out['release-group']['qid'],
'wiki-extract' => $out['release-group']['wiki-extract']
]
]
],
[
'upsert' => true,
'returnDocument' => MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER,
]
);
I've noticed there's "$addToSet" and "$push" commands, and could use assistance with what the difference is between these two commands.
If the field is absent in the document to update, $push adds the array
field with the value as its element.
The $addToSet operator adds a value to an array unless the value is
already present, in which case $addToSet does nothing to that array.
I did some googling, and reading of the MongoDB/Client UpdateOne function, but can't seem to find a way to append these fields to the existing arrays.
The error I'm getting is:
Fatal error: Uncaught MongoDB\Driver\Exception\BulkWriteException: The field 'artist' must be an array but is of type object in document {_id: ObjectId('5d1a6aaf5ecc8001ee858f6c')} in ...
I know the following:
It could be my document, as it's not a proper array that Fatal error is complaining about.
It could be my `findOneAndUpdate' formatting, and I'm not doing that correctly.
It could be both and I have it all wrong from the very start.
Any insight or constructive criticism is appreciated, just refrain from flames, pls.
Here's the working code I finally use to get it do what I want it to.
It's a simple matter of just setting your field names and values and mongo will update the found record replacing it with the array sent to it. No need to push or anything.
function firstFindMongoUpdate($out) {
$collection = (new MongoDB\Client)->stream->musicbrainz;
$updateResult = $collection->findOneAndUpdate(
[
'recording-id' => $out['recording']->id
],
['$set' => [
'query' => $out['query'],
'release' => [
'id' => $out['release']->id,
'title' => $out['release']->title,
'date' => $out['release']->date,
'country' => $out['release']->country,
'label' => $out['release']->label,
],
'artist' => [
'id' => $out['artist']->id,
'name' => $out['artist']->name,
'wiki' => $out['artist']->wiki,
],
'recording' => [
'id' => $out['recording']->id,
'title' => $out['recording']->title, // sometimes contains apostophe ie; Bill‘s Love (option ] key)
'score' => $out['recording']->score,
'length' => $out['recording']->length,
'release-count' => count($out['recording']->releases)
],
'release-group' => [
'id' => $out['release-group']['id'],
'title' => $out['release-group']['title'],
'first-release-date'=>$out['release-group']['first-release-date'],
'primary-type' => $out['release-group']['primary-type'],
'musicbrainz' => $out['release-group']['musicbrainz'],
'url-rels' => $out['release-group']['url-rels'],
'coverart' => $out['release-group']['coverart'],
'wiki' => $out['release-group']['wiki']
],
'execution' => [
'artistQuery' => $out['execution']->artistQuery,
'recordingQuery'=> $out['execution']->recordingQuery,
'time' => $out['execution']->time
]
]
],
['upsert' => true,
'projection' =>
[
'_id' => 1,
'query' => 1,
'release' => 1,
'artist' => 1,
'recording' => 1,
'release-group' => 1,
'execution' => 1
],
'returnDocument' => MongoDB\Operation\FindOneAndUpdate::RETURN_DOCUMENT_AFTER,
]
);

Elastic Transcoder error "Start of list found where not expected"

I am trying to use ElasticTranscoderPHP to create a new preset with php, but I am getting the error "start of list found where not expected"
https://github.com/LPology/ElasticTranscoderPHP
What would cause this error?
$photo_info = getimagesize($_FILES["photo-file"]['tmp_name']);
$photo_width = $photo_info[0];
$photo_height = $photo_info[1];
$options = array(
"Name" => $vivaloo_id,
"Description" => "testing 123",
"Container" => "mp4",
"Audio" => array(
"Codec" => "AAC",
"CodecOptions" => array(
"Profile" => "AAC-LC"
),
"SampleRate" => "44100",
"BitRate" => "128",
"Channels" => "2",
),
"Video" => array(
"Codec" => "H.264",
"CodecOptions" => array(
"Profile" => "baseline",
"Level" => "3",
"MaxReferenceFrames" => "3"
),
"KeyframesMaxDist" => "90",
"FixedGOP" => "false",
"BitRate" => "600",
"FrameRate" => "29.97",
"MaxWidth" => $photo_width,
"MaxHeight" => $photo_height,
"SizingPolicy" => "Fill",
"PaddingPolicy" => "NoPad",
"DisplayAspectRatio" => "auto"
),
"Thumbnails" => array(
"Format" => "jpg",
"Interval" => "9999",
"MaxWidth" => "480",
"MaxHeight" => "480",
"SizingPolicy" => "Fit",
"PaddingPolicy" => "NoPad"
)
);
$presetResult = AWS_ET::createPreset( array($options) );
if (!$presetResult) {
echo AWS_ET::getErrorMsg();
}else{
echo 'New preset ID: ';
}
Answering my own question - hope it helps others...
I ultimately solved this issue by separating Audio, Video, and Thumbs settings into their own individual arrays. Here is an example:
//create a preset
$presetAudio = array(
"Codec" => "AAC",
"CodecOptions" => array( "Profile" => "AAC-LC"),
"SampleRate" => "32000",
"BitRate" => "64",
"Channels" => "2"
);
$presetVideo = array(
"Codec" => "H.264",
"CodecOptions" => array("Profile" => "baseline","Level" => "3","MaxReferenceFrames" => "3","BufferSize" => null, "MaxBitRate" => null),
"KeyframesMaxDist" => "90",
"FixedGOP" => "false",
"BitRate" => "500",
"FrameRate" => "29.97",
"MaxFrameRate" => null,
"MaxWidth" => "500", //note: MUST BE AN EVEN NUMBER
"MaxHeight" => "500", //note: MUST BE AN EVEN NUMBER
"SizingPolicy" => "Fill",
"PaddingPolicy" => "NoPad",
"DisplayAspectRatio" => "auto"
);
$presetThumbs = array(
"Format" => "jpg",
"Interval" => "9999",
"MaxWidth" => "100", //note: MUST BE AN EVEN NUMBER
"MaxHeight" => "100", //note: MUST BE AN EVEN NUMBER
"SizingPolicy" => "Fit",
"PaddingPolicy" => "NoPad"
);
$presetResult = AWS_ET::createPreset("name of preset", "description of preset", "mp4", $presetAudio, $presetVideo, $presetThumbs);
if (!$presetResult) {
echo AWS_ET::getErrorMsg();
} else {
$preset_id = $presetResult['Preset']['Id'];
echo $preset_id;
}

Categories