CameraManager icon indicating copy to clipboard operation
CameraManager copied to clipboard

cameraManager.stopVideoRecording closure not recording videos

Open omartehsin1 opened this issue 5 years ago • 11 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
            }
        })
    }

omartehsin1 avatar Aug 26 '19 23:08 omartehsin1

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.

Akash1604 avatar Aug 30 '19 05:08 Akash1604

i have the same problem

lvst avatar Apr 14 '20 04:04 lvst

@lvst

are you using the latest version v5.1.0? If not, can you please try it to see if the problem persists?

torrao avatar Apr 14 '20 08:04 torrao

I have the same problem but only if I change .cameraDevice from .front to .back. I'm using v5.1.0.

savasavic avatar Apr 14 '20 17:04 savasavic

@savasavic

thanks, I will look into it.

torrao avatar Apr 15 '20 08:04 torrao

@savasavic

couldn't replicate the issue. Can you please provide more steps to reproduce:

  • cameraManager setup;
  • device;
  • iOS version;
  • CameraManager version;

torrao avatar Apr 20 '20 14:04 torrao

@torrao

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

savasavic avatar Apr 20 '20 21:04 savasavic

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!

gsmalley10 avatar Jun 23 '20 16:06 gsmalley10

Could anyone fix this problem?

bluepixeltech avatar Jul 08 '21 19:07 bluepixeltech

I also had the same problem and gsmalley10's solution works - just move cameraManager.cameraOutputMode out of viewDidLoad and in the "shoot" button method.

infonotarydev avatar Sep 10 '21 14:09 infonotarydev

Please follow the instructions:

cameraManager.addLayerPreviewToView(cameraView, newCameraOutputMode: .videoOnly) { self.cameraManager.startRecordingVideo() }

absolutvodka8888 avatar May 08 '23 05:05 absolutvodka8888