码迷,mamicode.com
首页 > 其他好文 > 详细

导出相册视频-> 本地沙盒

时间:2020-04-30 15:30:38      阅读:74      评论:0      收藏:0      [点我收藏+]

标签:relative   default   ati   本地   沙盒   network   相册   res   pre   

 

1, exportSession

let option = PHVideoRequestOptions()
                option.isNetworkAccessAllowed = true
                option.deliveryMode = .highQualityFormat
                PHCachingImageManager.default().requestExportSession(forVideo: asset, options: option, exportPreset: AVAssetExportPresetHighestQuality) { (exportSession, info) in
                    guard let exportSession = exportSession else {
                        single(.error(KimPhotoHelperError.sourceNotFound))
                        return
                    }
                    exportSession.outputURL = videoPath
                    exportSession.outputFileType = .mp4
                    exportSession.exportAsynchronously {
                        switch exportSession.status {
                        case .completed:
                            single(.success((videoPath.relativePath, size)))
                        case .failed:
                            print(exportSession.error)
                            single(.error(KimPhotoHelperError.sourceNotFound))
                        default:
                            break
                        }
                    }
                }

 

2,  PHAssetResourceManager

let resourceManager = PHAssetResourceManager.default()
                let option = PHAssetResourceRequestOptions()
                option.isNetworkAccessAllowed = true
                resourceManager.writeData(for: assetRescource, toFile: videoPath, options: option) { (error) in
                    guard let error = error else {
                        //single(.error(e))
                        exportSession(asset)
                        return
                    }
                    single(.success((videoPath.relativePath, size)))
                }

 

导出相册视频-> 本地沙盒

标签:relative   default   ati   本地   沙盒   network   相册   res   pre   

原文地址:https://www.cnblogs.com/daxueshan/p/12808761.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!