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