我尝试过多次在上面的iOS 7版本中捕获240fps视频。但所有尝试都失败了。我的代码如下。
CGFloat frameRate = 240.f;
for (AVCaptureDeviceFormat *videoFormat in [self.inputCamera formats]) {
CMFormatDescriptionRef videoFormatDescriptionRef = videoFormat.formatDescription;
Float64 maxFrameRate = ((AVFrameRateRange *) [videoFormat.videoSupportedFrameRateRanges objectAtIndex:0]).maxFrameRate;
if (maxFrameRate >= frameRate && CMFormatDescriptionGetMediaSubType(videoFormatDescriptionRef) == kCVPixelFormatType_420YpCbCr8BiPlanarFullRange) {
if ([self.inputCamera lockForConfiguration:nil]) {
self.inputCamera.activeFormat = videoFormat;
[self.inputCamera setActiveVideoMinFrameDuration:CMTimeMake(600.f/(CGFloat)_frameRate, 600)];
[self.inputCamera setActiveVideoMaxFrameDuration:CMTimeMake(600.f/(CGFloat)_frameRate, 600)];
[self.inputCamera unlockForConfiguration];
}
}
}
AVCaptureConnection *connection = [videoOutput connectionWithMediaType:AVMediaTypeVideo];
if ( connection ) {
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)])
connection.videoMinFrameDuration = CMTimeMake(1, _frameRate);
if ([connection respondsToSelector:@selector(setVideoMaxFrameDuration:)])
connection.videoMaxFrameDuration = CMTimeMake(1, _frameRate);
#pragma clang diagnostic pop
}
如果我尝试直接将帧速率设置为240fps,它会崩溃。所以我必须在iOS和240 fps支持的值之间设置最小值。
有人可以帮助我吗?
问候。
答案 0 :(得分:1)