从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];
}
最佳答案
解决办法很简单——不删除并添加writer。感谢苹果公司bford的解释! 这是更新后的函数方法
// method that switches the output file
- (void) switchOutputFile {
NSURL *outputUrl = [self getOutputFileUrl];
NSLog(@"Switching to: %@", outputUrl);
[self.fileOutput startRecordingToOutputFileURL:outputUrl recordingDelegate:self];
}
关于IOS8:录制到文件并使用 AVCaptureSession/commitConfiguration 时相机预览闪烁,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26573580/