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.

avcapturedevice
Filter by
Sorted by
Tagged with
56 votes
12 answers
48k views

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( ...
Andi's user avatar
  • 8,594
55 votes
11 answers
63k views

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 ...
Peter's user avatar
  • 663
46 votes
8 answers
215k views

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 { ...
John's user avatar
  • 611
23 votes
3 answers
18k views

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 ...
user717452's user avatar
18 votes
6 answers
14k views

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/...
Roi Mulia's user avatar
  • 5,816
17 votes
1 answer
6k views

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 ...
JimVision's user avatar
  • 454
15 votes
2 answers
7k views

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 ...
Maxim Irbe's user avatar
13 votes
2 answers
2k views

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 ...
dre_84w934's user avatar
12 votes
2 answers
14k views

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 ...
Brandon Ruetsche's user avatar
11 votes
2 answers
28k views

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 ...
William's user avatar
  • 1,033
11 votes
5 answers
25k views

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 ...
Adam Popławski's user avatar
11 votes
2 answers
4k views

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 ...
7ball's user avatar
  • 2,265
11 votes
1 answer
3k views

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's user avatar
  • 4,249
10 votes
1 answer
5k views

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 ...
Caleb Rudnicki's user avatar
10 votes
1 answer
9k views

Show camera stream while AVCaptureSession's running

I was able to capture video frames from the camera using AVCaptureSession according to http://developer.apple.com/iphone/library/qa/qa2010/qa1702.html. However, it seems that AVCaptureScreen captures ...
Peter's user avatar
  • 663
10 votes
2 answers
1k views

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 ...
Pavel Alexeev's user avatar
10 votes
2 answers
8k views

How to specify the exposure, focus and white balance to the video recording?

I have a program to take a video with default parameters, and the Exposure, Focus and White Balance will be adjusted automatically when I move the camera. I want to add 2 buttons in the program: LOCK ...
Yang's user avatar
  • 151
9 votes
1 answer
4k views

In Swift 2.1, how do you get the NSError that was thrown?

I'm initializing an AVCaptureDeviceInput. In Swift 2 rather than getting an NSError variable you catch an error with a do-try-catch sandwich. However I don't see how to get the NSError inside the ...
CommaToast's user avatar
  • 11.7k
9 votes
1 answer
6k views

iOS Swift - AVCaptureSession - Capture frames respecting frame rate

I'm trying to build an app which will capture frames from the camera and process them with OpenCV before saving those files to the device, but at a specific frame rate. What I'm stuck on at the ...
Richard Poole's user avatar
9 votes
1 answer
5k views

How to find the highest resolution AVCaptureDeviceFormat suitable for recording to a file?

I'm using AVFoundation to record from the device's camera to a movie file, using AVCaptureMovieFileOutput. I want to allow the user to switch between high frame rate and high resolution modes before ...
Robert's user avatar
  • 5,803
9 votes
1 answer
369 views

AVCaptureDeviceFormat 1080p 60 fps Autofocus issue

I noticed that AVCaptureDeviceFormat 1080p 60 fps on iPhone 6s does not supports focus pixels, so in low light conditions the camera continues to autofocus when moved. This creates an issue with video ...
Deepak Sharma's user avatar
8 votes
4 answers
11k views

How to access Mac default camera using swift xcode

Today i am coding for Mac first time. What I am trying to do is access the default camera and show a preview. 2nd step i will record or take a snap if i need. For the 1st step i have written the ...
KD.'s user avatar
  • 2,035
8 votes
1 answer
881 views

zoom in and zoom out camera on pinch gesture swift

I am using front camera in my app. I want that while taking photos user can zoom in and out camera I tried this code let device = AVCaptureDevice.default(for: .video) print(sender.scale) let ...
Naqeeb's user avatar
  • 1,291
8 votes
1 answer
1k views

AVCaptureDevice adjustingExposure is False but captured image is dark

The Mac OS X app I'm coding is taking a photo capture using the macbook built-in facetime camera. On MacBookAir3,2, MacBookPro8,2 and MacBookPro10,2 it works fine but on new macbooks it takes "dark" ...
grzaks's user avatar
  • 1,414
8 votes
0 answers
517 views

AVCaptureVideoPreviewLayer and ARKit: is it possible to use them together?

I've found that using an AVCaptureVideoPreviewLayer camera overlay, the quality of the camera image shown is quite better than when using an ARSKView. I need to use ARKit and display some SKNodes ...
AppsDev's user avatar
  • 12.4k
8 votes
1 answer
1k views

How to add an audio input to a AVCaptureSession and allow other apps to play music in the background

I'm trying to add an audio input to my AVCaptureSession() and it works great. However I would also like to support users who wish to play music in the background from other apps such as Spotify and ...
JZ.'s user avatar
  • 21.5k
7 votes
3 answers
15k views

Why does AVCaptureVideoOrientation landscape modes result in upside down still images?

I am using AVFoundation classes to implement a custom camera in my app. I am only capturing still images, not video. I have everything working but am stumped by something. I take into account the ...
XJones's user avatar
  • 22k
7 votes
1 answer
4k views

Locking exposureMode with key value observer causes crash

I am doing some motion detection on an area of screen. Before starting the detection I want to set focus and exposure and lock them so they don't trigger a false motion. I am therefore sending a ...
Sten's user avatar
  • 3,714
7 votes
3 answers
3k views

Audio Not Recording in AVCaptureSession [duplicate]

I have an app that when a view is loaded up, begins capturing video and audio, and upon completion, records it to both the documents folder of the app, along with the Camera Roll of the iPad that it ...
user717452's user avatar
7 votes
1 answer
5k views

Swift: autoFocus/Expose and continuousAutoFocus/Exposure at the same time?

Right now in my camera app I let the user touch anywhere to set the focus and exposure, but how can I get the best of both worlds just like Apple's Camera app? For instance, the user may want to ...
Chewie The Chorkie's user avatar
7 votes
3 answers
5k views

AVCaptureDevice is always null on simulator

I am trying to capture live microphone audio data. I took the following from the apple example for AVCaptureSession. AVCaptureSession *captureSession = [[AVCaptureSession alloc] init]; ...
zyeek's user avatar
  • 1,277
7 votes
2 answers
5k views

iPhone 4 AVFoundation : Capture from front and rear cameras simultaneously

I was wondering if it was possible to capture from both cameras simultaneously using AVFoundation framework. Specifically, my question is whether both front and rear AVCaptureDevices can be active at ...
Abai's user avatar
  • 760
7 votes
2 answers
190 views

AVCaptureSession bug persists between installs

I have a app that opens straight to a camera that is based on this WWDC sample: https://developer.apple.com/library/ios/samplecode/AVCam/Introduction/Intro.html A few users have been experiencing a ...
Cbas's user avatar
  • 6,093
7 votes
3 answers
3k views

AVCaptureSession cancels background audio

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 ...
Edmond's user avatar
  • 71
7 votes
0 answers
326 views

How to manually control exposure duration with AVFoundation in OSX?

I'm using AVFoundation to capture images from a connected camera. I need to be able to control the exposure manually, instead of it being automatic. I've found AVCaptureDevice.exposureMode (https://...
Jason von Nieda's user avatar
7 votes
1 answer
1k views

How to get 240fps on iPhone 6 with low resolution

I am trying to do real time image processing with an iPhone 6 at 240fps. The problem is when I capture video at that speed, I can't process the image fast enough since I need to sample each pixel to ...
lehn0058's user avatar
  • 20.1k
7 votes
0 answers
815 views

Live filter on AVCaptureVideoPreviewLayer

How can i add filters to AVCaptureVideoPreviewLayer? Ive tried making a CIFilter and settings AVCaptureVideoPreviewLayer.filters property to an array with the filter, but it did nothing.
Maximilian Litteral's user avatar
6 votes
4 answers
7k views

Preventing AVCaptureVideoPreviewLayer from rotating, but allow UI layer to rotate with orientation

I have two view controllers. One is the root VC and contains the UI interface such as the record button. On this view controller, I also display the view of another VC at index 0. This view contains a ...
yamski's user avatar
  • 471
6 votes
1 answer
3k views

iPhone 13 Pro / swift / AVFoundation builtInTripleCamera : how to enable automatic switching between cameras?

I am currently making a custom camera app for iOS with swiftUI AVFoundation. I also just bought iPhone 13 Pro. On the native Camera App, cameras automatically switch depending on FOCUS (ultrawide for ...
Mourad's user avatar
  • 61
6 votes
3 answers
9k views

iOS: captureOutput:didOutputSampleBuffer:fromConnection is NOT called

I want to pull frames from the live-feed of AVCaptureSession and I am using Apple's AVCam as a test case. Here is the link to AVCam: https://developer.apple.com/library/ios/samplecode/AVCam/...
Paul A.'s user avatar
  • 577
6 votes
2 answers
2k views

Haptic feedback not playing nice with AVFoundation? (UIImpactFeedbackGenerator, etc)

I'm trying to have a video/camera view in the background while I also allow for haptic feedback in my app for various actions, but it seems that AVFoundation is not playing nice with any of the calls ...
JasonAddFour's user avatar
6 votes
3 answers
11k views

Why my iOS app does not ask user permission to access camera?

I develop iOS app and it uses camera. AVCaptureDeviceInput is used to interface to camera. I checked Authorisation status as - (void)checkDeviceAuthorizationStatus { NSString *mediaType = ...
batuman's user avatar
  • 7,212
6 votes
2 answers
775 views

macOS: Accessing a virtual Cameras (OBS) as AVFoundation CaptureDevice

On macOS, is it possible to see a virtual Camera, such as OBS, as a CaptureDevice? I see that, for example, Google Chrome or Zoom can use this camera, but using AVCaptureDevice.DiscoverySession I am ...
below's user avatar
  • 948
6 votes
0 answers
141 views

Audio Recording Mac app with Visualizations unable to select input device with AudioKit

Hey I wonder if someone can point me in the right direction. I am building a Mac Audio App that I need to perform the following actions Select audio input device Show a live audio graph of device ...
user499846's user avatar
5 votes
4 answers
6k views

show record timer while making video

I had implemented the concept of AVCaptureSession for recording video. -(void)startRecordingWithOrientation:(AVCaptureVideoOrientation)videoOrientation { AVCaptureConnection *videoConnection = ...
Sudha Tiwari's user avatar
  • 2,419
5 votes
2 answers
8k views

Set a custom AVFrameRateRange for an AVCaptureSession

I'm trying to take 5 pictures every second with AVCaptureSession and I'm not sure I understand what AVFrameRange means. Currently I have some code that sets up the device: AVCaptureDevice *device = [...
ray1's user avatar
  • 3,978
5 votes
3 answers
9k views

Unable to get devices using AVCaptureDevice

I've managed to find some code that would give me access to the devices of a phone (such as the camera). The issue is that when I compile the code (and I'm printing the different devices) using Xcode, ...
Tricks's user avatar
  • 51
5 votes
2 answers
8k views

Objective-C AVCaptureDevice Front Camera

I have followed a tutorial that guided through a way to make a custom but simple camera app, almost exactly to the needs of the use I would like it. I actually have two issues that I need changing but ...
Noodleme's user avatar
5 votes
2 answers
3k views

How to calculate focusPointOfInterest for AVCaptureDevice?

How do you calculate the focusPointOfInterest (a CGPoint value between 0,0 and 1,1) for an given AVCaptureDevice? I've been following the code samples from the latest WWDC but I really don't ...
wgpubs's user avatar
  • 8,221
5 votes
2 answers
387 views

Touch ID freezes AVCaptureDevice

I have an AVCaptureDevice to display a live camera preview on screen. When a Touch ID view is overlaid on the camera preview (using CAContext's evaluatePolicy), the camera preview freezes. When the ...
Randomblue's user avatar
  • 115k

1
2 3 4 5
7