4
iOS4의 새로운 API를 사용하여 iPhone의 카메라 및 마이크에서 입력을 캡처하여 파일에 저장하려고합니다. 아래 코드는 제가 사용하고있는 코드입니다.카메라 및 오디오 입력을 캡처 할 때 오류가 발생했습니다.
AVCaptureSession* captureSession = [[AVCaptureSession alloc] init];
AVCaptureDevice *audioCaptureDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];
AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioCaptureDevice error:&error];
AVCaptureDeviceInput* videoInput = [[AVCaptureDeviceInput alloc] initWithDevice:captDevice error:&error];
AVCaptureMovieFileOutput * videoOutput = [[AVCaptureMovieFileOutput alloc] init];
if (videoInput && videoOutput && audioInput)
{
[captureSession addInput:audioInput];
[captureSession addInput:videoInput];
[captureSession addOutput:videoOutput];
if([captDevice lockForConfiguration:&error])
{
if ([captDevice hasTorch])
captDevice.torchMode = AVCaptureTorchModeOn;
[captDevice unlockForConfiguration];
}
else
{
NSLog(@"Could not lock device for config error: %@", error);
}
NSArray *paths = NSSearchPathForDirectoriesInDomains(NSDocumentDirectory, NSUserDomainMask, YES);
NSString *documentsDirectory = [paths objectAtIndex:0];
NSURL* saveLocationURL = [[NSURL alloc] initFileURLWithPath:[NSString stringWithFormat:@"%@/movie.mov", documentsDirectory]];
[videoOutput startRecordingToOutputFileURL:saveLocationURL recordingDelegate:self];
[captureSession startRunning];
[saveLocationURL release];
}
else
{
NSLog(@"Video Error: %@", error);
}
didFinishRecordingToOutputFileAtURL이 돌아 왔을 때 나는 이상한 오류 응답을받습니다.
Error Domain=AVFoundationErrorDomain Code=-11803 "Cannot Record" UserInfo=0x152f70 {NSLocalizedRecoverySuggestion=Try recording again., AVErrorRecordingSuccessfullyFinishedKey=false, NSLocalizedDescription=Cannot Record}
오류 코드 -11803은 "AVErrorSessionNotRunning"을 의미합니다. 내가 말할 수있는 전부는 내가 모르는 뭔가를 말해 준다. 누구나 세션이 실행되지 않는 이유를 알 수 있습니까?
신고 된 문제가 해결되었지만 이제는 새로운 오류가 발생합니다. 오류 도메인 = NSOSStatusErrorDomain 코드 = -12673 "작업을 완료 할 수 없습니다 (OSStatus 오류 -12673)."UserInfo = 0x154190 {AVErrorRecordingSuccessfullyFinishedKey = false} – iHorse
movie.mov가 이미 있습니까? "stringByAppendingPathComponent :"도 참조하십시오. –
해당 파일이 없습니다. 그럴까? – iHorse