1

I tried everything I have found but did not get good results.

Source 1, Source 2, Source 3

My path is

recordSession.outputUrl ==> file:///private/var/mobile/Containers/Data/Application/4D4B0147-C52F-469C-AA0A-23D21AA50B5B/tmp/YYEQsKSLMwIl-SCVideo-Merged.mov
recordSession.outputUrl path ===> /private/var/mobile/Containers/Data/Application/4D4B0147-C52F-469C-AA0A-23D21AA50B5B/tmp/YYEQsKSLMwIl-SCVideo-Merged.mov
recordSession.outputUrl pathExtension ===> mov

My Code

NSString *path = [self.recordSession.outputUrl path];
NSData *data = [[NSFileManager defaultManager] contentsAtPath:path];
NSData *data2 = [NSData dataWithContentsOfURL:[NSURL URLWithString:path]];
NSData *videoData = [NSData dataWithContentsOfFile:path];    
NSData *data3 = [[NSData alloc]initWithContentsOfURL:self.recordSession.outputUrl];

NSLog(@"data is ==> %@",data);
NSLog(@"data2 is ==> %@",data2);
NSLog(@"videoData is ==> %@",videoData);
NSLog(@"data3 ==> %@",data3);

Logs Result

data is ==> (null)
data2 is ==> (null)
videoData is ==> (null)
data3 ==> (null)
Community
  • 1
  • 1
jose920405
  • 7,982
  • 6
  • 45
  • 71
  • Don't save the full path to the file, but only the file name. Then when you access the file build the path use the `URLsForDirectory:inDomains:` method. This is because the application directory might have been changed, – rckoenes Mar 18 '16 at 13:38
  • @rckoenes I tried manually go that route, and indeed can not find the folder `mobile` any idea what could be the problem? This makes my a library of video recording, and it seems very difficult to control or modify the library for this. – jose920405 Mar 18 '16 at 13:45
  • 2
    Every time an app gets installed or update a new app GUID is created. Existing data is moved to the new directory. So never save the full path to the file, just the relative one to you apps directory and build the path when you want to access it. – rckoenes Mar 18 '16 at 14:04
  • Also saving data in the `temp` directory is not permanent. If the system is running low on storage it will delete files in the temp directory without informing you. – rckoenes Mar 18 '16 at 14:06
  • Thanks man. I fix this using `AVAssetExportSession` with `exportAsynchronouslyWithCompletionHandler` and `[NSFileManager defaultManager] contentsAtPath:path` – jose920405 Mar 18 '16 at 14:21

0 Answers0