ofVideoPlayer and GL_RGBA

Hi there,

I am trying to load Quicktime videos with alpha channels, so I can read them frame by frame and save the alpha values from each frame as GL_ALPHA ofTextures.

I was having trouble getting this to work, and then decided to look under the hood in ofVideoPlayer.cpp. It seems that ofVideoPlayer only support GL_RGB, and not GL_RGBA. Might there be some easy way to hack around this?

Could I just replace all references to “GL_RGB” with “GL_RGBA”, and all “width*height*3” pixel allocations to “width*height*4” inside ofVideoPlayer.cpp?

What would be the best solution here? Thanks!


hi jonathon,

you’d likely have to hack it a bit, or take the ofVideoPlayer as a starting point and build another class that does what you want it to do. it wont be as simple as changing the pixel array size and adding GL_RGBA.

the real action that you’ll want to modify is in a function called “convertpixels” in ofQtUtils, which converts RGBA to RGB. It’s doing the conversion line by line, since quicktime gworlds are non-contiguous memory (and it’s making it contiguous). you could probably rewrite this (or better, write another function) that copies the RGBA into a contguous RGBA array…

it might be best to write all of these steps in another class, so that it’s easier to distribute (instead of modifying the OF code). I’m sure others will find it very useful.

hope that helps!!

OK, I’ll see what I can do.

If I make changes to the OF code (ofVideoPlayer.cpp and ofQtUtils.cpp), how can I recompile these files so my OF project will use them properly? I’m using Visual C++ 2005.

And if I were to write my own class (say, ofVideoPlayerAlpha), where should I put that? In the openFrameworks/video folder? Or in my local project directory? Somewhere else? I haven’t tried modifying any core OF code yet, so am not quite sure how to go about that.



we suggest that you don’t modify the OF core code at all unless it is a bug fix. modifying it can break your other apps, and make it harder to share code…

you could create a copy of the ofVideoPlayer, rename everything (and rename the #define at the top) and throw it in with the rest of your source code (in the src folder, etc). It should be part of your source, just like any other class you create and not part of OF, because it’s not really a “core” thing. later, we can talk about putting it with the addons (reusable code and libs, etc that you might find useful for your other apps) but for now, it makes sense to just tuck it with your source.

take care

OK, thanks Zach, I got this to work.

I copied the ofVideoPlayer class to my local project, and made an adapted version that reads and maintains RGBA pixels. I posted the relevant files in a small project demonstrating the resulting “AlphaVideoPlayer” class, which reads the frames of a video with an alpha channel, and then saves all the frames into an array of ofTexture objects, which can be played back quickly.

Maybe some people will find it useful.

Files are here: http://number27.org/download/OF/AlphaVideoPlayer.zip

Thanks again for your help and Happy New Year!


Thanks, that’s very usefull!


Anybody knows if VideoAlphaPlayer is still working in of06? I want to use it to get and draw the alpha channel of a Video…I can do it manually but I guess exists another easy solution.

Other point is how is the easy way to get that mov with transparencies… but I think we are doing that properly with aftereffects, exporting Quicktime with PNG and transparency enabled.

I’ve been able to use the AlphaVideoPlayer with oF6–works great!

The problem I’m running into, though, is the PNG codec is running very choppily in oF. All videos look like they’re running at half the frame count. I’ve tried the few other codecs that support Alpha out of After Effects (JPEG2000, AppleProRes 4444) but it’s all the same.

Any thoughts about how I can make the video play smoother?



For a project I’m working on I need to get full HD videos with alpha channel to run with OpenFrameworks.
I’m talking about:

  • 1920 x 1080 pixels full HD
  • files around 1Gb - 3Gb
  • alpha channel
  • animation codec ( I’m not sure about this yet)

I tried the code Jonathan made, but my little macbook just hangs when I try to load a single video (and I need to “layer” multiple videos on top of each other).

I read somewhere that Zach suggested extending the ofVideoPlayer.
And that’s what I did. With some really minor adjustments to the original code I’ve got it to work very decently on OSX 10.6 / OF0061
I didn’t really look at the win32 or Linux code, so I’m sorry for those people, but here is a quick hack for a working ofxAlphaVideoPlayer on OSX: [edit] petergoes tested on Windows 7 [/edit]


Documentation: it works exactly the same as the normal ofVideoPlayer, just drop the ofxAlphaVideoPlayer folder in your Xcode project and create an ofxAlphaVideoPlayer object where you would create an ofVideoPlayer.
oh! almost forgot: you need to add an ofEnableAlphaBlending() before calling ofxAlphaVideoPlayer.draw() !

Hope someone finds it useful!



Thanks Tim!
You just made my day!


this is a great addition and super helpful – I’ve done too many mask movies now, and it’s great to have an alpha option for quick tests.


I’m glad I can pay back some of my debts!

I’m still working on this alpha Video player and will be adding multithreading too.
When it’s done and cleaned up, I’ll put the source online.


great job!
u are my hero for today!

this is very useful
thousand thanks for you effort :smiley:

Hello all

I am sorry but I am a beginner in OF.
I need to work with alpha channel videos but I don’t know how to use the ofxAlphaVideoPlayer.
I’m trying to transform the moviePlayerExample by using ofxAlphaVideoPlayer.
I thought that it was only changing ofVideoPlayer by ofxAlphaVideoPlayer.
But I don’t know where should I put the files that are inside ofxAlphaVideoPlayer folder so they can be linked to the moviePlayerExample.

This is a basic question, but I don’t know what to do.
Can you help me or tell me where can I find more information?

Best regards
rui avelans coelho

Hey all,

I’ve been working on a app based on the standard movie player example using ofxAlphaVideoPlayer, integrating it as per Tim K’s instructions above (Thanks @Tim K, really nice).

Unfortunately, when I try to compile my app in 007, I’m getting an abstract class error:

error: cannot declare field ‘testApp::fingerMovieAlpha’ to be of abstract type ‘ofxAlphaVideoPlayer’

However, the same code works perfectly in 0061. So it seems something has changed in 007 that is causing ofxAlphaVideoPlayer to break.

Just wondering if anyone else is having this issue, and if you’ve found a solution?

Many thanks

oF 007
Xcode 3.2.6
Mac OS 10.6.7
MBP i7

PS @Rui, if you’re still having problems implementing ofxAlphaVideoPlayer, here’s what I did to get it working: In the Finder, drag the ofxAlphaVideoPlayer folder to the addons folder in oF 0061. Then launch your xcode project, and drag this folder from the Finder into the ‘groups and files’ pane in Xcode, recursively add files and folders to your project.

hey there,

the “absract type” errors come from when the super class (the class that ofxAlphaVideoPlayer inherit from) changes it’s definition. It means that ofxAlphaVideoPlayer hasn’t been updated for the way the video players changed in 007

the *easiest* and dirtiest fix is to just remove the “: public ofBaseXXX” after the class declaration so that it doesn’t inherit from anything. Should get you up and running quick.

The long term answer is to refactor the class to work properly with the new 007 structure.

Thanks James, that got it running in 007 :slight_smile:

Soon as I get a chance I’ll have a look into fixing it properly and sharing the results.


I have the same problem of an “abstract error” with the 007 version of oF. I tried to delete " : public ofBaseVideo" in the ofxAlphaVideoPlayer.h, but that way I get a lot more errors of undeclared identifiers. Is there another way to get it working with oF 007?