Post not yet marked as solved
Post marked as unsolved with 5 replies, 2,980 views
Hi guys,I want to apply a CIFilter to a video. I already can apply it to an image but somehow not to a video.Currently my code looks like: let contentFilter = CIFilter(name: chosenFilter)
let challengeCIImage = CIImage(image: challengeImage)
contentFilter!.setValue(challengeCIImage, forKey: kCIInputImageKey)
let editedChallengeImage = contentFilter!.value(forKey: kCIOutputImageKey) as! CIImage
challengeImageView.image = UIImage(ciImage: editedChallengeImage)
if (IS_VIDEO_SELECTED) {
playerItem = AVPlayerItem(asset: avAsset!)
playerItem!.videoComposition = AVVideoComposition(asset: avAsset!, applyingCIFiltersWithHandler: { request in
let seconds = CMTimeGetSeconds(request.compositionTime)
contentFilter?.setValue(seconds * 10.0, forKey: kCIInputRadiusKey)
// Provide the filter output to the composition
request.finish(with: editedChallengeImage, context: nil)
})
}To be more specific about my problem. During runtime, the content of the asynchronous block starting at line 13 is never reached. The playerItem variable and the avAsset variable are not nil.Does anyone have an idea?Thanks in advance!