5

I am currently testing on iOS 8, on an iPhone 6. I am calling these APIs from Swift.

I'm trying to figure out why I can't call startRecordingToOutputFileURL more than once on a single instance of AVCaptureMovieFileOutput.

  • I am calling stopRecording before I call startRecordingToOutputFileURL again.
  • I am deleting the temporary video file before calling startRecordingToOutputFileURL.

The first time that I call startRecordingToOutputFileURL, the didStartRecordingToOutputFileAtURL delegate callback is fired. When I call stopRecording, the didFinishRecordingToOutputFileAtURL callback is fired.

After this, I delete the temporary file.

Then, when I call startRecordingToOutputFileURL the next time, the delegate callback is not fired. And when I call stopRecording a second time, the "finished" callback is not fired either.

The Apple docs for startRecordingToOutputFileURL say the following:

In iOS, this frame accurate file switching is not supported. You must call stopRecording before calling this method again to avoid any errors.

However, I am calling stopRecording before calling it again, and it is not working.

My current workaround is to remove the AVCaptureMovieFileOutput connection, initialize a new instance of AVCaptureMovieFileOutput, and then set up a new connection. This is terrible, because it takes a long time and freezes the video preview.

Please let me know if you know why this is happening, and if there is a fix.

UPDATE: I just noticed that if I toggle my AVCaptureSession sessionPreset to AVCaptureSessionPresetPhoto and then back to AVCaptureSessionPresetHigh, then I can start capturing video again.

UPDATE 2: Here's another way I can fix the problem:

    captureSession.stopRunning()
    captureSession.startRunning()

UPDATE 3: It turns out that this seems to be related to some code that captures the volume buttons - JPSVolumeButtonHandler. It doesn't happen when I comment out the code that starts JPSVolumeButtonHandler.

4

0 回答 0