简体   繁体   中英

How do i write video to iphone camera roll using AVFoundation?

I am currently recording video using AVFoundation api and have specified a fileUrl to write to:

    NSURL *fileUrl = [NSURL fileURLWithPath:[NSString stringWithFormat:@"%@%@", NSTemporaryDirectory(), @"output.mov"]];

However, right now its recording to a temp directory. How do i write this file to the camera roll? Whats the camera roll directory?

Thanks!

After recording to the disk do the following to copy the video to Camera Roll

if (UIVideoAtPathIsCompatibleWithSavedPhotosAlbum(outFileName)) {
    UISaveVideoAtPathToSavedPhotosAlbum(outFileName, self, @selector(video:didFinishSavingWithError: contextInfo:), nil);
}

Note that UIVideoAtPathIsCompatibleWithSavedPhotosAlbum() will be successful only of the recorded video is proper QuickTIme format.

我从AVCamDemo代码在Apple网站上找到了一些文档。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM