大佬教程收集整理的这篇文章主要介绍了ios – 我想在AVCapture框架中限制视频捕获帧速率,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
目前,它从摄像机捕获帧,然后尽快使用OpenGL例程处理帧.我想在捕获过程中设置一个特定的帧速率.
我希望能够通过使用videoMinFrameDuration或minFrameDuration来实现这一点,但这似乎对性能没有任何影响.有任何想法吗?
NSArray *devices = [AVCaptureDevice devicesWithMediaType:AVMediaTypeVideo]; for (AVCaptureDevice *device in devices) { if ([device position] == AVCaptureDevicePositionBACk) { BACkFacingCamera = device; // SET SOME OTHER PROPERTIES } } // Create the capture session captureSession = [[AVCaptureSession alloc] init]; // Add the video input NSError *error = nil; videoInput = [[[AVCaptureDeviceInput alloc] initWithDevice:BACkFacingCamera error:&error] autorelease]; // Add the video frame output videoOutput = [[AVCaptureVideoDataOutput alloc] init]; [videoOutput setAlwaysDiscardsLateVideoFrames:YES]; [videoOutput setVideoSetTings:[NSDictionary DictionaryWithObject:[NSnumber numberWithInt:kCVPixelFormatType_32BGRA] forKey:(id)kCVPixelBufferPixelFormatTypeKey]]; [videoOutput setSampleBufferDelegate:self queue:dispatch_get_main_queue()]; // Start capturing if([BACkFacingCamera supportsAVCaptureSessionPreset:AVCaptureSessionPreset1920x1080]) { [captureSession setSessionPreset:AVCaptureSessionPreset1920x1080]; captureDeviceWidth = 1920; captureDeviceHeight = 1080; #if Defined(VA_DEBUG) NSLog(@"Video AVCaptureSessionPreset1920x1080"); #endif } else do some fall BACk stuff // If you wish to cap the frame rate to a kNown value,such as 15 fps,set // minFrameDuration. AVCaptureConnection *conn = [videoOutput connectionWithMediaType:AVMediaTypeVideo]; if (conn.supportsVideoMinFrameDuration) conn.videoMinFrameDuration = CMTimeMake(1,2); else videoOutput.minFrameDuration = CMTimeMake(1,2); if ([captureSession canAddInput:videoInput]) [captureSession addInput:videoInput]; if ([captureSession canAddOutput:videoOutput]) [captureSession addOutput:videoOutput]; if (![captureSession isRunning]) [captureSession startRunning];
有任何想法吗?我错过了什么吗?这是节流的最好方法吗?
AVCaptureConnection *conn = [videoOutput connectionWithMediaType:AVMediaTypeVideo]; if (conn.supportsVideoMinFrameDuration) conn.videoMinFrameDuration = CMTimeMake(1,2);
int fps = 30; // Change this value AVCaptureDevice *device = ...; // Get the active capture device [device lockForConfiguration:nil]; [device setActiveVideoMinFrameDuration:CMTimeMake(1,fps)]; [device setActiveVideoMaxFrameDuration:CMTimeMake(1,fps)]; [device unlockForConfiguration];
以上是大佬教程为你收集整理的ios – 我想在AVCapture框架中限制视频捕获帧速率全部内容,希望文章能够帮你解决ios – 我想在AVCapture框架中限制视频捕获帧速率所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。