Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

xStep

macrumors 68020
Original poster
Jan 28, 2003
2,031
143
Less lost in L.A.
Apple's camera app seems to save video straight to the photos album. I'm wondering if that capability can be accomplished by us mere mortal developers.

Both methods I've come across and tested, copy a video file to the photos album. The larger the file, the longer it takes to save. A 2 minute creation can vary in the save time. Two timings I have are, 45 seconds, and 1 minute 12 seconds to copy to copy files about 150MB in size. A file of similar size from the Apple Camera app can take as little as 6 seconds.

I've looked at the AVCam demo code and it uses one of the two methods I've already tested.

ALAssetsLibrary instance method writeVideoAtPathToSavedPhotosAlbum:completionBlock:

UIKit Function UISaveVideoAtPathToSavedPhotosAlbum

I'm using AVFoundation to connect to the camera and open up a stream to a file. For context, the following is where I open that file. The movieURLPath a file reference in my apps document directory area.

Code:
outputWriter = [AVAssetWriter assetWriterWithURL: [projectPaths movieURLPath] fileType: AVFileTypeQuickTimeMovie error: &error];

When the file has been closed by stopping the recording, I eventually get to this line.

Code:
UISaveVideoAtPathToSavedPhotosAlbum ([projectPaths movieFilePath], self, @selector(video:didFinishSavingWithError: contextInfo:), nil);


Does anyone have any other options to speed up the writing process? Clearly my preference would be to have movieURLPath pointing to a file in the PhotosAlbum. It would be optimal to open the file in that folder instead, which is what I think Apple has done.
 

xStep

macrumors 68020
Original poster
Jan 28, 2003
2,031
143
Less lost in L.A.
Well, it is looking dim. No one has responded here or on Stackoverflow with this answer I'd like. ;)

It looks like the best I can do is to do the copy in on background thread. Oh, and make sure the file name is unique so that I don't overwrite it if the user records something new while the copy is in progress.

:(
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.