Posts

Showing posts with the label avasset

displaying a filtered video File with a preferredTransform that is not identity swift

displaying a filtered video File with a preferredTransform that is not identity swift For the app i'm working on, I need to provide a functionality that lets users apply filters to their videos( not real time, applying filters on a saved video and filePath is provided). addFilterToVideo is called when the user taps on a filter, a video composition is passed as a parameter to the initPlayer function and if the "none" video filter is tapped nil is passed whenever a new filter is tapped on I just change the video composition of the playerItem and the file is loaded only the first time func addFilterToVideo(filterName: String ){ if filterName != "" { let filter = CIFilter(name: filterName) if #available(iOS 9.0, *) { let composition = AVVideoComposition(asset: (self.playerItem?.asset)!) { (request) in let source = request.sourceImage.clampingToExtent() filter?.setValue(source, forKey: kCIInputImageKey) let outp...