Swift 4 & iOS 11: Custom Camera View (Ep3 of Build a Custom Camera)
Why Stack Overflow recommends it
Stack Overflow users cite it as the tutorial they followed when building a custom AVFoundation camera, usually when asking why their preview, audio or layout does not work.
Recommended by 0 people across 0 different months, 2017 to 2018.
What it is
Episode 3 of Zero2Launch's series on building a custom camera in Swift 4 and iOS 11. It sets up an AVFoundation capture session and a camera preview view so the app can show the live camera feed, with photo capture saved for the next episode.
What people said
Cites Michael Clark · 2017-11 · Stack Overflow · on “Camera preview does not conform to UIView bounds when running on iOS devices”
I have an issue when using a camera preview layer within an app. I am currently experiencing an issue where I need the camera preview to alter its size depending on the device its loading on (on iPhone SE the width 380, height 224 while on iPhone 6, 7, 8 its width 479, height 279 and so on in landscape mode). However, whenever I run the app on a device I am provided with the current frame from my storyboard whether this is landscape or portrait. Screenshot of storyboard layout, all views have constraints: The following screenshots are taken from my iPhone6S running the app: Storyboard set to landscape iPhone8+: Storyboard set to landscape iPhone8: Storyboard set to landscape iPhoneSE: Storyb
Cites Brewski · 2018-03 · Stack Overflow · on “Add audio to my video when recording - Swift 4”
I'm trying to add audio when I record video. I know that I have to record it separately and combine them when I save the file, but I cant figure out the syntax or where to add my audio device and where to combine the files. Most of the information available is based on older deprecated syntax or only deal with one subject (Video, vs. Audio etc.) I have different functions for preparing the session, displaying the session and recording the session and saving the outputFile that looks like this code that is based on the tutorial from "Zero2Launch" [this video] but for the life of me I cant figure out what to do with the audio. func setupCaptureSession() { captureSession.sessionPreset = AVCaptureSes
Cites ItsSgtMarv · 2018-12 · Stack Overflow · on “What is wrong with my custom camera view?”
I followed this video: [this video] to the T. But when I open the camera view all I see is the black screen and white button. I get no error messages when I try I load the camera view. Can someone please assist me with what I'm doing wrong? My code is below: import UIKit import AVFoundation class CameraViewController: UIViewController { var captureSession = AVCaptureSession() var backCamera: AVCaptureDevice? var currentCamera: AVCaptureDevice? var photoOutput: AVCapturePhotoOutput? var cameraPreviewLayer: AVCaptureVideoPreviewLayer? override func viewDidLoad() { super.viewDidLoad() setupCaptureSession() setupDevice() setupInputOutput() setupPreviewLayer() startRunningCaptureSession() } func setup