FAQ Database Discussion Community


Front Flash Brightness iPhone

ios,iphone,image,avcapturesession,avcapturedevice
I have been working on a project for a while now and I have come to one thing I want to really work out that I haven't been able to figure out. In the application when taking a front facing picture, I would like front flash to actually make the...

AVCaptureOutput didOutputSampleBuffer stops getting called

ios,objective-c,avfoundation,avcapturesession
I have an issue with the delegate method didOutputSampleBuffer:(CMSampleBufferRef)sampleBuffer fromConnection:(AVCaptureConnection *)connection of AVCaptureOutput. It stops getting called within a second or two when I'm adding the sampleBuffer to a CFArray. If I remove the CFArray code, the delegate method continues to get called so I have no idea why the...

Objective-C to Swift translation issue

objective-c,swift,translation,avcapturesession
I'm trying to translate this simple line of code to Swift, but can't figure out how to write it: AVCaptureConnection *videoConnection = nil; I've tried: let videoConnection: AVCaptureConnection = nil let videoConnection: AVCaptureConnection = false var videoConnection:AVCaptureConnection = AVCaptureConnection() videoConnection = nil var videoConnection:AVCaptureConnection = AVCaptureConnection() videoConnection = false var...

How to capture picture with AVCaptureSession in Swift?

ios,swift,camera,avcapturesession
I have a UIViewController in which I use AVCaptureSession to show the camera and it is working just fine and fast. I placed a UIButton object on top of this camera view and added a IBAction for the button. This is how it looks like right now: Now I want...

Objective-C to Swift: correct way to translate a for-loop

objective-c,swift,for-loop,avcapturesession
I'm trying to convert this code to swift, but I keep getting an error in the if-statement, the objective-c code looks like this: AVCaptureStillImageOutput *stillImageOutPut; AVCaptureConnection *videoConnection = nil; for (AVCaptureConnection *connection in stillImageOutput.connections){ for (AVCaptureInputPort *port in [connection inputPorts]){ if ([[port mediaType] isEqual:AVMediaTypeVideo]){ videoConnection = connection; break; } }...

Changing Max Duration of Video while Recording iOS

ios,avfoundation,video-capture,avcapturesession
I am initially starting recording with a specified Maximum Time Threshold. AVCaptureMovieFileOutput* output; //initialisations, other configurations... //Here i am setting up my MaxDuration before starting recording. [output setMaxRecordedDuration:CMTimeMakeWithSeconds(MY_MAX_LENGTH, 600)]; //Starting recording here [output startRecordingToOutputFileURL:MY_FILE_URL recordingDelegate:self]; I need to change the Maximum Recording Time Threshold while recording is going on. What...

Inactive/invalid connection passed when attempting to take a photo

ios,iphone,swift,avcapturesession,avcapture
I am attempting to take a photo using a custom view (without using UIImagePickerController), but whenever I attempt to take the photo, the app crashes, and this error is thrown: Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[AVCaptureStillImageOutput captureStillImageAsynchronouslyFromConnection:completionHandler:] - inactive/invalid connection passed.' Here's my takePhoto() function, which causes...

AVCapture Session To Capture Image SWIFT

ios,swift,avcapturesession
I have created an AVCaptureSession to capture video output and display it to the user via UIView. Now I want to be able to click a button (takePhoto method) and display the image from the session in an UIImageView. I have tried to iterate through each devices connection and try...

iOS: AVCaptureOutput stops working after navigation

ios,objective-c,avcapturesession,avcaptureoutput
I'm using the camera view as a barcode scanner that scans a barcode and launches a segue to another viewcontroller with a webview. This is working fine, and I can navigate back to the scanner from the webview and scan another barcode without issue. However, if I navigate away from...

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

ios,swift,avfoundation,avcapturesession,avcapturedevice
I have a two view controllers. One is the root VC and contains my 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 AVCaptureVideoPreviewLayer. I would like my video camera to mimic the...

AVCaptureVideoPreviewLayer displays correctly except on iPhone6

ios,objective-c,iphone,uiview,avcapturesession
I'm working on implementing a view that consists of an AVCaptureVideoPreviewLayer. The view is supposed to take up the entirety of the screen, except for the navigation bar at the top (the view is embedded in a navigation controller). My code below shows how I've set up a capture session...