简体   繁体   English

如何使用AVFoundation将视频写入iPhone胶卷?

[英]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: 我目前正在使用AVFoundation api录制视频,并指定了要写入的fileUrl:

    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 录制到磁盘后,请执行以下操作将视频复制到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. 请注意,UIVideoAtPathIsCompatibleWithSavedPhotosAlbum()仅在录制的视频是正确的QuickTIme格式时才会成功。

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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