forked from awsdocs/aws-doc-sdk-examples
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCreateJobTemplate.php
More file actions
237 lines (226 loc) · 9.88 KB
/
CreateJobTemplate.php
File metadata and controls
237 lines (226 loc) · 9.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
<?php
/**
* Copyright 2010-2019 Amazon.com, Inc. or its affiliates. All Rights Reserved.
*
* This file is licensed under the Apache License, Version 2.0 (the "License").
* You may not use this file except in compliance with the License. A copy of
* the License is located at
*
* http://aws.amazon.com/apache2.0/
*
* This file is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
* CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* ABOUT THIS PHP SAMPLE => This sample is part of the SDK for PHP Developer Guide topic at
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/emc-examples-jobs.html
*
*
*
*/
// snippet-start:[mediaconvert.php.create_job_template.complete]
// snippet-start:[mediaconvert.php.create_job_template.import]
require 'vendor/autoload.php';
use Aws\MediaConvert\MediaConvertClient;
use Aws\Exception\AwsException;
// snippet-end:[mediaconvert.php.create_job_template.import]
/**
* Create a Job for AWS Elemental MediaConvert.
*
* This code expects that you have AWS credentials set up per:
* https://docs.aws.amazon.com/sdk-for-php/v3/developer-guide/guide_credentials.html
*/
//Create an AWSMediaConvert client object with your account specific endpoint.
// snippet-start:[mediaconvert.php.create_job_template.main]
$mediaConvertClient = new MediaConvertClient([
'version' => '2017-08-29',
'region' => 'us-east-2',
'profile' => 'default',
'endpoint' => 'ACCOUNT_ENDPOINT'
]);
$jobTemplate = [
"Settings" => [
"OutputGroups" => [
[
"Name" => "File Group",
"OutputGroupSettings" => [
"Type" => "FILE_GROUP_SETTINGS",
"FileGroupSettings" => [
"Destination" => "s3://BUCKET_NAME/"
]
],
"Outputs" => [
[
"VideoDescription" => [
"ScalingBehavior" => "DEFAULT",
"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" => 5000000,
"FramerateControl" => "SPECIFIED",
"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" => "SPECIFIED",
"NumberBFramesBetweenReferenceFrames" => 2,
"RepeatPps" => "DISABLED",
"FramerateNumerator" => 30,
"FramerateDenominator" => 1,
"ParNumerator" => 1,
"ParDenominator" => 1
]
],
"AfdSignaling" => "NONE",
"DropFrameTimecode" => "ENABLED",
"RespondToAfd" => "NONE",
"ColorMetadata" => "INSERT"
],
"AudioDescriptions" => [
[
"AudioTypeControl" => "FOLLOW_INPUT",
"CodecSettings" => [
"Codec" => "AAC",
"AacSettings" => [
"AudioDescriptionBroadcasterMix" => "NORMAL",
"RateControlMode" => "CBR",
"CodecProfile" => "LC",
"CodingMode" => "CODING_MODE_2_0",
"RawFormat" => "NONE",
"SampleRate" => 48000,
"Specification" => "MPEG4",
"Bitrate" => 64000
]
],
"LanguageCodeControl" => "FOLLOW_INPUT",
"AudioSourceName" => "Audio Selector 1"
]
],
"ContainerSettings" => [
"Container" => "MP4",
"Mp4Settings" => [
"CslgAtom" => "INCLUDE",
"FreeSpaceBox" => "EXCLUDE",
"MoovPlacement" => "PROGRESSIVE_DOWNLOAD"
]
],
"NameModifier" => "_1"
]
]
]
],
"AdAvailOffset" => 0,
"Inputs" => [
[
"AudioSelectors" => [
"Audio Selector 1" => [
"Offset" => 0,
"DefaultSelection" => "NOT_DEFAULT",
"ProgramSelection" => 1,
"SelectorType" => "TRACK",
"Tracks" => [
1
]
]
],
"VideoSelector" => [
"ColorSpace" => "FOLLOW"
],
"FilterEnable" => "AUTO",
"PsiControl" => "USE_PSI",
"FilterStrength" => 0,
"DeblockFilter" => "DISABLED",
"DenoiseFilter" => "DISABLED",
"TimecodeSource" => "EMBEDDED",
]
],
"TimecodeConfig" => [
"Source" => "EMBEDDED"
]
]
];
try [
$result = $mediaConvertClient->createJob([
Category => 'YouTube Jobs',
Description => 'Final production transcode',
Name => 'DemoTemplate',
Queue => 'JOB_QUEUE_ARN',
"JobTemplate" => , //String either a job template or the transcoding settings
"Role" => "IAM_ROLE_ARN" ,
"Settings" => $jobSetting , //JobSettings structure
"Queue" => 'JOB_QUEUE_ARN',
]);
]catch (AwsException $e) [
// output error message if fails
echo $e->getMessage();
echo "\n";
]
try [$result = $mediaConvertClient->createJob([
"Queue" => "QUEUE_ARN",
"JobTemplate" => "TEMPLATE_NAME",
"Role" => "ROLE_ARN",
"Settings" => [
"Inputs" => [
[
"AudioSelectors" => [
"Audio Selector 1" => [
"Offset" => 0,
"DefaultSelection" => "NOT_DEFAULT",
"ProgramSelection" => 1,
"SelectorType" => "TRACK",
"Tracks" => [
1
]
]
],
"VideoSelector" => [
"ColorSpace" => "FOLLOW"
],
"FilterEnable" => "AUTO",
"PsiControl" => "USE_PSI",
"FilterStrength" => 0,
"DeblockFilter" => "DISABLED",
"DenoiseFilter" => "DISABLED",
"TimecodeSource" => "EMBEDDED",
"FileInput" => "s3://BUCKET_NAME/FILE_NAME"
]
]
]
];
// snippet-end:[mediaconvert.php.create_job_template.main]
// snippet-end:[mediaconvert.php.create_job_template.complete]
// snippet-comment:[These are tags for the AWS doc team's sample catalog. Do not remove.]
// snippet-sourcedescription:[CreateJobTemplate.php demonstrates how to create template that can be used to create a AWS Elemental MediaConvert Job.]
// snippet-keyword:[PHP]
// snippet-sourcesyntax:[php]
// snippet-keyword:[AWS SDK for PHP v3]
// snippet-keyword:[Code Sample]
// snippet-keyword:[AWS Elemental MediaConvert]
// snippet-service:[mediaconvert]
// snippet-sourcetype:[full-example]
// snippet-sourcedate:[2018-09-20]
// snippet-sourceauthor:[jschwarzwalder (AWS)]