fix CvVideoCamera defaultfps
This commit is contained in:
parent
157c94c03e
commit
2de3a24f46
@ -295,13 +295,27 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;}
|
|||||||
|
|
||||||
|
|
||||||
// set default FPS
|
// set default FPS
|
||||||
if ([self.videoDataOutput connectionWithMediaType:AVMediaTypeVideo].supportsVideoMinFrameDuration) {
|
AVCaptureDeviceInput *currentInput = [self.captureSession.inputs objectAtIndex:0];
|
||||||
[self.videoDataOutput connectionWithMediaType:AVMediaTypeVideo].videoMinFrameDuration = CMTimeMake(1, self.defaultFPS);
|
AVCaptureDevice *device = currentInput.device;
|
||||||
|
|
||||||
|
NSError *error = nil;
|
||||||
|
[device lockForConfiguration:&error];
|
||||||
|
|
||||||
|
float maxRate = ((AVFrameRateRange*) [device.activeFormat.videoSupportedFrameRateRanges objectAtIndex:0]).maxFrameRate;
|
||||||
|
if (maxRate > self.defaultFPS - 1 && error == nil) {
|
||||||
|
[device setActiveVideoMinFrameDuration:CMTimeMake(1, self.defaultFPS)];
|
||||||
|
[device setActiveVideoMaxFrameDuration:CMTimeMake(1, self.defaultFPS)];
|
||||||
|
NSLog(@"[Camera] FPS set to %d", self.defaultFPS);
|
||||||
|
} else {
|
||||||
|
NSLog(@"[Camera] unable to set defaultFPS at %d FPS, max is %f FPS", self.defaultFPS, maxRate);
|
||||||
}
|
}
|
||||||
if ([self.videoDataOutput connectionWithMediaType:AVMediaTypeVideo].supportsVideoMaxFrameDuration) {
|
|
||||||
[self.videoDataOutput connectionWithMediaType:AVMediaTypeVideo].videoMaxFrameDuration = CMTimeMake(1, self.defaultFPS);
|
if (error != nil) {
|
||||||
|
NSLog(@"[Camera] unable to set defaultFPS: %@", error);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[device unlockForConfiguration];
|
||||||
|
|
||||||
// set video mirroring for front camera (more intuitive)
|
// set video mirroring for front camera (more intuitive)
|
||||||
if ([self.videoDataOutput connectionWithMediaType:AVMediaTypeVideo].supportsVideoMirroring) {
|
if ([self.videoDataOutput connectionWithMediaType:AVMediaTypeVideo].supportsVideoMirroring) {
|
||||||
if (self.defaultAVCaptureDevicePosition == AVCaptureDevicePositionFront) {
|
if (self.defaultAVCaptureDevicePosition == AVCaptureDevicePositionFront) {
|
||||||
@ -329,7 +343,7 @@ static CGFloat DegreesToRadians(CGFloat degrees) {return degrees * M_PI / 180;}
|
|||||||
[self.videoDataOutput setSampleBufferDelegate:self queue:videoDataOutputQueue];
|
[self.videoDataOutput setSampleBufferDelegate:self queue:videoDataOutputQueue];
|
||||||
|
|
||||||
|
|
||||||
NSLog(@"[Camera] created AVCaptureVideoDataOutput at %d FPS", self.defaultFPS);
|
NSLog(@"[Camera] created AVCaptureVideoDataOutput");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user