从IOS8开始,我在使用commitConfiguration的时候遇到了一个奇怪的问题我们通过AVCaptureMovieFileOutput录制了5秒的文件。更改文件时,相机预览会闪烁并变黑一秒钟。在接收服务器上缝合文件时也会出现口吃。
// 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];
}