修复app内视频拍摄完毕后保存视频至相册的操作
This commit is contained in:
parent
dc2fb63193
commit
e62f93f9a7
@ -370,6 +370,11 @@ class CCSpatialShootController: BaseController {
|
||||
}
|
||||
|
||||
do {
|
||||
print("builtInWideAngleCamera:\(backCamera.videoZoomFactor)")
|
||||
// try backCamera.lockForConfiguration()
|
||||
// backCamera.videoZoomFactor=3.0
|
||||
// backCamera.unlockForConfiguration()
|
||||
|
||||
wideAngleCameraDeviceInput = try AVCaptureDeviceInput(device: backCamera)
|
||||
|
||||
guard let wideAngleCameraDeviceInput = wideAngleCameraDeviceInput,
|
||||
@ -390,8 +395,13 @@ class CCSpatialShootController: BaseController {
|
||||
}
|
||||
|
||||
do {
|
||||
print("builtInUltraWideCamera:\(frontCamera.videoZoomFactor)")
|
||||
// try frontCamera.lockForConfiguration()
|
||||
// frontCamera.videoZoomFactor = 8.0//变焦
|
||||
// frontCamera.unlockForConfiguration()
|
||||
// 设置焦距
|
||||
// frontCamera.focusMode = .autoFocus
|
||||
ultraWideCameraDeviceInput = try AVCaptureDeviceInput(device: frontCamera)
|
||||
|
||||
guard let ultraWideCameraDeviceInput = ultraWideCameraDeviceInput,
|
||||
session.canAddInput(ultraWideCameraDeviceInput) else {
|
||||
print("Could not add front camera input")
|
||||
@ -936,12 +946,13 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate {
|
||||
if(rightEyeVideoURL != nil && leftEyeVideoURL != nil){
|
||||
let spatialVideoWriter = SpatialVideoWriter()
|
||||
Task {
|
||||
spatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: leftEyeVideoURL!, rightEyeVideoURL: rightEyeVideoURL!, outputVideoURL: outputVideoURL!) { success, error in
|
||||
spatialVideoWriter.writeSpatialVideo(leftEyeVideoURL: leftEyeVideoURL!, rightEyeVideoURL: rightEyeVideoURL!, outputVideoURL: outputVideoURL!) {[self] success, error in
|
||||
DispatchQueue.main.async {
|
||||
SVProgressHUD.dismiss()
|
||||
}
|
||||
if success {
|
||||
print("空间视频生成成功")
|
||||
saveVideoToLibrary(videoURL:outputVideoURL!)
|
||||
DispatchQueue.main.async {
|
||||
SVProgressHUD.showSuccess(withStatus: "空间视频成功保存到相册")
|
||||
}
|
||||
@ -957,6 +968,19 @@ extension CCSpatialShootController: AVCaptureFileOutputRecordingDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
private func saveVideoToLibrary(videoURL: URL) {
|
||||
PHPhotoLibrary.shared().performChanges({
|
||||
PHAssetChangeRequest.creationRequestForAssetFromVideo(atFileURL: videoURL)
|
||||
}) { success, error in
|
||||
if success {
|
||||
print("保存成功")
|
||||
} else if let error = error {
|
||||
print("保存失败")
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//MARK: 空间图片合成
|
||||
private func firstFrame(from videoURL: URL) -> UIImage? {
|
||||
let asset = AVURLAsset(url: videoURL)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user