根据本文档,与视频帧最大和最小持续时间有关的属性和方法:
supportsVideoMaxFrameDuration
supportsVideoMinFrameDuration
videoMaxFrameDuration
videoMinFrameDuration
已全部弃用。有替代品吗?
根据本文档,与视频帧最大和最小持续时间有关的属性和方法:
supportsVideoMaxFrameDuration
supportsVideoMinFrameDuration
videoMaxFrameDuration
videoMinFrameDuration
已全部弃用。有替代品吗?
根据头文件(AVCaptureSession.h),
此属性在 iOS 上已弃用,其中最小和最大帧速率调整仅在 AVCaptureDevice 上使用 activeVideoMinFrameDuration 和 activeVideoMaxFrameDuration 属性应用。
在 iOS7 中使用以下序列,我让它以我指定的帧速率运行(使用 activeVideoMinFrameDuration 时我也遇到了一些问题,但这似乎是一个可行的解决方案):
AVCaptureDevice* camera = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
if([camera isTorchModeSupported:AVCaptureTorchModeOn]) {
[camera lockForConfiguration:nil];
//configure frame rate
[camera setActiveVideoMaxFrameDuration:CMTimeMake(1, samplingFrequency)];
[camera setActiveVideoMinFrameDuration:CMTimeMake(1, samplingFrequency)];
[camera unlockForConfiguration];
}
AVCaptureInput* cameraInput = [[AVCaptureDeviceInput alloc] initWithDevice:camera error:nil];
AVCaptureVideoDataOutput* videoOutput = [[AVCaptureVideoDataOutput alloc] init];
dispatch_queue_t captureQueue=dispatch_queue_create("catpureQueue", DISPATCH_QUEUE_SERIAL);
//setup delegate
[videoOutput setSampleBufferDelegate:self queue:captureQueue];
videoOutput.videoSettings = [NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithUnsignedInt:kCVPixelFormatType_32BGRA], (id)kCVPixelBufferPixelFormatTypeKey,
nil];
[catpureSession setSessionPreset:AVCaptureSessionPresetMedium];
if([catpureSession canAddInput:cameraInput])
[catpureSession addInput:cameraInput];
if([catpureSession canAddOutput:videoOutput])
[catpureSession addOutput:videoOutput];
[catpureSession startRunning];
其中catpureSession是类AVCaptureSession的对象,而samplingFrequency是我的帧速率(设置为 30)