wess / Glimpse

UIView recording library.
MIT License
557 stars 42 forks source link

fileOutputURL does not contain valid file #2

Open twentyfourapp opened 11 years ago

twentyfourapp commented 11 years ago

after stopping glimpse from recording I want to save this file into the camera roll.
Below is the completion block I am using....

[glimpse startRecordingView:self.tableView onCompletion:^(NSURL fileOuputURL) { ALAssetsLibrary library = [[ALAssetsLibrary alloc] init]; [library writeVideoAtPathToSavedPhotosAlbum:fileOuputURL completionBlock:^(NSURL assetURL, NSError error) { NSLog(@"%@",error); NSLog(@"%@",assetURL); NSLog(@"%@",fileOuputURL); }]; }];

assetURL is NULL as well as my error. So it does not seem to error out. Any reason why I can't use this file URL that is generated from glimpse to save this file to someones camera roll?

manderson-productions commented 10 years ago

I think it has something to do with the 'timestamp' that is appended to the @"glimpse_" string to create the fileOutputURL. Since I only need to create a single video at a time, I was able to work around it:

in the (NSString *)fileOutputURL method,

// I changed *filename to @"glimpse_movie.mov"; // then I set the return value to the instance variable

NSString *filename          = @"glimpse_movie.mov";
NSString *path              = [NSString stringWithFormat:@"%@/%@", documentDirectory, filename];
NSFileManager *fileManager  = [NSFileManager defaultManager];

if([fileManager fileExistsAtPath:path])
    [fileManager removeItemAtPath:path error:nil];

_fileOutputURL = [NSURL fileURLWithPath:path];

return _fileOutputURL; }

Then in the 'writeVideoFromImageFrames method, access the instance variable of _fileOutputURL rather than calling the custom getter:

        if(callback)
            callback(_fileOutputURL);

Otherwise, if you call the getter, it actually finds that the @"glimpse_movie.mov" file already exists and will remove it before returning the path-to-file.

ExoticObjects commented 9 years ago

Setting _fileOutputURL = [NSURL fileURLWithPath:path]; and later if(callback) callback(_fileOutputURL); worked for me even though I preserved the timestamp.

komocode commented 6 years ago

Was this ever resolved? I just ran the example and it doesn't seem to be producing a valid video file. Ran on iPad Mini 4.