UISaveVideoAtPathToSavedPhotosAlbum不保存视频并返回错误0中止有效负载

问题描述 投票:1回答:1

这是我开始录制会话的代码。

var recordingDelegate:AVCaptureFileOutputRecordingDelegate? = self
        cameraSession.beginConfiguration()
        self.cameraSession.addOutput(videoFileOutput)
        cameraSession.commitConfiguration()
        let documentsURL = FileManager.default.urls(for: .documentDirectory, in: .userDomainMask)[0]
        filePath = documentsURL.appendingPathComponent("temp.mp4")


        videoFileOutput.startRecording(toOutputFileURL: filePath, recordingDelegate: recordingDelegate)

这是录制视频后的代码。

        self.videoFileOutput.stopRecording()
        UISaveVideoAtPathToSavedPhotosAlbum((filePath?.relativePath)!, nil, nil, nil)
        cameraSession.beginConfiguration()
        cameraSession.removeOutput(videoFileOutput)
        cameraSession.commitConfiguration()

这个用法在xcode 9出现之前工作,但是现在当我试图停止我的视频时它会崩溃我的应用程序并且xcode抛出错误线程8信号SIGABART 0_abort_with_payload。我的代码没有从xcode 8这个部分改变,但现在它崩溃了。除了这个错误代码之外,我找不到这次崩溃的原因。我怀疑它与我如何保存视频有关。我试过更改appendingPathComponent,但没有区别。

ios xcode video swift4 xcode9.2
1个回答
0
投票

您必须在信息plist中填写新的权限字符串 - 其中一些是Xcode 9和iOS 11的新功能。检查信息plist中的以下键是否存在:

  • NSPhotoLibraryAddUsageDescription(新)
  • NSPhotoLibraryUsageDescription
  • NSCameraUsageDescription
  • NSMicrophoneUsageDescription

你可能不需要所有这些 - 但其中一些肯定。 (我敢打赌,第一个更新的是Gotcha)

© www.soinside.com 2019 - 2024. All rights reserved.