我正在iOS上開發一個應用程序。我需要從相機捕捉視頻,我需要將該視頻記錄到一個文件,並獲得未壓縮的幀,這就是爲什麼我需要同時使用AVCaptureOutput ...我可以在同一個會話中使用AVCaptureVideoDataOutput和AVCaptureMovieFileOutput嗎?
我在蘋果的文檔中閱讀了這篇文章「你可以配置多個輸入和輸出,由單個會話協調:」所以我認爲它必須是可行的,但我有與它的問題...
我都設置爲會議做:
self.fileOutput.maxRecordedDuration = CMTimeMake(5000,1);;
self.fileOutput.minFreeDiskSpaceLimit = 3000;
if([self.captureSession canAddOutput:self.fileOutput]){
[self.captureSession addOutput:self.fileOutput];
NSLog(@"Added File Video Output");
}else{
NSLog(@"Couldn't add video output");
}
if ([self.captureSession canAddOutput:videoOutput]){
[self.captureSession addOutput:videoOutput];
NSLog(@"Added Data Video Output");
}else{
NSLog(@"Couldn't add video output");
}
我收到了'正面'確認信息。在那之後我打電話來:
NSString *assetPath = [self createAssetFilePath:@"mov"];
NSURL *outputURL = [[NSURL alloc] initFileURLWithPath:assetPath];
[self.fileOutput startRecordingToOutputFileURL:outputURL recordingDelegate:self];
[self.captureSession startRunning];
然後,我有我的委託函數:
- (void)captureOutput:(AVCaptureFileOutput *)captureOutput didFinishRecordingToOutputFileAtURL:(NSURL *)outputFileURL fromConnections:(NSArray *)connections error:(NSError *)error {
NSLog(@"Output File URL: %@ ", outputFileURL);
BOOL recordedSuccessfully = YES;
if ([error code] != noErr) {
NSLog(@"Error: %@", error);
id value = [[error userInfo] objectForKey:AVErrorRecordingSuccessfullyFinishedKey];
NSLog(@"Error: %@", value);
if (value) {
recordedSuccessfully = [value boolValue];
}
}
}
而且我沒有得到任何錯誤,但「AVCaptureVideoDataOutput」被添加「AVCaptureMovieFileOutput前的工作「而現在它不是......
所以......這樣做可能嗎?!任何想法?!
謝謝!
感謝您的回答! – Andres