AVfoundation mirror front camera display

Hi,


I have a requirement from client to mirror the frame display using the selfie camera or front camera in AVfoundation. Is this possible. If not is there any other suggestion?


Thanks

Accepted Reply

Did you see this :


https://stackoverflow.com/questions/40259041/mirroring-flipping-camera-preview-layer


I read that there :

there used to be a mirrored property, now deprecated

AVCaptureVideoPreviewLayer has a property mirrored. Set this true or false, as required.


Must do:

Nowadays, if you use the mirrored property of the preview layer directly, you will get a deprecation warning at runtime. The current way to do it is using directly the connection from the camera. You must do something like this (code below is not real code, property names probably will differ, but you get the idea)



if (cameraPreviewLayer.connection.SupportsVideoMirroring) {
  cameraPreviewLayer.connection.automaticallyAdjustsVideoMirroring = false
  cameraPreviewLayer.connection.videoMirrored = true
}


>I did not test. If it works, thanks to tell, and close the thread…

Replies

Did you see this :


https://stackoverflow.com/questions/40259041/mirroring-flipping-camera-preview-layer


I read that there :

there used to be a mirrored property, now deprecated

AVCaptureVideoPreviewLayer has a property mirrored. Set this true or false, as required.


Must do:

Nowadays, if you use the mirrored property of the preview layer directly, you will get a deprecation warning at runtime. The current way to do it is using directly the connection from the camera. You must do something like this (code below is not real code, property names probably will differ, but you get the idea)



if (cameraPreviewLayer.connection.SupportsVideoMirroring) {
  cameraPreviewLayer.connection.automaticallyAdjustsVideoMirroring = false
  cameraPreviewLayer.connection.videoMirrored = true
}


>I did not test. If it works, thanks to tell, and close the thread…

Looking for this explanation long time ago!! nice

Thanks a ton. It works like a charm