我正在尝试将黑白效果添加到播放中使用swift中的PBJVideoPlayer pod的视频中。我已将其设置为用户可以点按按钮以应用过滤器。我想我的问题是因为我不确定AVVIdeoComposition的模拟对于pod来说是什么。任何见解都将不胜感激。
@IBAction func filterTapped(sender: UIButton) {
switch self.media! {
case .Photo(let image): self.blackAndWhiteFilterForImage(image)
case .Video(let url): self.createBlackAndWhiteFilterForVideo(url)
}
}
func createBlackAndWhiteFilterForVideo(url: NSURL){
//B&W Filter for Video
let asset = AVAsset(URL: url)
let filter = CIFilter(name: "CIPhotoEffectNoir")!
let composition = AVVideoComposition(asset: asset, applyingCIFiltersWithHandler: { request in
// Clamp to avoid blurring transparent pixels at the image edges
let source = request.sourceImage.imageByClampingToExtent()
filter.setValue(source, forKey: kCIInputImageKey)
// Vary filter parameters based on video timing
let seconds = CMTimeGetSeconds(request.compositionTime)
filter.setValue(seconds * 10.0, forKey: kCIInputRadiusKey)
// Crop the blurred output to the bounds of the original image
let output = filter.outputImage!.imageByCroppingToRect(request.sourceImage.extent)
// Provide the filter output to the composition
request.finishWithImage(output, context: nil)
})
//Everything below this code is where I am unsure how to proceed
let playerItem = playerController.asset
print(playerItem)
/*
playerItem.comp
let player = AVPlayer(playerItem: playerItem)
player.play()
*/
}
答案 0 :(得分:0)
我在将任何CIPhotoEffect
应用于视频方面遇到了问题。其他过滤器似乎工作正常。