AWS code-library documentation change
Summary
Simplified MediaConvert job creation example by removing multiple output profiles (HLS low/medium/high, thumbnails) and complex codec configurations. Added endpoint resolution logic and streamlined output to a single MP4 file group with basic H264 settings.
Security assessment
The changes focus on code simplification and configuration optimization rather than addressing security vulnerabilities. While output destination paths were modified (fileInputVal -> fileInput1, output/ folder), there's no evidence of security controls like encryption, access policies, or authentication mechanisms being added/modified. The quality level reduction (qvbrQualityLevel 8->7) and bitrate changes are performance/quality tradeoffs.
Diff
diff --git a/code-library/latest/ug/mediaconvert_example_mediaconvert_CreateJob_section.md b/code-library/latest/ug/mediaconvert_example_mediaconvert_CreateJob_section.md index c2478c3dd..88f868be5 100644 --- a//code-library/latest/ug/mediaconvert_example_mediaconvert_CreateJob_section.md +++ b//code-library/latest/ug/mediaconvert_example_mediaconvert_CreateJob_section.md @@ -1054 +1054 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - fileInputVal: String, + fileInput1: String, @@ -1056,7 +1056,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - val s3path = fileInputVal.substring(0, fileInputVal.lastIndexOf('/') + 1) + "javasdk/out/" - val fileOutput = s3path + "index" - val thumbsOutput = s3path + "thumbs/" - val mp4Output = s3path + "mp4/" - - try { - val describeEndpoints = + // Step 1: Describe endpoints to get the MediaConvert endpoint URL + val describeResponse = mcClient.describeEndpoints( @@ -1064,2 +1059,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - maxResults = 20 - } + maxResults = 1 + }, + ) @@ -1067,8 +1063,5 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - val res = mcClient.describeEndpoints(describeEndpoints) - if (res.endpoints?.size!! <= 0) { - println("Cannot find MediaConvert service endpoint URL!") - exitProcess(0) - } - val endpointURL = res.endpoints!!.get(0).url!! - val mediaConvert = - MediaConvertClient.fromEnvironment { + val endpointUrl = describeResponse.endpoints?.firstOrNull()?.url + ?: error("No MediaConvert endpoint found") + + // Step 2: Create MediaConvert client with resolved endpoint + val mediaConvert = MediaConvertClient.fromEnvironment { @@ -1076,3 +1069,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - endpointProvider = - MediaConvertEndpointProvider { - Endpoint(endpointURL) + endpointProvider = MediaConvertEndpointProvider { + Endpoint(endpointUrl) @@ -1082,8 +1074,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - // output group Preset HLS low profile - val hlsLow = createOutput("_low", "_\$dt$", 750000, 7, 1920, 1080, 640) - - // output group Preset HLS medium profile - val hlsMedium = createOutput("_medium", "_\$dt$", 1200000, 7, 1920, 1080, 1280) - - // output group Preset HLS high profole - val hlsHigh = createOutput("_high", "_\$dt$", 3500000, 8, 1920, 1080, 1920) + // Output destination folder in S3 - put in 'output/' folder beside input + val outputDestination = fileInput1.substringBeforeLast('/') + "/output/" @@ -1091,18 +1077,10 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - val outputSettings = - OutputGroupSettings { - type = OutputGroupType.HlsGroupSettings - } - - val outputObsList: MutableList<Output> = mutableListOf() - if (hlsLow != null) { - outputObsList.add(hlsLow) - } - if (hlsMedium != null) { - outputObsList.add(hlsMedium) - } - if (hlsHigh != null) { - outputObsList.add(hlsHigh) - } - - // Create an OutputGroup object. - val appleHLS = + // Step 3: Create the job request with minimal valid video codec settings + val jobRequest = CreateJobRequest { + role = mcRoleARN + settings = JobSettings { + inputs = listOf( + Input { + fileInput = fileInput1 + }, + ) + outputGroups = listOf( @@ -1110,25 +1088,4 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - name = "Apple HLS" - customName = "Example" - outputGroupSettings = - OutputGroupSettings { - type = OutputGroupType.HlsGroupSettings - this.hlsGroupSettings = - HlsGroupSettings { - directoryStructure = HlsDirectoryStructure.SingleDirectory - manifestDurationFormat = HlsManifestDurationFormat.Integer - streamInfResolution = HlsStreamInfResolution.Include - clientCache = HlsClientCache.Enabled - captionLanguageSetting = HlsCaptionLanguageSetting.Omit - manifestCompression = HlsManifestCompression.None - codecSpecification = HlsCodecSpecification.Rfc4281 - outputSelection = HlsOutputSelection.ManifestsAndSegments - programDateTime = HlsProgramDateTime.Exclude - programDateTimePeriod = 600 - timedMetadataId3Frame = HlsTimedMetadataId3Frame.Priv - timedMetadataId3Period = 10 - destination = fileOutput - segmentControl = HlsSegmentControl.SegmentedFiles - minFinalSegmentLength = 0.toDouble() - segmentLength = 4 - minSegmentLength = 1 - } + outputGroupSettings = OutputGroupSettings { + type = OutputGroupType.FileGroupSettings + fileGroupSettings = FileGroupSettings { + destination = outputDestination @@ -1136 +1092,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - outputs = outputObsList @@ -1138,2 +1094 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - - val theOutput = + outputs = listOf( @@ -1141,4 +1096,2 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - extension = "mp4" - containerSettings = - ContainerSettings { - container = ContainerType.fromValue("MP4") + containerSettings = ContainerSettings { + container = ContainerType.Mp4 @@ -1146,3 +1099 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - - videoDescription = - VideoDescription { + videoDescription = VideoDescription { @@ -1151,10 +1102 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - scalingBehavior = ScalingBehavior.Default - sharpness = 50 - antiAlias = AntiAlias.Enabled - timecodeInsertion = VideoTimecodeInsertion.Disabled - colorMetadata = ColorMetadata.Insert - respondToAfd = RespondToAfd.None - afdSignaling = AfdSignaling.None - dropFrameTimecode = DropFrameTimecode.Enabled - codecSettings = - VideoCodecSettings { + codecSettings = VideoCodecSettings { @@ -1162,2 +1104 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - h264Settings = - H264Settings { + h264Settings = H264Settings { @@ -1165,3 +1106,4 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - parControl = H264ParControl.InitializeFromSource - qualityTuningLevel = H264QualityTuningLevel.SinglePass - qvbrSettings = H264QvbrSettings { qvbrQualityLevel = 8 } + qvbrSettings = H264QvbrSettings { + qvbrQualityLevel = 7 + } + maxBitrate = 5_000_000 @@ -1170 +1111,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - maxBitrate = 2400000 @@ -1172,109 +1112,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - gopSize = 2.0 - gopSizeUnits = H264GopSizeUnits.Seconds - numberBFramesBetweenReferenceFrames = 2 - gopClosedCadence = 1 - gopBReference = H264GopBReference.Disabled - slowPal = H264SlowPal.Disabled - syntax = H264Syntax.Default - numberReferenceFrames = 3 - dynamicSubGop = H264DynamicSubGop.Static - fieldEncoding = H264FieldEncoding.Paff - sceneChangeDetect = H264SceneChangeDetect.Enabled - minIInterval = 0 - telecine = H264Telecine.None - framerateConversionAlgorithm = H264FramerateConversionAlgorithm.DuplicateDrop - entropyEncoding = H264EntropyEncoding.Cabac - slices = 1 - unregisteredSeiTimecode = H264UnregisteredSeiTimecode.Disabled - repeatPps = H264RepeatPps.Disabled - adaptiveQuantization = H264AdaptiveQuantization.High - spatialAdaptiveQuantization = H264SpatialAdaptiveQuantization.Enabled - temporalAdaptiveQuantization = H264TemporalAdaptiveQuantization.Enabled - flickerAdaptiveQuantization = H264FlickerAdaptiveQuantization.Disabled - softness = 0 - interlaceMode = H264InterlaceMode.Progressive - } - } - } - - audioDescriptions = - listOf( - AudioDescription { - audioTypeControl = AudioTypeControl.FollowInput - languageCodeControl = AudioLanguageCodeControl.FollowInput - codecSettings = - AudioCodecSettings { - codec = AudioCodec.Aac - aacSettings = - AacSettings { - codecProfile = AacCodecProfile.Lc - rateControlMode = AacRateControlMode.Cbr - codingMode = AacCodingMode.CodingMode2_0 - sampleRate = 44100