I want to record a video and not have it show up in the Photos/Videos app, Camera Roll or other Photo Albums.
Using the AVCam demo app provided by Apple I’m trying to save a recorded video to the apps’ own Document directory. This works fine, but the saved video is also registered in the Camera Roll / Photo Album and that is something I do not want.
I’ve tried changing the filename extension from .mov to something random, and the video does get saved in the right location with the unknown extension and it does in fact not get added to the Camera Roll but right after saving a dialogue box is shown to the user:
Invalid data – There was a problem writing the asset because the data is invalid and cannot be viewed or played.
There are apps out there that do seem to be able to save to their own Documents directory and not have the taken pictures/videos added to the Camera Roll, ie ReconBot.
So my question is: how can I save a picture or video to the apps’ Documents dir without it showing up in the Photos/Videos app (without the previously mentioned dialogue) ?
In the AvCam sample app, at the very end of the Classes/AVCamCaptureManager.m is the routine that stores the video after it has been recorded. Simply remove the code that stores it to the Camera Roll and leave the existing code that copies it to the documents directory:
-(void)recorder:(AVCamRecorder *)recorder recordingDidFinishToOutputFileURL:(NSURL *)outputFileURL error:(NSError *)error
{
// Save it in the app's Documents directory, whence it can be copied from the device via
// iTunes file sharing.
[self copyFileToDocuments:outputFileURL];
if ([[UIDevice currentDevice] isMultitaskingSupported]) {
[[UIApplication sharedApplication] endBackgroundTask:[self backgroundRecordingID]];
}
if ([[self delegate] respondsToSelector:@selector(captureManagerRecordingFinished:)]) {
[[self delegate] captureManagerRecordingFinished:self];
}
}