AWS code-library documentation change
Summary
Simplified MediaConvert job creation by removing complex output presets, reduced H264 quality settings, and streamlined endpoint discovery logic
Security assessment
Changes focus on code simplification and configuration adjustments rather than addressing security vulnerabilities. The quality level reduction (8->7) and bitrate changes impact output quality but not security. No security-related patterns like authentication, encryption, or vulnerability fixes are present.
Diff
diff --git a/code-library/latest/ug/kotlin_1_mediaconvert_code_examples.md b/code-library/latest/ug/kotlin_1_mediaconvert_code_examples.md index d50528ced..f6eeda8db 100644 --- a//code-library/latest/ug/kotlin_1_mediaconvert_code_examples.md +++ b//code-library/latest/ug/kotlin_1_mediaconvert_code_examples.md @@ -39 +39 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - fileInputVal: String, + fileInput1: String, @@ -41,7 +41,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( @@ -49,2 +44,3 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - maxResults = 20 - } + maxResults = 1 + }, + ) @@ -52,8 +48,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 { @@ -61,3 +54,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) @@ -67,24 +59,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) - - 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) - } + // Output destination folder in S3 - put in 'output/' folder beside input + val outputDestination = fileInput1.substringBeforeLast('/') + "/output/" @@ -92,2 +62,10 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - // 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( @@ -95,25 +73,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 @@ -121 +77,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - outputs = outputObsList @@ -123,2 +79 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - - val theOutput = + outputs = listOf( @@ -126,4 +81,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 @@ -131,3 +84 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - - videoDescription = - VideoDescription { + videoDescription = VideoDescription { @@ -136,10 +87 @@ 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 { @@ -147,2 +89 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - h264Settings = - H264Settings { + h264Settings = H264Settings { @@ -150,3 +91,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 @@ -155 +96,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - maxBitrate = 2400000 @@ -157,26 +97,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 - } - } @@ -184,19 +98,0 @@ There's more on GitHub. Find the complete example and learn how to set up and ru - - 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