Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6991443
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T19:30:09+00:00 2026-05-27T19:30:09+00:00

I am using UIImagePickerController to choose video file from library. And user can upload

  • 0

I am using UIImagePickerController to choose video file from library. And user can upload the video.

Also I am using videoMaximumDuration property while user wants to capture video and upload it.

I want to know that How can I get the duration of selected video file ? so that I can restrict the user to upload video that has duration more then 20 seconds.

I am able to get some basic info about selected video by this code :

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    selectedVideoUrl = [info objectForKey:UIImagePickerControllerMediaURL];
    NSError *error;
    NSDictionary * properties = [[NSFileManager defaultManager] attributesOfItemAtPath:selectedVideoUrl.path error:&error];
    NSNumber * size = [properties objectForKey: NSFileSize];
    NSLog(@"Vide info :- %@",properties);
}

But there is nothing about duration of selected video.

Thanks…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T19:30:10+00:00Added an answer on May 27, 2026 at 7:30 pm

    Got the solution : I use AVPlayerItem class and AVFoundation and CoreMedia framework.

    #import <AVFoundation/AVFoundation.h>
    #import <AVFoundation/AVAsset.h>
    
    - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
    {
        selectedVideoUrl = [info objectForKey:UIImagePickerControllerMediaURL];
    
        AVPlayerItem *playerItem = [AVPlayerItem playerItemWithURL:selectedVideoUrl];
    
        CMTime duration = playerItem.duration;
        float seconds = CMTimeGetSeconds(duration);
        NSLog(@"duration: %.2f", seconds);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using UIImagePickerController to allow my user to select a video from the asset
I'm using the UIImagePickerController to choose an image, and display it to the user
I am using UIImagePickerController for bring images from the photo library, i found this
I am using following code to choose image from camera role picker= [[UIImagePickerController alloc]
I am using UIImagePickerController to load saved photo from iphone library. but when I
From the documentation of UIImagePickerController : On iPad, present the user interface using a
When I shoot a video using UIImagepickerController, the movie url which I receive from
I'm using UIImagePickerController to let my user take a photo or choose a photo
I am trying to save a recorded video to the library using the UIImagePickerController
I have found a lot of information on using UIImagePickerController to let the user

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.