gpt4 book ai didi

ios - Swift AVCaptureMovieFileOutput 找不到 URL

转载 作者:行者123 更新时间:2023-11-30 12:22:56 31 4
gpt4 key购买 nike

目前我正在尝试使用 AVCaptureMovieFileOutput 录制视频并将其保存到照片库。然而,一旦照片库的 URL 传递到 startRecording 函数,它就会声称“在此服务器上找不到所请求的 URL”。创建 URL 以便 startRecording 函数可以识别它的正确方法是什么?

以下是我初始化 URL 的方法:

paths = try FileManager.default.url(for: .picturesDirectory, in:.userDomainMask, appropriateFor: nil, create: false)
movieURL = try paths.appendingPathComponent("output.mov")

这是将 movieURL 传递给 startRecording 的函数:

func recordVideo(_sender: AnyObject?){
videoOutput.startRecording(toOutputFileURL: movieURL, recordingDelegate: mself)

let delayTime = 5.0
DispatchQueue.main.asyncAfter(deadline: DispatchTime.now()+delayTime){
print("stopping")
self.videoOutput.stopRecording()
}
}

这是错误消息:

完成可选(错误域=NSURLErrorDomain代码=-1100“在此服务器上找不到请求的URL。”UserInfo={NSLocalizedDescription=在此服务器上找不到请求的URL。,NSUnderlyingError=0x15e88cc0 {错误域=NSPOSIXErrorDomain Code=2“没有这样的文件或目录”},AVErrorRecordingSuccessivelyFinishedKey=false})x顶

任何帮助将不胜感激。

最佳答案

您正尝试将其保存在错误的目录中。您可以将其保存在 documentDirectory 中。有关保存应用程序文档的更多信息,您可以阅读有关 File System Basics 的 Apple 开发人员文档。 .

关于ios - Swift AVCaptureMovieFileOutput 找不到 URL,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/44573858/

31 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com