iOS保存视频到相册

方法1

import

PHPhotoLibrary *photoLibrary = [PHPhotoLibrary sharedPhotoLibrary];
[photoLibrary performChanges:^{

    [PHAssetChangeRequest creationRequestForAssetFromVideoAtFileURL:[NSURL
fileURLWithPath:self.peerVideoPath]];

} completionHandler:^(BOOL success, NSError * _Nullable error) {
    if (success) {
        NSLog(@"stopRecord=====已将视频保存至相册");
    } else {
        NSLog(@"stopRecord=====未能保存视频到相册 ==error:%@",error);


    }
}];

方法二

实现UIImagePickerControllerDelegate

UISaveVideoAtPathToSavedPhotosAlbum(self.peerVideoPath, self, @selector(video:didFinishSavingWithError:contextInfo:), nil);
 - (void)video:(NSString *)videoPath didFinishSavingWithError:(NSError *)error contextInfo:(void *)contextInfo {
if (!error) {
    NSLog(@"stopRecord=====成功");
} else {
    NSLog(@"stopRecord=====失败");}
}

你可能感兴趣的:(iOS保存视频到相册)