-1

I am working with some computer vision algorithms that require me to work on lower frame rates ~ sometimes even 7-10 fps.

The issue is that I don't want the user to have a poor experience when using the app but I still want to process at a lower frame rate. Is there a builtin API to do this?

I don't have to go into the delegate method and manually drop frames myself and work on the ones that are required.

p0lAris
  • 4,750
  • 8
  • 45
  • 80

1 Answers1

1

It's kinda hard / nearly impossible to drop frames manually without screwing your video but you can configure your encoder like this

// in you initialisation code
NSError *err;
AVCaptureDevice* dev = [AVCaptureDevice defaultDeviceWithMediaType:AVMediaTypeVideo];
[dev lockForConfiguration:&err];
[self configureCameraForFrameRate:dev frameRate:10];
[dev unlockForConfiguration];
 - (void)configureCameraForFrameRate:(AVCaptureDevice *)device frameRate:(NSInteger)rate;
{
    AVCaptureDeviceFormat *bestFormat = nil;
    AVFrameRateRange *bestFrameRateRange = nil;
    for ( AVCaptureDeviceFormat *format in [device formats] ) {
        for ( AVFrameRateRange *range in format.videoSupportedFrameRateRanges ) {
            if ( range.maxFrameRate > bestFrameRateRange.maxFrameRate ) {
                bestFormat = format;
                bestFrameRateRange = range;
            }
        }
    }
    if ( bestFormat ) {
        device.activeFormat = bestFormat;
        CMTime time = CMTimeMake(1, rate);
        device.activeVideoMinFrameDuration = time;
        //NSLog(@"%d %lld",bestFrameRateRange.minFrameDuration.timescale, bestFrameRateRange.minFrameDuration.value);
        device.activeVideoMaxFrameDuration = time;
    }
}

Not sure it's the best way to achieve this but ... ^^'

HaneTV
  • 916
  • 1
  • 7
  • 24
  • Well this is pretty much what I have but this doesn't solve the issue. This still shows the user that he is capturing at 10fps and not 30fps. What I need is to create an illusion that the user captures at 30fps even if the frames are processed at 7fps. – p0lAris Jul 09 '14 at 11:34
  • Maybe you want to read the question and talk properly. Either will work. – p0lAris Mar 15 '15 at 23:14
  • @p0lAris the Q says 7-10fps, your comment is "This still shows the user that he is capturing at 10fps and not 30fps", wut? You can skip frames or limit framerate, either will work. – pronebird Mar 15 '15 at 23:39