Questions tagged [avcapturedevice]

AVCaptureDevice represents a physical capture device and the properties associated with that device. You use a capture device to configure the properties of the underlying hardware.

A capture device also provides input data (such as audio or video) to an AVCaptureSession object.

API reference

347 questions
55
votes
12 answers

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

Before iOS 10 came out I was using the following code to get the video and audio capture for my video recorder: for device in AVCaptureDevice.devices() { if (device as AnyObject).hasMediaType( AVMediaTypeAudio ) { …
Andi
  • 8,154
  • 3
  • 30
  • 34
55
votes
11 answers

Why AVCaptureSession output a wrong orientation?

So, I followed Apple's instructions to capture video session using AVCaptureSession: http://developer.apple.com/iphone/library/qa/qa2010/qa1702.html. One problem I'm facing is that even though the orientation of the camera / iPhone device is…
Peter
  • 663
  • 1
  • 6
  • 7
46
votes
8 answers

Turn on torch/flash on iPhone

I know that the only way to turn on the flash and keep it on on iPhone 4 is by turning the video camera on. I'm not too sure of the code though. Here is what I am trying: -(IBAction)turnTorchOn { AVCaptureSession *captureSession =…
John
  • 611
  • 2
  • 9
  • 12
23
votes
3 answers

AVCaptureSession Record Video With Audio

I have my app set up to record video from the camera using an AVCaptureSession, however, there is no audio with it. What do I need to do to record audio and then add it to the videoOutput for the file? Here is my code for recording the…
18
votes
6 answers

AVCaptureVideoPreviewLayer (camera preview) freezes/stuck after moving to background and back

Cant figure this one out. Everything works fine when the app is active, and than sometimes when i move the app to the background(pressing the home button) and than going back, the previewlayer freezes/stuck. Im using viewWillAppear and…
Roi Mulia
  • 5,626
  • 11
  • 54
  • 105
17
votes
1 answer

Individual Access of Camera LED Lights of iPhone 5s

I'm coding for the iPhone 5s and it now has two LED lights for the rear camera. I don't know the official LED color names, but one LED is white and the other LED is yellowish. Apple refers to this as "True Tone". I'm trying to access these camera…
JimVision
  • 454
  • 4
  • 15
15
votes
2 answers

AVCaptureSession and background audio iOS 7

Whenever I start an AVCaptureSession running with the microphone as an input it cancels whatever background music is currently running (iPod music for instance). If I comment out the line adding the audio input, the background audio continues. Does…
13
votes
2 answers

How to disable camera microphone on AVCapture device input

I am setting a microphone on a AVCaptureSession and I am in need of a switch for the mic. How should I proceed with this? Do I really need to the captureSession?.removeInput(microphone), or is there an easies way? let microphone =…
dre_84w934
  • 678
  • 8
  • 27
12
votes
2 answers

Type 'AVCaptureDevice' has no member 'defaultDevice'

Working on a QR code reader. I am new to programming so this might be an easy fix. The error is "Type 'AVCaptureDevice' has no member 'defaultDevice'" Thanks for the help in advance! //Creating session let session = AVCaptureSession() …
Brandon Ruetsche
  • 121
  • 1
  • 1
  • 3
11
votes
1 answer

Set GrayScale on Output of AVCaptureDevice in iOS

I want to implement custom camera into my app. So, I am creating this camera using AVCaptureDevice. Now I want to show only Gray Output into my custom camera. So I am trying to getting this using…
Meet Doshi
  • 4,241
  • 10
  • 40
  • 81
11
votes
2 answers

Get Camera Preview to AVCaptureVideoPreviewLayer

I was trying to get the camera input to show on a preview layer view. self.cameraPreviewView is tied to a UIView in IB Here is my current code that I put together from the AV Foundation Programming Guide. But the preview never shows AVCaptureSession…
William
  • 1,033
  • 2
  • 13
  • 25
11
votes
5 answers

Accessing iOS 6 new APIs for camera exposure and shutter speed

On Apple's iOS 6.0 feature page, it used to say Take advantage of the built-in camera’s advanced features. New APIs let you control focus, exposure, and region of interest. You can also access and display faces with face detection APIs, and…
Adam Popławski
  • 345
  • 1
  • 3
  • 13
10
votes
3 answers

iOS: Torch level on iPhone 11 Pro

I'm using AVCaptureDevice.setTorchModeOn(level) method to turn on the flashlight at variable brightness. On my old iPhone SE it's working fine — I can clearly see 4 different brightness levels as I change level from 0 to 1. But on the iPhone 11 Pro…
Pavel Alexeev
  • 6,026
  • 4
  • 43
  • 51
10
votes
1 answer

AVCaptureMetadataOutput().rectOfInterest not Working

I am building a UIView that has an overlaid box and the end-goal is to have the QR Code reader only fire when the QR falls within the box. I know that I need to set the .rectOfInterest() to be the same as the yellow box, but in the current…
Caleb Rudnicki
  • 345
  • 8
  • 17
10
votes
2 answers

AVCaptureDevice on macOS

Is it possible to display a camera feed in a macOS app? I'm basically trying to capture images frame by frame from a camera feed. I know how to do this in iOS, but for some reasons, on macOS, I can't seem to find any AVCaptureDevice for video. let x…
7ball
  • 2,183
  • 4
  • 26
  • 61
1
2 3
23 24