Maulik Maulik - 1 year ago 117
iOS Question

How to Get iPhone recorded video size?

I want to know How can I get the size of the video that is taken from iPhone camera (recording) ?

I want to set maximum video size for uploading videos on our server.

Example: Each user is subject to limits on the size of the video files they can upload.

Is it possible to get size of video after recording and if size is more then maximum size, then video can not be upload ??? and proper message get displayed ?


Answer Source

In your UIImagePickerControllerDelegate:

- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {
    NSURL * mediaURL = [info objectForKey:UIImagePickerControllerMediaURL];
    NSDictionary * properties = [[NSFileManager defaultManager] attributesOfItemAtPath:mediaURL.path error:&error];
    NSNumber * size = [properties objectForKey: NSFileSize];
    // Do your check here

size is a NSNumber that contains a unsigned long long.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download