VideoFlint / Cabbage

A video composition framework build on top of AVFoundation. It's simple to use and easy to extend.
MIT License
1.52k stars 221 forks source link

Adjusting intensity of VideoConfigurationProtocol with Slider #25

Open cosmicsalad opened 5 years ago

cosmicsalad commented 5 years ago

Basic example -

public class MyFilter: VideoConfigurationProtocol {

    var filter: TestFilter!
    public var setIntensity: CGFloat = 0.3

    public init() { }

    public func applyEffect(to sourceImage: CIImage, info: VideoConfigurationEffectInfo) -> CIImage {

        var finalImage = sourceImage

        filter = TestFilter()
        filter.inputImage = finalImage
        filter.intensity = setIntensity
        finalImage = filter.outputImage!

        return finalImage
    }

}

Then when appending this class into trackItem.videoConfiguration.configurations, would there be a preferred method to adjust the setIntensity variable with a UISlider?

vitoziv commented 5 years ago

You can call setIntensity anywhere you like, no preferred method. But be careful of multi-thread issue, the applyEffect method will be called on the render thread.