2

从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];
  } 
4

1 回答 1

2

解决方案非常简单——不要删除和添加作者。感谢苹果的 bford 的解释!这是更新的函数方法

// method that switches the output file
- (void) switchOutputFile {
    NSURL *outputUrl = [self getOutputFileUrl];
    NSLog(@"Switching to: %@", outputUrl);
    [self.fileOutput startRecordingToOutputFileURL:outputUrl recordingDelegate:self];
}
于 2014-10-28T11:47:21.300 回答