I am using UIImagePickerController to choose video file from library. And user can upload the video.
Also I am using videoMaximumDuration p
The other answer to this question using AVPlayerItem didn't work for me, but this did using AVURLAsset:
#import
-(void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
NSURL *videoURL=[info objectForKey:@"UIImagePickerControllerMediaURL"];
AVURLAsset *asset = [[AVURLAsset alloc] initWithURL:videoURL options:nil];
NSTimeInterval durationInSeconds = 0.0;
if (asset)
durationInSeconds = CMTimeGetSeconds(asset.duration);
}