Turn on torch/flash on iPhone

Here’s a shorter version you can now use to turn the light on or off: AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; if ([device hasTorch]) { [device lockForConfiguration:nil]; [device setTorchMode:AVCaptureTorchModeOn]; // use AVCaptureTorchModeOff to turn off [device unlockForConfiguration]; } UPDATE: (March 2015) With iOS 6.0 and later, you can control the brightness or level of the torch … Read more

Why AVCaptureSession output a wrong orientation?

Take a look at the header AVCaptureSession.h. There is a definition for an enum called AVCaptureVideoOrientation that defines various video orientations. On the AVCaptureConnection object there is a property called videoOrientation that is a AVCaptureVideoOrientation. You should be able to set this to change the orientation of the video. You probably want AVCaptureVideoOrientationLandscapeRight or AVCaptureVideoOrientationLandscapeLeft. … Read more

How to get front camera, back camera and audio with AVCaptureDeviceDiscoverySession

You can get the front camera with the following: AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .front) The back camera: AVCaptureDevice.default(.builtInWideAngleCamera, for: AVMediaType.video, position: .back) And the microphone: AVCaptureDevice.default(.builtInMicrophone, for: AVMediaType.audio, position: .unspecified)