IOS8: предварительный просмотр камеры мерцает при записи в файл и использовании AVCaptureSession/commitConfiguration
Начиная с IOS8, я испытываю странную проблему при использовании commitConfiguration. Мы записываем 5-секундные файлы через AVCaptureMovieFileOutput. При изменении файлов предварительный просмотр камеры на секунду мигает и становится черным. Также возникает заикание при зашивании файлов на принимающем сервере.
// 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];
}
1 ответ
Решение
Решение очень простое - не удалять, а добавлять писателя. спасибо bford из apple за объяснение! Вот обновленный метод функции
// method that switches the output file
- (void) switchOutputFile {
NSURL *outputUrl = [self getOutputFileUrl];
NSLog(@"Switching to: %@", outputUrl);
[self.fileOutput startRecordingToOutputFileURL:outputUrl recordingDelegate:self];
}