简体   繁体   English

Swift AVCaptureMovieFileOutput无法找到URL

[英]Swift AVCaptureMovieFileOutput can't find URL

Currently I am trying to use an AVCaptureMovieFileOutput to record video and save it to the photo library. 目前,我正在尝试使用AVCaptureMovieFileOutput录制视频并将其保存到照片库。 However, once the URL of the photo library is passed to the startRecording function, it claims that "The requested URL was not found on this server." 但是,将图片库的URL传递给startRecording函数后,它声称“在此服务器上找不到请求的URL”。 What is the proper way to create the URL so that the startRecording function can recognize it? 创建URL以便s​​tartRecording函数可以识别它的正确方法是什么?

Here is how I initialize the URL: 这是我初始化URL的方法:

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

This is the function where movieURL is passed to startRecording: 这是将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()
    }
}

This is the error message: 这是错误消息:

Finished Optional(Error Domain=NSURLErrorDomain Code=-1100 "The requested URL was not found on this server." UserInfo={NSLocalizedDescription=The requested URL was not found on this server., NSUnderlyingError=0x15e88cc0 {Error Domain=NSPOSIXErrorDomain Code=2 "No such file or directory"}, AVErrorRecordingSuccessfullyFinishedKey=false}) xtopping 已完成可选(错误域= NSURLErrorDomain代码= -1100“在此服务器上找不到请求的URL。” UserInfo = {NSLocalizedDescription =在此服务器上找不到请求的URL。NSUnderlyingError= 0x15e88cc0 {错误域= NSPOSIXErrorDomain代码= 2 “没有这样的文件或目录”},AVErrorRecordingSuccessfullyFinishedKey = false})xtopping

Any help would be greatly appreciated. 任何帮助将不胜感激。

You are trying to save it at the wrong directory. 您试图将其保存在错误的目录中。 You can save it at the documentDirectory. 您可以将其保存在documentDirectory中。 For more information on where you can save your App documents you can read the Apple developer documents about File System Basics . 有关可以在何处保存您的App文档的更多信息,请阅读有关File System Basics的Apple开发人员文档。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM