Cannot get better video quality than 720p from UIImagePickerController

I am using UIImagePickerController to let users pick videos to use in my app. However I noticed that best quality I am able to get is 1280x720 probably because of the compression that always happen.

These videos are 4K and I would like to get this resolution or at least 1080p.

Here is my code for creating picker:

Code Block
let picker = UIImagePickerController()
picker.delegate = self
picker.videoQuality = .typeHigh
picker.sourceType = .photoLibrary
picker.mediaTypes = UIImagePickerController.availableMediaTypes(for: .photoLibrary) ?? []
assert(!picker.mediaTypes.isEmpty)
picker.mediaTypes = ["public.movie"]
picker.allowsEditing = true
present(picker, animated: true, completion: nil)

Modifying allowsEditing or videoQuality does not do anything.

Thanks for help!

Answered by renssies in 612202022
Try setting picker.videoExportPreset to one of the AVAssetExportSession presets: https://developer.apple.com/documentation/avfoundation/avassetexportsession/export_preset_names_for_quicktime_files_of_a_given_size

In my test picker.videoExportPreset = AVAssetExportPresetHEVCHighestQuality returns the video at original size in .move format.

If you really want to have the original video, you might want to look into PhotoKit/Photos framework.
Accepted Answer
Try setting picker.videoExportPreset to one of the AVAssetExportSession presets: https://developer.apple.com/documentation/avfoundation/avassetexportsession/export_preset_names_for_quicktime_files_of_a_given_size

In my test picker.videoExportPreset = AVAssetExportPresetHEVCHighestQuality returns the video at original size in .move format.

If you really want to have the original video, you might want to look into PhotoKit/Photos framework.
Wonderful! Thanks this works great.

I am having an issue with this as well. I am using typeHigh, but this seems to max out at 1080p.

The documentation states that typeHigh will: If recording, specifies that you want to use the highest-quality video recording supported for the active camera on the device.

Is it possible to obtain 4k with UIImagePickerController, or is 1080 the highest quality possible?

Cannot get better video quality than 720p from UIImagePickerController
 
 
Q