cameraManager.stopVideoRecording closure not recording videos
omartehsin1 opened this issue · comments
I have a record button, I put breakpoints to see what was going on and it looks like startRecording is working, but when I press the button again (to change the state) it is not saving the file anywhere
var isRecording = false
isRecording = !isRecording
if isRecording {
cameraManager.startRecordingVideo()
print("Record button has been touched!")
print(isRecording)
} else {
print("it is not recording")
print(isRecording)
cameraManager.stopVideoRecording({ (videoURL, recordError) -> Void in
guard let videoURL = videoURL else {
//Handle error of no recorded video URL
print("not recording")
return
}
do {
try FileManager.default.copyItem(at: videoURL, to: self.myVideoURL)
//self.recordButton.backgroundColor = .green
}
catch {
//Handle error occured during copy
}
})
}
I am facing the same problem
Scenario is:
When you give some time to record video, stop recording delegate will not give call back.
It will happen randomly not every time.
i have the same problem
are you using the latest version v5.1.0? If not, can you please try it to see if the problem persists?
I have the same problem but only if I change .cameraDevice from .front to .back. I'm using v5.1.0.
thanks, I will look into it.
couldn't replicate the issue. Can you please provide more steps to reproduce:
- cameraManager setup;
- device;
- iOS version;
- CameraManager version;
steps to reproduce:
- start recording with front camera
- change camera to back camera
cameraManager.cameraDevice = (cameraManager.cameraDevice == CameraDevice.front ? CameraDevice.back : CameraDevice.front)
- stop recording
cameraManager.stopVideoRecording({ (videoURL, recordError) -> Void in
})
(closure not called because runningMovieOutput.isRecording is false)
device: iPhone 11 pro max
iOS version: 13.3.1
camera manager: latest version
I had this same issue on version 5.1.3 but was able to fix it by moving my cameraManager.cameraOutputMode = .videoWithMic
line to be outside of my viewDidLoad
.
I think there's a race condition somewhere that prevents that line from taking effect if it's called inside of viewDidLoad
. cameraOutputMode
will stay set to the default .stillImage
, which prevents the video recording from even starting in the first place (and so of course runningMovieOutput.isRecording
will be false and the .stopVideoRecording
callback won't get executed). It wasn't until I moved that line to be right before my call to .startRecordingVideo()
that everything started working normally.
On top of that, there's code inside of .startRecordingVideo()
that looks like it will warn the user if the output mode is set as .stillImage
, but for whatever reason it didn't pop up in the console for me...
Also, I didn't see anything in the documentation that warns about trying to set the cameraOutputMode
inside of viewDidLoad
, but maybe I just missed it. If that's the case, sorry!
Could anyone fix this problem?
I also had the same problem and gsmalley10's solution works - just move cameraManager.cameraOutputMode out of viewDidLoad and in the "shoot" button method.
Please follow the instructions:
cameraManager.addLayerPreviewToView(cameraView, newCameraOutputMode: .videoOnly) {
self.cameraManager.startRecordingVideo()
}