Created
June 19, 2024 17:08
-
-
Save kmdarshan/6d4f552f4e0266700414a37d232b0e7b to your computer and use it in GitHub Desktop.
This file contains 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
func exportVideoWithWatermark(inputURL: URL, outputURL: URL, watermark: UIImage) { | |
guard let composition = addWatermark(to: inputURL, watermark: watermark) else { | |
print("Failed to add watermark") | |
return | |
} | |
guard let exportSession = AVAssetExportSession(asset: composition, presetName: AVAssetExportPresetHighestQuality) else { | |
print("Failed to create export session") | |
return | |
} | |
exportSession.outputURL = outputURL | |
exportSession.outputFileType = .mp4 | |
exportSession.shouldOptimizeForNetworkUse = true | |
exportSession.exportAsynchronously { | |
switch exportSession.status { | |
case .completed: | |
print("Export completed") | |
case .failed: | |
print("Failed to export video: \(String(describing: exportSession.error))") | |
case .cancelled: | |
print("Export cancelled") | |
default: | |
break | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment