【问题标题】:UISaveVideoAtPathToSavedPhotosAlbum not saving videos and returning error 0 abort with payloadUISaveVideoAtPathToSavedPhotosAlbum 不保存视频并返回错误 0 abort with payload
【发布时间】:2017-12-26 17:43:37
【问题描述】:

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

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 会抛出错误 Thread 8 signal SIGABART 0_abort_with_payload。我的代码与本节的 xcode 8 相比没有变化,但现在它崩溃了。除了此错误代码之外,我找不到此崩溃的原因。我怀疑这与我保存视频的方式有关。我已经尝试更改 appendingPathComponent,但没有任何区别。

【问题讨论】:

    标签: ios xcode video swift4 xcode9.2


    【解决方案1】:

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

    • NSPhotoLibraryAddUsageDescription(新)
    • NSPhotoLibraryUsageDescription
    • NSCameraUsageDescription
    • NSMicrophoneUsageDescription

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

    【讨论】:

      猜你喜欢
      • 2023-04-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-15
      • 2017-10-19
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多