我打算使用SWIFT为OS X应用程序构建一个NSOpenGLView,可用于将核心图像过滤器和效果应用于视频,到目前为止,我已经研究了视频控制器的代码来添加视频播放,但是我不确定如何将过滤器应用于视频:
[[NSMutableArray alloc] initWithArray:@[@1.5,@2.,@2.5,@3.,@3.5,@4.,@4.5,@5.,@5.5,@6.,@6.5,@7.]];
但我无法理解在哪里以及如何应用核心图像过滤器。我在网上搜索过,但是找不到完整的例子。
任何帮助都将不胜感激,天啊,我很快就能搞清楚:)
答案 0 :(得分:0)
实际上我想出来了..这是一个需要OS X El Capitan或更高版本的解决方案..
let url = NSBundle.mainBundle().URLForResource("skies", withExtension: "mp4”)!
let avAsset = AVAsset(URL: url)
let vidComp = AVVideoComposition(asset: avAsset,
applyingCIFiltersWithHandler: {
request in
self.image = request.sourceImage.imageByClampingToExtent();
self.image = (self.image!.imageByApplyingFilter("CIGaussianBlur”, withInputParameters: [kCIInputRadiusKey: self.blurTestSlider.integerValue])
self.image = self.image!.imageByCroppingToRect(request.sourceImage.extent)
request.finishWithImage(self.image!, context: self.context)
})
let playerItem = AVPlayerItem(asset: avAsset)
playerItem.videoComposition = vidComp
player = AVPlayer(playerItem: playerItem)
dTMediaViewControllerA?.player = player
dTMediaViewControllerA?.player.play()