To get the total duration of a movie, you can use:
1). Use the AVPlayerItem class and the AVFoundation and CoreMedia framework . (I used UIImagePickerController to select the movie)
#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); }
2). MPMoviePlayerController has a duration .Refer Apple Doc property
source share