func removeFilterFromVideo(videoURL: URL, completion: @escaping ((URL?, String?) -> Void)) {
let asset = AVAsset(url: videoURL)
// Create a mutable video composition
guard let videoTrack = asset.tracks(withMediaType: .video).first else {
completion(nil, "Didn't load video monitor")
return
}
This operate just isn't working i'm not getting any errors.
let videoComposition = AVMutableVideoComposition(asset: asset) { request in
// Present the unique picture to the composition
request.end(with: request.sourceImage, context: nil)
}
videoComposition.renderSize = videoTrack.naturalSize
// Export session
guard let exportSession = AVAssetExportSession(asset: asset, presetName: AVAssetExportPresetHighestQuality) else {
completion(nil, "Didn't create export session")
return
}
// Create output file URL
let documentDirectory = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
let outputURL = documentDirectory.appendingPathComponent("NoFilterVideo").appendingPathExtension("mp4")
// Take away present file
deleteFile(outputURL)
// Configure export session
exportSession.outputURL = outputURL
exportSession.outputFileType = .mp4
exportSession.videoComposition = videoComposition
// Carry out export asynchronously
exportSession.exportAsynchronously {
swap exportSession.standing {
case .accomplished:
completion(outputURL, nil)
case .failed, .cancelled:
completion(nil, exportSession.error?.localizedDescription)
default:
completion(nil, "Didn't export video")
}
}
}
This operate just isn’t working, i’m not getting any error although. I wish to take away all present CIFilter earlier than including a brand new one presently it is including filter on prime. Engaged on video edit software.