问题
When I have updated Xcode from 4.6 to 5.1 `'videoMinnFrameDuration' is deprecated in 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);
回答1:
For one thing, you're using an outdated version of GPUImage, as this is has been fixed in the framework code for almost a year now. Update your local framework version.
The way I address this in GPUImage, since I still need to use this method for old iOS versions, is to disable deprecation checks around the relevant code:
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
}
}
If the new property (activeVideoMinFrameDuration
) is available, we use that. If not, it falls back to the now-deprecated method. Since we know it's deprecated, there's no need to have the compiler warn us about this.
回答2:
In AVCaptureSession.h class of AVFoundation it mention by following comment.
@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.
来源:https://stackoverflow.com/questions/24606778/videominframeduration-is-deprecated