2018-10-11 15:00:23 -07:00
< ? php
2018-12-28 10:35:52 -08:00
// Copyright Amazon.com, Inc. or its affiliates. All Rights Reserved.
2018-10-11 15:00:23 -07:00
// SPDX-License-Identifier: Apache-2.0
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
/*
* 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
*
2019-02-01 20:05:05 -08:00
*
*
2018-10-11 15:00:23 -07:00
*/
2019-02-01 20:05:05 -08:00
// snippet-start:[mediaconvert.php.create_job.complete]
// snippet-start:[mediaconvert.php.create_job.import]
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
require 'vendor/autoload.php' ;
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
use Aws\Exception\AwsException ;
2021-01-07 22:52:19 +09:00
use Aws\MediaConvert\MediaConvertClient ;
2024-02-05 10:49:20 -07:00
2019-02-01 20:05:05 -08:00
// snippet-end:[mediaconvert.php.create_job.import]
2024-02-05 10:49:20 -07:00
2018-10-11 15:00:23 -07:00
/**
* 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
*/
2024-02-05 10:49:20 -07:00
2021-01-07 22:52:19 +09:00
//Create an AWSMediaConvert client object with your account specific endpoint.
2019-02-02 16:23:37 -08:00
// snippet-start:[mediaconvert.php.create_job.region]
2018-10-11 15:00:23 -07:00
$mediaConvertClient = new MediaConvertClient ([
'version' => '2017-08-29' ,
'region' => 'us-east-2' ,
2024-05-15 11:26:06 -04:00
'profile' => 'default'
2018-10-11 15:00:23 -07:00
]);
2019-02-02 16:23:37 -08:00
// snippet-end:[mediaconvert.php.create_job.region]
// snippet-start:[mediaconvert.php.create_job.jobsettings]
2018-10-11 15:00:23 -07:00
$jobSetting = [
" OutputGroups " => [
[
" Name " => " File Group " ,
" OutputGroupSettings " => [
" Type " => " FILE_GROUP_SETTINGS " ,
" FileGroupSettings " => [
" Destination " => " s3://OUTPUT_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 "
]
]
2024-02-05 10:49:20 -07:00
]
2018-10-11 15:00:23 -07:00
],
" AdAvailOffset " => 0 ,
" Inputs " => [
[
" AudioSelectors " => [
" Audio Selector 1 " => [
" Offset " => 0 ,
" DefaultSelection " => " NOT_DEFAULT " ,
" ProgramSelection " => 1 ,
" SelectorType " => " TRACK " ,
" Tracks " => [
1
]
2024-02-05 10:49:20 -07:00
]
2018-10-11 15:00:23 -07:00
],
" VideoSelector " => [
" ColorSpace " => " FOLLOW "
],
" FilterEnable " => " AUTO " ,
" PsiControl " => " USE_PSI " ,
" FilterStrength " => 0 ,
" DeblockFilter " => " DISABLED " ,
" DenoiseFilter " => " DISABLED " ,
" TimecodeSource " => " EMBEDDED " ,
" FileInput " => " s3://INPUT_BUCKET_AND_FILE_NAME "
]
],
" TimecodeConfig " => [
" Source " => " EMBEDDED "
]
2021-01-07 22:52:19 +09:00
];
2019-02-02 16:23:37 -08:00
// snippet-end:[mediaconvert.php.create_job.jobsettings]
// snippet-start:[mediaconvert.php.create_job.main]
2018-10-11 15:00:23 -07:00
try {
$result = $mediaConvertClient -> createJob ([
" Role " => " IAM_ROLE_ARN " ,
" Settings " => $jobSetting , //JobSettings structure
" Queue " => " JOB_QUEUE_ARN " ,
" UserMetadata " => [
" Customer " => " Amazon "
],
]);
} catch ( AwsException $e ) {
// output error message if fails
echo $e -> getMessage ();
echo " \n " ;
2021-01-07 22:52:19 +09:00
}
2024-02-05 10:49:20 -07:00
2019-02-01 20:05:05 -08:00
// snippet-end:[mediaconvert.php.create_job.main]
2021-01-07 22:52:19 +09:00
// snippet-end:[mediaconvert.php.create_job.complete]