AVCaptureSession *session = [[AVCaptureSession alloc] init];[session beginConfiguration];session.sessionPreset = AVCaptureSessionPresetMedium;CALayer *vIEwLayer = self.vImagePrevIEw.layer;NSLog(@"vIEwLayer = %@",vIEwLayer);AVCaptureVIDeoPrevIEwLayer *captureVIDeoPrevIEwLayer = [[AVCaptureVIDeoPrevIEwLayer alloc] initWithSession:session];captureVIDeoPrevIEwLayer.vIDeoGravity = AVLayerVIDeoGravityResizeAspectFill;captureVIDeoPrevIEwLayer.frame = self.vImagePrevIEw.bounds;[self.vImagePrevIEw.layer addSublayer:captureVIDeoPrevIEwLayer];AVCaptureDevice *device = [self frontFacingCameraifAvailable];NSError *error = nil;AVCaptureDeviceinput *input = [AVCaptureDeviceinput deviceinputWithDevice:device error:&error];if (!input) { // Handle the error appropriately. NSLog(@"ERROR: trying to open camera: %@",error);}NSArray *paths = NSSearchPathForDirectorIEsInDomains(NSdocumentDirectory,NSUserDomainMask,YES);Nsstring *documentsDirectoryPath = [paths objectAtIndex:0];AVCaptureMovIEfileOutput *movIEfileOutput = [[AVCaptureMovIEfileOutput alloc] init];Nsstring *archives = [documentsDirectoryPath stringByAppendingPathComponent:@"archives"];Nsstring *outputpathofmovIE = [[archives stringByAppendingPathComponent:@"Test"] stringByAppendingString:@".mp4"];NSURL *outputURL = [[NSURL alloc] initfileURLWithPath:outputpathofmovIE];[session addinput:input];[session addOutput:movIEfileOutput];[session commitConfiguration];[session startRunning];[movIEfileOutput startRecordingToOutputfileURL:outputURL recordingDelegate:self];
我为音频添加了另一个输入,但它不能与后台的mpmovIEplayercontroller一起使用.有什么想法可以播放一个视频,同时记录相机的音频和视频?
解决方法 您尚未包括音频设备:AVCaptureDevice *audioDevice = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeAudio];AVCaptureDeviceinput * audioinput = [AVCaptureDeviceinput deviceinputWithDevice:audioDevice error:nil];[session addinput:audioinput]
在beginConfiguration和commitConfiguration之间.它会工作!
总结以上是内存溢出为你收集整理的ios – AVCaptureSession录制视频与音频全部内容,希望文章能够帮你解决ios – AVCaptureSession录制视频与音频所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)