asset, presetName: AVAssetExportPresetHEVCHighestQualityWithAlpha) else { print("Failed to create export session to HEVC with alpha.") handleExportCompletion(.failed) return } // Make CIFilter let filter = makeChromaKeyFilter(usingHueFrom: 0.3, to: 0.4, brightnessFrom: 0.05, to: 1.0 ) let chromaKeyComposition = AVVideoComposition(asset: asset, applyingCIFiltersWithHandler: { request in let source = request.sourceImage.clampedToExtent() filter.setValue(source, forKey: kCIInputImageKey) let output = filter.outputImage! // Provide the filter output to the composition request.finish(with: output, context: nil) }) // Export exportSession.outputURL = destinationURL exportSession.outputFileType = .mov exportSession.videoComposition = chromaKeyComposition exportSession.exportAsynchronously { handleExportCompletion(exportSession.status) }