问题
According to this document the properties and methods relating to video-frame maximum and minimum duration:
supportsVideoMaxFrameDuration
supportsVideoMinFrameDuration
videoMaxFrameDuration
videoMinFrameDuration
have all been deprecated. Are there alternatives?
回答1:
According to the header file (AVCaptureSession.h),
This property is deprecated on iOS, where min and max frame rate adjustments are applied exclusively at the AVCaptureDevice using the activeVideoMinFrameDuration and activeVideoMaxFrameDuration properties.
回答2:
in iOS7 using the following sequence I get it running at the frame rate I specify (I also had a few problems using activeVideoMinFrameDuration, but this seems to be a working solution):
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];
where catpureSession is an object of class AVCaptureSession and samplingFrequency is my frame rate (set to 30)
来源:https://stackoverflow.com/questions/19168970/alternatives-to-deprecated-avcaptureconnection-frame-duration-properties