AVCaptureSession does not start AVCaptureSessionWasInterruptedNotification, cannot determine source of interrupt

I have a video camcorder built similar to the Apple AVCam demo. I ran into a very nasty problem that I don’t know how to do debugging.

In principle, we are talking about setting up the camcorder on the view controller. When VC appears, the previewer should show what the camera sees and, after pressing the record button, starts recording to a file.

This works 20% of the time. The rest of the time, VC loads normally, but the preview layer freezes after 1-3 seconds. After freezing, I do not get any crashes or errors reset [EDIT: Not true, see below] . However, if I hit a record after freezing it, which causes a call

[self.fileOutput startRecordingToOutputFileURL:currentVideoURL recordingDelegate:self];

I immediately get a call to the AVCaptureFileOutputRecordingDelegate method

-(void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error

The NSError object is set with error code -11803 {AVErrorSessionNotRunning}. This method, of course, starts after a call to [captureSession startRunning].

UPDATE

Something causes the session to terminate immediately. The captureSession.isInterrupted function is set to TRUE almost immediately after the recording starts, and the following notifications are triggered immediately after the session starts:

AVCaptureSessionWasInterruptedNotification
AVCaptureSessionDidStopRunningNotification  (edit -- had the wrong const here)

What can cause a session to terminate immediately after starting?

- , AVCaptureSession?

+5

All Articles