videoMinFrameDuration is Deprecated

瘦欲@ 提交于 2019-12-22 14:03:56

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!