0

我已经知道如何使用 CIColorCubeWithColorSpace 将 LUT 应用于本地视频。问题是性能有点滞后/缓慢。注意:如果我将 CIFilter 应用于 60FPS 视频,则滞后很明显。

这是我的代码:

let lutFilter = CIFilter.colorCubeWithColorSpace()

override func viewDidLoad() {
    lutFilter.cubeDimension = Float(64)
    lutFilter.colorSpace = CGColorSpaceCreateDeviceRGB()
    lutFilter.cubeData = LUTData // i've already created the lut data

    updateComposition()
}

func updateComposition() {
    player.currentItem?.videoComposition = AVVideoComposition(asset: player.currentItem!.asset, applyingCIFiltersWithHandler: { request in
        lutFilter.inputImage = request.sourceImage
        request.finish(with: lutFilter.outputImage, context: nil)
    })
}

怎样才能优化呢?

4

0 回答 0