IOS camera freezes when watching a video when there is a camera overlay

I am trying to overlay a view on a video capture session in UIImagePicker. The overlay works fine, but when the application hits the screen where the user can โ€œhave a biteโ€, โ€œplayโ€ or โ€œuse the videoโ€, the application will fail and give an error:

2017-04-16 21: 33: 04.129212-0400 ChugMug [429: 59833] libMobileGestalt MobileGestalt.c: 2690: statfs (/ mnt4): there is no such file or directory 2017-04-16 21: 33: 04.129871-0400 ChugMug [ 429: 59833] libMobileGestalt MobileGestalt.c: 2587: SInt64 NANDSize (): no kIOMediaSizeKey found for disk0! 2017-04-16 21: 33: 09.352085-0400 ChugMug [429: 60065] [MediaRemote] An error operation requires that a client callback be registered. play queue request

The code is quite simple when the overlay is commented out, the video preview screen and buttons work fine, but when the overlay is present, the application freezes on the following screen: enter image description here

Here is the code for the camera and overlay:

func startMediaBrowserFromViewController(viewController: UIViewController, usingDelegate delegate: UINavigationControllerDelegate & UIImagePickerControllerDelegate) -> Bool { // 1 if UIImagePickerController.isSourceTypeAvailable(.savedPhotosAlbum) == false { return false } // 2 let mediaUI = UIImagePickerController() mediaUI.sourceType = .savedPhotosAlbum mediaUI.mediaTypes = [kUTTypeMovie as NSString as String] mediaUI.allowsEditing = true mediaUI.delegate = delegate // 3 present(mediaUI, animated: true, completion: nil) return true } func startCameraFromViewController(viewController: UIViewController, withDelegate delegate: UIImagePickerControllerDelegate & UINavigationControllerDelegate) -> Bool { if UIImagePickerController.isSourceTypeAvailable(.camera) == false { return false } cameraController.sourceType = .camera cameraController.mediaTypes = [kUTTypeMovie as NSString as String] cameraController.allowsEditing = false cameraController.delegate = delegate cameraController.showsCameraControls = true //customView stuff let customViewController = CustomOverlayViewController( nibName:"CustomOverlayViewController", bundle: nil ) let customView = customViewController.view //as! CustomOverlayView customView?.frame = cameraController.view.frame present(cameraController, animated: true, completion: { self.cameraController.cameraOverlayView = customView customViewController.cameraLabel.text = "Camera Label" self.cameraController.startVideoCapture() }) return true } func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [String : Any]) { let mediaType = info[UIImagePickerControllerMediaType] as! NSString dismiss(animated: true, completion: nil) // Handle a movie capture if mediaType == kUTTypeMovie { guard let path = (info[UIImagePickerControllerMediaURL] as! NSURL).path else { return } if UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(path) { UISaveVideoAtPathToSavedPhotosAlbum(path, self, nil, nil) } } } 

I do not know what causes this strange error, and cannot find anything like it. Hope someone can help me.

+5
source share

Source: https://habr.com/ru/post/1266803/


All Articles