Ever since IOS8, I am experiencing a strange problem when using commitConfiguration We record 5 second files via AVCaptureMovieFileOutput. When changing the files, the camera preview flickers and fades to black for a second. Also there is a stutter when stitching back the files on the receiving server.
// method that switches the output file
- (void) switchOutputFile {
NSURL *outputUrl = [self getOutputFileUrl];
NSLog(@"Switching to: %@", outputUrl);
// begin configuration
[self.captureSession beginConfiguration];
// remove the current writer
[self.captureSession removeOutput:self.fileOutput];
// attach new writer
self.fileOutput = [self attachFileWriter:self.captureSession];
// commit configuration
[self.captureSession commitConfiguration];
// after this line the camera preview flickers.
[self.fileOutput startRecordingToOutputFileURL:outputUrl recordingDelegate:self];
}
The solution is very simple - not remove and add the writer. thanks to bford from apple for the explanation! Here is the updated function method
// method that switches the output file
- (void) switchOutputFile {
NSURL *outputUrl = [self getOutputFileUrl];
NSLog(@"Switching to: %@", outputUrl);
[self.fileOutput startRecordingToOutputFileURL:outputUrl recordingDelegate:self];
}