I'm creating a CIFilter
for a AVMutableVideoComposition
Since it doesn't support both a filter and layer instructions, I tried to apply the transform I need directly in the filter:
filter.setValue(transform, forKey: kCIInputTransformKey)
Where transform
is a CGAffineTransform
This throws the exception
Terminating app due to uncaught exception 'NSUnknownKeyException', reason: '[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key inputTransform.'
Now the doc says
A key for an NSAffineTransform object that specifies a transformation to apply.
But NSAffineTransform
does not exist on iOS.
How to use CGAffineTransform
or iOS, or what substitute could replace it ?
My solution was to apply directly the transform in the filter.
This can be done by applying it to the source image.
request.sourceImage.transformed(by: transform)
edit: As Frank pointed out; not all filters support transforms!