Last active
September 8, 2021 18:27
-
-
Save pahud/1ec32d3c62e7c6e0fe2291649400fa1b to your computer and use it in GitHub Desktop.
AWS CLI sample for Elemental MediaConvert create-job actions
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# Usage: bash create-job.sh S3_INPUT_VIDEO_FILE_PATH | |
# e.g. bash create-job.sh s3://your-s3-bucket/your-input-video.mov | |
input=$1 | |
basename=$(basename $input) | |
newbasename="${basename%%.*}-H264-AAC.mp4" | |
output="$(dirname $input)/$newbasename" | |
echo "[INFO] converting to $output" | |
region='ap-northeast-1' | |
endpoint=$(aws mediaconvert describe-endpoints --region $region --query 'Endpoints[0].Url' --output text) | |
role='arn:aws:iam::112233445566:role/MediaCovertRole' | |
# build the settings.json | |
jq -n \ | |
--arg FILEINPUT $input \ | |
--arg FILEOUTPUT $output \ | |
-f settings.skeleton.json > settings.json | |
# create-job with settings.json as the cli-input-json | |
aws --region $region mediaconvert create-job \ | |
--role $role \ | |
--cli-input-json file://settings.json \ | |
--endpoint-url $endpoint \ | |
--client-request-token "client-request-token-${RANDOM}" | |
echo "[INFO] converting to $output" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AccelerationSettings": { | |
"Mode": "ENABLED" | |
}, | |
"BillingTagsSource": "PRESET", | |
"ClientRequestToken": "", | |
"JobTemplate": "", | |
"Queue": "", | |
"Role": "", | |
"Settings": { | |
"AdAvailOffset": 0, | |
"Inputs": [ | |
{ | |
"AudioSelectors": { | |
"Audio Selector 1": { | |
"Offset": 0, | |
"DefaultSelection": "DEFAULT", | |
"ProgramSelection": 1 | |
} | |
}, | |
"VideoSelector": { | |
"ColorSpace": "FOLLOW", | |
"Rotate": "DEGREE_0" | |
}, | |
"FilterEnable": "AUTO", | |
"PsiControl": "USE_PSI", | |
"FilterStrength": 0, | |
"DeblockFilter": "DISABLED", | |
"DenoiseFilter": "DISABLED", | |
"TimecodeSource": "ZEROBASED", | |
"FileInput": $FILEINPUT | |
} | |
], | |
"NielsenConfiguration": { | |
"BreakoutCode": 0, | |
"DistributorId": "" | |
}, | |
"OutputGroups": [ | |
{ | |
"CustomName": "", | |
"Name": "", | |
"OutputGroupSettings": { | |
"Type": "FILE_GROUP_SETTINGS", | |
"FileGroupSettings": { | |
"Destination": $FILEOUTPUT | |
} | |
}, | |
"Outputs": [ | |
{ | |
"AudioDescriptions": [ | |
{ | |
"AudioTypeControl": "FOLLOW_INPUT", | |
"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" | |
} | |
], | |
"ContainerSettings": { | |
"Container": "MP4", | |
"Mp4Settings": { | |
"CslgAtom": "INCLUDE", | |
"FreeSpaceBox": "EXCLUDE", | |
"MoovPlacement": "PROGRESSIVE_DOWNLOAD", | |
"Mp4MajorBrand": "" | |
} | |
}, | |
"Extension": "", | |
"OutputSettings": { | |
"HlsSettings": { | |
"AudioGroupId": "", | |
"AudioOnlyContainer": "AUTOMATIC", | |
"AudioRenditionSets": "", | |
"AudioTrackType": "AUDIO_ONLY_VARIANT_STREAM", | |
"IFrameOnlyManifest": "EXCLUDE", | |
"SegmentModifier": "" | |
} | |
}, | |
"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", | |
"MaxBitrate": 1500000, | |
"SlowPal": "DISABLED", | |
"SpatialAdaptiveQuantization": "ENABLED", | |
"TemporalAdaptiveQuantization": "ENABLED", | |
"FlickerAdaptiveQuantization": "DISABLED", | |
"EntropyEncoding": "CABAC", | |
"Bitrate": 1500000, | |
"FramerateControl": "INITIALIZE_FROM_SOURCE", | |
"RateControlMode": "VBR", | |
"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" | |
} | |
} | |
] | |
} | |
], | |
"TimecodeConfig": { | |
"Source": "ZEROBASED" | |
} | |
}, | |
"StatusUpdateInterval": "SECONDS_60", | |
"UserMetadata": { | |
"KeyName": "" | |
} | |
} |
submit a single inputFile from existing job template
- create your favorite job template from console and name it, let's say 'my-h265-template'
- prepare your iam role
- upload your video to s3 bucket
- run command below
region=ap-northeast-1
endpoint=$(aws mediaconvert describe-endpoints --region $region --query 'Endpoints[0].Url' --output text)
role='arn:aws:iam::112233445566:role/MediaCovertRole'
templateName='my-h265-template'
inputFile='s3://YOUR-BUCKET-NAME/filename.MP4'
# create a job from the template
aws --region $region mediaconvert create-job \
--job-template $templateName \
--role $role \
--setting "{\"Inputs\": [{\"FileInput\": \"$inputFile\"}]}" \
--endpoint-url $endpoint
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Awesome. Just what I was looking for!