Closed cosmicsalad closed 5 years ago
You can set custom filter in TrackItem.videoConfiguration.configurations
What would be the correct way of creating the configuration? I'm just unclear about how to start that.
You need create a new class and implement VideoConfigurationProtocol
protocol, then you can set the class instance to configurations
I've spent a while trying to wrap my head around it, if you have the time, would you be open to providing a very basic example of what correct implementation would look like?
Create a CustomEffect
and implement VideoConfigurationProtocol
public class CustomEffect: VideoConfigurationProtocol {
public func applyEffect(to sourceImage: CIImage, info: VideoConfigurationEffectInfo) -> CIImage {
// HERE IS YOUR CUSTOM FILTER CODE
}
}
Then you can put the effect to TrackItem
TrackItem item = ...
let effect = CustomEffect()
item.videoConfiguration.configurations = [effect]
Ok thank you for the confirmation that I was at least doing the setup right! Mostly confused with the purpose of the required NSCopying
when conforming to VideoConfigurationProtocol
You are right :+1:, NSCopying
is unnecessary...... I will optimize it later
So I got Custom Filters to work with the new configuration setup, but something I'm noticing is that with high-resolution videos filter application tends to make playback lag and eventually memory usage rises above about 1.3gb and it crashes. Would it be possible/helpful to modify how filter's get applied maybe by utilizing AVVideoComposition.init(asset:applyingCIFiltersWithHandler:)?
You need to find out why the memory keeps rising, not to change API.
Hmm, it seems to be caused when I set the Timeline's renderSize to the resource's width and height. If it's a portrait video, I don't want AVPlayer to have a background. I want the player to be the same size as the video's size so there's never a background.
Hi Vito, I'm wondering what the process looks like for processing a filter now that filterProcessor was removed in version 0.2. The VideoCat demo used this when applying Lookup table filters but I'm wondering how I should go about doing this now it's gone. Do you have an example I could try? Thank you for your work and time!