ofVideoGrabber performance

I’m using a simple ofVideoGrabber like this:

void ofApp::setup(){
    _videoGrabber.setup(1280, 720, OF_PIXELS_BGRA);
    _screenWidth = ofGetScreenWidth();
    _screenHeight = ofGetScreenHeight();

void ofApp::update(){

void ofApp::draw(){
    _videoGrabber.draw(0, 0, _screenWidth, _screenHeight);

On an iPhone 6 running iOS 9.1.3, the grabber starts smoothly, but the frame rate gets really bad after 5 seconds or so. Locking the phone and unlocking it restores the smooth frame rate, but it slows down again after further 5 seconds.

Is there a way to easily improve performance?

P. S.: I also posted this as an Issue on GitHub, in case it’s an ofVideoGrabber bug


I was answer your problem. but It was wrong.
I didn’t realized what exactly your question. your problem is about camera on iphone. right ?
and ofVideoGrabber’s update fps is going down. I Know. I was check it.

Meanwhile, I Found solution for maintain 30fps on runtime when grabbing camera frames.
(actually, I got same problem too. So, I need this solution just like you :grinning:)

1) I recommend turn to Release build mode. It is up to fps some 5~8 fps.
2) use [ AVFoundationVideoGrabber.h ] instead of [ videoGrabber ].

here is my test case

on my “iPhone 5s” let’s check fps in screen.

and some code is…


#include "ofxiOS.h"
#include "AVFoundationVideoGrabber.h"
class ofApp : public ofxiOSApp {

        ofFpsCounter fps;
        AVFoundationVideoGrabber fGrabber;
        ofImage img;
        ofTrueTypeFont font;

/// ... abridged ... ///


#include "ofApp.h"

void ofApp::setup(){	


    int w = 1280;
    int h = 720;


void ofApp::update()
        //pixels copy to ofImage
        ofPixels p;
        p.setFromPixels(fGrabber.getPixels() , fGrabber.getWidth() , fGrabber.getHeight() , fGrabber.getPixelFormat());

void ofApp::draw(){

    //draw copied image

Hope this hints helps you.

1 Like