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!

Accepted Reply

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.

Replies

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.