alphaMask on HAP Video

Hey there,
I’m using an FBO as an alpha mask to make a video transition like this:

fbo.allocate(4320, 1920, GL_RGBA);

// draw some shapes

video.draw(0, 0, 4320, 1920);

This works like a charm for ofVideoPlayer and H264 videos. But since the resolution is quite high and I need several videos running at the same time, the performance drops significantly. That’s why I was experimenting with HAP (ofxDSHapVideoPlayer, Windows 10) that brought huge performance improvements when playing several videos.

But until now I haven’t had luck getting the video transition to work with HAP. The above code also compiles when using ofxDSHapVideoPlayer instead of ofVideoPlayer but doesn’t show the transition.

Any idea why this is the case? Or another idea how to make the transition work with HAP?



ofxDSHapVideoPlayer has a slightly different architecture than ofVideoPlayer. Depending on which HAP codec type your video has, it may use an internal shader and override the default OF shader that allows you to setAlphaMask().

This isn’t a feature that I’ve actually used before, but you might consider drawing the video into an FBO and then calling setAlphaMask() on that FBO. Otherwise I recommend writing an alpha masking shader to do the blending with the video. See “alphaMaskingShaderExample” in the examples/gl folder.

Hope that helps!

Thanks @mantissa. Drawing the video onto an FBO first and setting the AlphaMask for the FBO did the trick.
I remember doing some tests with an alpha masking shader also some time ago and didn’t really get it to work. Do you think there would be a performance benefit for that solution?

Sure thing! Glad that it worked for you. When you’re drawing into the FBO and setting the AlphaMask, openFrameworks is actually using a shader to do the blending–it’s all just happening behind the scenes. So the only performance hit is due to the extra step your drawing the movie frame into an FBO.