当我将Xcode从4.6更新到5.1时,“VideoMinnFrameDuration”'在ios7中弃用
- (void)setFrameRate:(NSInteger)frameRate;
{
_frameRate = frameRate;
if (_frameRate > 0)
{
for (AVCaptureConnection *connection in videoOutput.connections)
{
if ([connection respondsToSelector:@selector(setVideoMinFrameDuration:)])
connection.videoMinFrameDuration = CMTimeMake(1,_frameRate);
答案 0 :(得分:5)
首先,您使用的是过时版本的GPUImage,因为这已经在框架代码中修复了近一年了。更新您的本地框架版本。
我在GPUImage中解决这个问题的方法,因为我仍然需要对旧iOS版本使用此方法,是禁用相关代码的弃用检查:
if ([_inputCamera respondsToSelector:@selector(setActiveVideoMinFrameDuration:)] &&
[_inputCamera respondsToSelector:@selector(setActiveVideoMaxFrameDuration:)]) {
NSError *error;
[_inputCamera lockForConfiguration:&error];
if (error == nil) {
#if defined(__IPHONE_7_0)
[_inputCamera setActiveVideoMinFrameDuration:CMTimeMake(1, _frameRate)];
[_inputCamera setActiveVideoMaxFrameDuration:CMTimeMake(1, _frameRate)];
#endif
}
[_inputCamera unlockForConfiguration];
} else {
for (AVCaptureConnection *connection in videoOutput.connections)
{
#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
}
}
如果新属性(activeVideoMinFrameDuration
)可用,我们会使用它。如果没有,它将回退到现在已弃用的方法。由于我们知道它已被弃用,因此没有必要让编译器向我们发出警告。
答案 1 :(得分:0)
在AVCaptureSession.h类的AVFoundation中,它通过以下评论提及。
@property supportsVideoMinFrameDuration
@abstract
Indicates whether the connection supports setting the videoMinFrameDuration property.
@discussion
This property is only applicable to AVCaptureConnection instances involving
video. In such connections, the videoMinFrameDuration property may only be set if
-isVideoMinFrameDurationSupported returns YES.
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. On Mac OS X, frame rate adjustments are supported both at the AVCaptureDevice
and at AVCaptureConnection, enabling connections to output different frame rates.