Save Video to PhotosAlbum - Is Apple Cheating

Discussion in 'iOS Programming' started by xStep, Oct 20, 2011.

  1. xStep macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #1
    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.
     
  2. xStep thread starter macrumors 68000

    Joined:
    Jan 28, 2003
    Location:
    Less lost in L.A.
    #2
    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.

    :(
     

Share This Page