Is there a way to save the video in cache and then extract it if necessary?
NSCache *memoryCache; //assume there is a memoryCache for images or videos NSString *urlString = @"http://blog.jimdo.com/wp-content/uploads/2014/01/tree-247122.jpg"; NSString *path = [[NSBundle mainBundle] pathForResource:[NSString stringWithFormat:@"A"] ofType:@"mov"]; NSURL *url = [NSURL fileURLWithPath:path]; NSData *downloadedData = [NSData dataWithContentsOfURL:[NSURL URLWithString:urlString]]; dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_BACKGROUND, 0), ^ { if (downloadedData) { // STORE IN FILESYSTEM NSString* path = [NSSearchPathForDirectoriesInDomains(NSCachesDirectory, NSUserDomainMask, YES) lastObject]; NSString *file = [path stringByAppendingPathComponent:@"B.mov"]; [downloadedData writeToFile:file options:NSDataWritingAtomic error:nil]; NSLog(@"Cache File : %@", file); // STORE IN MEMORY [memoryCache setObject:downloadedData forKey:@"B.mov"]; } // NOW YOU CAN CREATE AN AVASSET OR UIIMAGE FROM THE FILE OR DATA });
I found this code in Stack Overflow, but it does not work.
source share