Loading Videos via ofThread


I have a number of videos inside an app, too many to load them all in setup.

I have them loading fine on selection. However I get the 2-3 second freeze while it loads.

I tried to get the ofxThreadedVideo addon working, however I had to give up eventually and try and load the videos via ofThread myself.

I’ve managed to get to a good place based on what I’ve read on this forum. However I can’t get past the final hurdle.

I suppose my main question is just confirmation that this is possible? I’m getting errors that say “QTMovie_QuickTime class must be initialized on the main thread.”. Making me question if it’s ever going to work.

This is what I have in my videoThread.h class, is anyone able to confirm that I’m going in the right direction with this?



#ifndef videoThread_h
#define videoThread_h

#include "ofMain.h"

class videoThread : public ofThread{


ofVideoPlayer *asset;
bool assetLoaded;

    assetLoaded = false;
    asset = new ofVideoPlayer;
void start(){
    startThread(true, false);
void stop(){
unsigned char *getMovie(){
    return asset->getPixels();
void threadedFunction(){
    while(isThreadRunning()!= 0){
            assetLoaded = true;


Any news on that topic? I tried to use the ofxThreadedVideo addon with no success, so I decided to build my own threaded class to load videos. But I am facing the same error (“QTMovie_QuickTime class must be initialized on the main thread”). Have you been able to resolve the problem?

Hi! I am on the same situation :frowning:
Anybody has any update? Is v0.9.0 giving any news on this?

Hello again,
I am sorry if this is just too noobie but I feel a bit confused. Sometimes is not that easy to jump into conversations regarding versions, SDKs, toolkits, frames and libraries, even more when the versions have changed a lot during the last 3 years.
I have tried to go with ofxThreadedVideo, use 10.6 SDK and so but couldn’t not make it work under XCode 7 + 10.11.
In addition, OF v0.9.0 has appeared lately and I wonder if it can help some how.
It is my understanding that the main problem with loading videos on threads is that if you try to load a video outside the openGL thread you have to do it through pixels instead of textures.
Also, it looks like QT has to be used on the main thread, regarding the older posts in this thread. Am I correct so far?

Also, it is my understanding that now OF v0.9.0 deals with videos thorugh AVFoundation, correct? -I am also having problems to load streaming videos with .load() in v.0.9.0 but that’s a completly different story…- Is then a solution to go with pixels through AVFoundation?
Thanks again, and sorry for such a long post…

in 0.9.0 you can call loadAsync("filepath") and it’ll load the video in the background. you need to wait until isFrameNew returns true to be able to use the player

Thanks!!! I wil try it asap! I will get back once I have it

this loadasync function seems interesting- though it’s not implemented in the windows version, isnt it?

no, not yet, only in osx with the avfoundation player and in gstreamer implementation, you can use ofxGStreamer if you need something faster than the current directshow implementation in windows