Search code examples
objective-ccocoaqtkit

How can captured video be vertically reflected using QTKit?


I have a QTCaptureSession set up which has as its input a QTCaptureDeviceInput (initialized with a QTCaptureDevice corresponding to a webcam); a QTCaptureLayer has had its session set to be this QTCaptureSession. This all works swimmingly.

I would like, however, to vertically reflect (i.e. "mirror") the captured video. Rather than using a QTCaptureVideoPreviewOutput, a CAOpenGLLayer, and a custom kernel, is there a way built-in to QTKit to do this?


Solution

  • Since QTCaptureLayer is a subclass of CALayer, we can just set the affine transform on the QTCaptureLayer to achieve this effect.