Éste es el código
Código:
Después simplemente hago esto para iniciar la grabaciónsession = [[AVCaptureSession alloc] init]; [session beginConfiguration]; session.sessionPreset = AVCaptureSessionPresetPhoto; AVCaptureDevice *device = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo]; AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio]; AVCaptureDeviceInput *input = [AVCaptureDeviceInput deviceInputWithDevice:device error:nil]; AVCaptureDeviceInput *audioInput = [AVCaptureDeviceInput deviceInputWithDevice:audioDevice error:nil]; NSError *error; AVAudioSession *audioSession = [AVAudioSession sharedInstance]; [audioSession setCategory:AVAudioSessionCategoryRecord error:&error]; [audioSession setActive:YES error:&error]; [session addInput:input]; [session addInput:audioInput]; MovieFileOutput = [[AVCaptureMovieFileOutput alloc] init]; [session addOutput:MovieFileOutput];
Código:
Pero siempre me da lanza la excepción:NSString *outputPath = [[NSString alloc] initWithFormat:@"%@%@", NSTemporaryDirectory(), @"output2.mov"]; NSURL *outputURL = [[NSURL alloc] initFileURLWithPath:outputPath]; NSFileManager *fileManager = [NSFileManager defaultManager]; if ([fileManager fileExistsAtPath:outputPath]) { NSError *error; if ([fileManager removeItemAtPath:outputPath error:&error] == NO) { NSLog(@"error %@",error); //Error - handle if requried } } //Start recording @try{ NSLog(@"grabando..."); [MovieFileOutput startRecordingToOutputFileURL:outputURL recordingDelegate:self]; alreadyGrabando = YES; }@catch(NSException *e){}
Código:
Y al checar las entradas de audio y video:exception *** -[AVCaptureMovieFileOutput startRecordingToOutputFileURL:recordingDelegate:] - no active/enabled connections.
Código:
¿Alguien sabe cómo activar las entradas? "<AVCaptureConnection: 0x124799c50 [type:vide][enabled:1][active:0]>", "<AVCaptureConnection: 0x124794110 [type:soun][enabled:1][active:0]>"