Loading an ofMoviePlayer in a thread not working correctly


I have to load one movie every time an event happens. So, to avoid preloading all of them, I am loading them on demand. But there is a noticeable short freeze whenever a movie is loaded (I’m running this on a Raspberry Pi 3).

So I decided to load the movies in a thread using an ofThreadChannel to send it back to the main process.

The movies play fine when I’m not using threads. But with threads I get all sorts of errors and, even though the first movie still plays correctly, the next movies I load just draw a white image.

The first movie just says this:
2017-05-13 01:36:21.909551+0100 vela2017Debug[53924:9456510] video loaded at 1280 x 720 @ 25.000000 fps

The second movie says this:
2017-05-13 01:35:10.602445+0100 vela2017Debug[53882:9454172] video loaded at 1280 x 720 @
25.000000 fps
2017-05-13 01:35:10.602804+0100 vela2017Debug[53882:9454151] AVD error: Perf capability check
failed: 0xe00002be
[warning] ofAVFoundationPlayer: load(): error when creating texture cache, -6661.

The third movie starts yielding these messages on every frame:
[ error ] ofAVFoundationPlayer: initTextureCache(): error creating texture cache from image -6661.
[ error ] ofAVFoundationPlayer: initTextureCache(): error creating texture cache from image -6661.
[ error ] ofAVFoundationPlayer: initTextureCache(): error creating texture cache from image -6661.

Is it really not possible to load an ofMoviePlayer nor ofxOMXPlayer in a thread?
Or is the problem related to ofThreadChannel?

Any ideas are welcome!

Thanks in advance,

the video players usually create a texture and that has to be created in the main thread, the easiest is to use loadAsync() which loads the movie without interrupting the main thread

1 Like

Hello @arturo, thank you so much. I hadn’t found loadAsync() which completely solves my problem in the mac. But I’ll be running the app in a Raspberry. And for some reason ofMoviePlayer is very slow in a Raspberry so I decided to use ofxOMXPlayer which unfortunately doesn’t implement loadAsync().

I already tried to load the movie without texture and only enable it in the main thread but stil l didn’t manage to make it work smoothly.

I’ll write another post asking why ofMoviePlayer is so slow in Raspberry Pi 3? With a 720p video I’m getting 2fps with ofVideoPlayer against 50fps with the ofxOMXPlayer. I hope there is a way to make it fast.

Thanks for your help!

try using OF_PIXELS_NATIVE to set the pixel format of the video player, that avoids a series of conversions in the cpu which make the playback much faster:


for this you’ll need to use openGL ES 2 since it needs some shaders to do the conversions that would otherwise be done in cpu, in you main.cpp, like: https://gist.github.com/arturoc/5880704601cb57b872c48385c10a1db6

1 Like

I had tried OF_PIXELS_NATIVE because I read it somewhere but I believe didn’t change the main.cpp to use openGL ES 2. I’ll give it a try later today. Thanks again!

also be sure you are compiling your applications in release not debug

Oh, really? Why? Is the performance really that different? Although I was going to do it once the development was ready I didn’t think it would make much difference. Cheers for that!

Hello @arturo,

I have tried OF_PIXELS_NATIVE with openGL ES 2 and it is indeed faster… but not fast enough.

  • Without your suggestion, I was getting around 2fps.
  • With your suggestion I am now getting around 15fps
  • The movie is 25fps
  • ofxOMXPlayer pulls of 50fps easily even in textured mode (which I need because I’m using alpha)


Do you think your suggested tweak should give me better performance than what I’m getting?

Any suggestions are welcome.

Until then I’ll have to keep on:

  • using ofxOMXPlayer
  • preloading videos
  • splitting GPU/CPU memory at 512
  • not using too many because the more I use the slower it becomes

Thanks again,

1 Like