Save the vedio in DocumentDirectory(Date&Time Wise)



– (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info {


[self dismissViewControllerAnimated:NO completion:nil];

NSString *type = [info objectForKey:UIImagePickerControllerMediaType];

if ([type isEqualToString:(NSString *)kUTTypeVideo] || [type isEqualToString:(NSString *)kUTTypeMovie])


NSURL *videoURL = [info objectForKey:UIImagePickerControllerMediaURL];

videoURL = [info objectForKey:UIImagePickerControllerMediaURL];

NSLog(@”found a video”);

// Code To give Name to video and store to DocumentDirectory //

NSData *videoData = [NSData dataWithContentsOfURL:videoURL];

videoData = [NSData dataWithContentsOfURL:videoURL];

NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);

NSString *documentsDirectory = [paths objectAtIndex:0];

NSDateFormatter *dateFormat = [[NSDateFormatter alloc] init] ;

[dateFormat setDateFormat:@”dd-MM-yyyy||HH:mm:SS”];

NSDate *now = [[NSDate alloc] init];

NSString *theDate;

theDate = [dateFormat stringFromDate:now];

NSString *dataPath = [documentsDirectory stringByAppendingPathComponent:@”Default Album”];

if (![[NSFileManager defaultManager] fileExistsAtPath:dataPath])

[[NSFileManager defaultManager] createDirectoryAtPath:dataPath withIntermediateDirectories:NO attributes:nil error:nil];

NSString *videopath= [[NSString alloc] initWithString:[NSString stringWithFormat:@”%@/”,documentsDirectory,theDate]];

BOOL success = [videoData writeToFile:videopath atomically:NO];

NSLog(@”Successs:::: %@”, success ? @”YES” : @”NO”);

NSLog(@”video path –> %@”,videopath);


[picker dismissViewControllerAnimated:YES completion:nil];



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s