2014-10-26 50 views
2

從IOS8開始,我在使用commitConfiguration時遇到了一個奇怪的問題 我們通過AVCaptureMovieFileOutput記錄了5個第二個文件。更改文件時,相機預覽閃爍並淡入黑色一秒鐘。在拼接接收服務器上的文件時也會出現口吃。IOS8:當記錄到文件並使用AVCaptureSession/commitConfiguration時,相機預覽閃爍

// 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]; 
    } 

回答

2

該解決方案非常簡單 - 不刪除和添加作家。感謝來自蘋果的bford的解釋! 這裏是更新的功能方法

// method that switches the output file 
- (void) switchOutputFile { 
    NSURL *outputUrl = [self getOutputFileUrl]; 
    NSLog(@"Switching to: %@", outputUrl); 
    [self.fileOutput startRecordingToOutputFileURL:outputUrl recordingDelegate:self]; 
}