Search code examples
iosuiimagepickercontrolleravfoundation

Choose video from photo gallery with certain duration and attached location only


I am working on an app which allow user to choose video from photo library using UIImagePickerController. I want to have some filter on the video e.g If selected video duration is > 5 mins video will not be uploaded. Same way the selected video must have the location coordinate attached with it.

I have done this thing in - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info. First I got the duration and validated it than I used ALAssetsLibraryAssetForURLResultBlock and check for valid coordinates attached.

All is working well but the problem is when I choose video from gallery it goes for compressing and after that progress I am able to get the duration and location. If user choose 1hrs duration video and it will take a lot time. and if it doesn't have location with it than also my app will refuse it.

  • Is it possible to choose only those video which are < 5mins and have valid coordinates??
  • Can we show only those videos which fulfill my app's criteria?
  • Can I get duration and location by skipping compressing of Image picker?

Solution

  • As per your requirement, I think UIImagePickerController is not fit for this u need AssetLibrary which is totally customizable by Apple so you can get whole detail of all videos properties like Size,Duration,Co-Ordinates all this so you need to go through on "ALAssetsLibrary " for your requirement.

    Please go through below link given by apple for filtering Videos & photos

    ALAssetsFilter Class Reference