I'm using Swift to show content from an AVPlayer in a view's AVPlayerLayer. The associated AVPlayerItem has a videoComposition, and slightly simplified version of the code to create it (without error checking, etc.) looks like this:
playerItem.videoComposition = AVVideoComposition(asset: someAsset, applyingCIFiltersWithHandler: {
[unowned self] (request: AVAsynchronousCIImageFilteringRequest) in
let paramDict = << set up parameter dictionary based on class vars >>
// filter the image
let filter = self.ciFilterWithParamDict(paramDict) {
filter.setValue(request.sourceImage, forKey: kCIInputImageKey)
if let filteredImage = filter.outputImage {
request.finishWithImage(filteredImage, context: nil)
}
})
This all works as expected when the AVPlayer is playing or seeking. And if a new videoComposition is created and loaded, the AVPlayerLayer is rendered correctly.
I have not found a way, however, to "trigger" the AVPlayer/ AVPlayerItem/ AVVideoComposition to re-render when I have changed some of the values that I use to calculate filter parameters. If I change values and then play or seek, it is rendered correctly, but only if I play or seek. Is there no way to trigger a rendering "in place"?