IOS8:录制到文件并使用 AVCaptureSession/commitConfiguration 时相机预览闪烁

标签 ios ios8 avfoundation avcapturemoviefileoutput

从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/

相关文章:

iphone - 美国 iPhone 是否具有 AVSpeechSynthesizer 的英国语音? (要测试的示例代码)

iphone - touchesMoved 工作速度不够快

ios - 哪些限制会阻止我的 UIView 相互堆叠?

ios - swift 中的 AVfoundation - 如何包含多种文件类型

iphone - 有没有办法替换已经定义的预处理器标识符?

ios - Firemonkey Windows/iOS 兼容代码

memory-management - 奇怪的,零星的 CUI ... NSInvalidArgumentException 错误

ios - 在 iOS 8 中使用 NSMutableAttributedString 的字符串的下划线部分不起作用

ios - 反转音频文件 Swift/Objective-C

iOS AVAudioSession,如何访问AVAudioRecorder 电平表