Reputation: 255
Currently I am trying to use an AVCaptureMovieFileOutput to record video and save it to the photo library. 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." What is the proper way to create the URL so that the startRecording function can recognize it?
Here is how I initialize the 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:
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
Any help would be greatly appreciated.
Upvotes: 0
Views: 637
Reputation: 236380
You are trying to save it at the wrong directory. You can save it at the documentDirectory. For more information on where you can save your App documents you can read the Apple developer documents about File System Basics.
Upvotes: 0