1

I am capturing live video within the app and saving it using PHAssetChangeRequest However, the video is saving to the camera roll at very low resolution. If I take the same exact video (same phone) from within the camera app, it saves to the camera roll at a higher resolution.

From within the app a portrait is being saved at 360X480 while the same video taken from the camera app, is saved at 720X1200.

below is the code for how the video is being saved from my app. Why the resolution drop?

PHPhotoLibrary.shared().performChanges({
        PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: self.sharedManager.videoFileLocalURL)
    }, completionHandler: { (saved, error) in
        if error != nil
        {
            print ("Asset Saving Error: \(error.debugDescription)")
        }

        if saved == true
        {
            print ("Asset saved to library")
            let fetchOptions = PHFetchOptions()
            fetchOptions.sortDescriptors = [NSSortDescriptor(key: "creationDate", ascending: true)]
            if let fetchedAsset = PHAsset.fetchAssets(with: .video, options: fetchOptions).lastObject
            {
                self.sharedManager.newzInfoInDraft.videoCreateDate = Date()
                self.processVideo(asset: fetchedAsset)
            }
            else
            {
                print ("Cannot fetch asset from library")
            }
        }
        else
        {
            print ("Asset not saved to library")
        }
    })
}

Update: Call to capture video

let recordActionButton = UIAlertAction(title: "Record a video", style: .destructive)
        { _ in
            self.imagePickerController.sourceType = .camera
            self.imagePickerController.mediaTypes = [kUTTypeMovie as String]
            self.imagePickerController.delegate = self

            self.present(self.imagePickerController, animated: true, completion: nil)

        }
C6Silver
  • 3,127
  • 2
  • 21
  • 49
  • 1
    Please post your AVCaptureSession sessionPreset configuration – Leo Dabus Jun 09 '18 at 18:22
  • @LeoDabus - One was not used. I've added the relevant code above that allows for video capture. – C6Silver Jun 09 '18 at 18:38
  • 1
    @LeoDabus - Your question led me in a different direction which has solved the problem. I have added: self.imagePickerController.videoQuality = .typeHigh – C6Silver Jun 09 '18 at 18:48

1 Answers1

0

Appreciate Leo Dabus putting a direction into my head as to the nature of the problem. The one-line of code that solved the problem is below. Not relying on the perceived default is a good lesson here....

self.imagePickerController.videoQuality = .typeHigh
C6Silver
  • 3,127
  • 2
  • 21
  • 49