Inverted Video Color while i load a RGBA VIDEO into Openframeworks.

Hello everyall,

I got a problem while im loading a RGBA video into openframeworks.

  
  fingerMovie2.setPixelFormat(OF_PIXELS_RGBA);  
        
  
   fingerMovie2.loadMovie("BAS_RECHERCHE(pre)32bit.mov");  
      
   fingerMovie2.play();  

Actually, it invert my blue color to yellow color.

I thought i was a problem of PixelFormat : RGBA / BGRA. But nothing else happend while i change the pixelFormat.

Any ideas ?

it is mostly sure a pixelFormat problem but the video player doesn’t support bgra. which platform are you using?

you could use a shader that swaps r with b

also you can disable the texture in the videoPlayer and upload to a custom texture using bgra like:

  
  
//setup  
player.loadMovie(...);  
player.setUseTexture(false);  
tex.allocate(player.getWidth(),player.getHeight(),GL_RGBA);  
  
//update:  
player.update();  
if(player.isFrameNew()){  
   tex.loadData(player.getPixelsRef(),GL_BGRA);  
}  
  
//draw  
tex.draw(0,0);  
  

I try that solution right now, and i post the result !

Thanks to a friend of mine, i got the solution, You have to change a line of code in the file ofGstVideotPlayer.cpp of openframeworks video library.

  
  
#if GST_VERSION_MAJOR==0  
	int bpp;  
	string mime;  
	switch(internalPixelFormat){  
	case OF_PIXELS_MONO:  
		mime = "video/x-raw-gray";  
		bpp = 8;  
		break;  
	case OF_PIXELS_RGB:  
		mime = "video/x-raw-rgb";  
		bpp = 24;  
		break;  
	case OF_PIXELS_RGBA:  
	case OF_PIXELS_BGRA:  
		mime = "video/x-raw-rgb";  
		bpp = 32;  
		break;  
	default:  
		mime = "video/x-raw-rgb";  
		bpp=24;  
		break;  
	}  
  
	GstCaps *caps = gst_caps_new_simple(mime.c_str(),  
										"bpp", G_TYPE_INT, bpp,  
										"depth", G_TYPE_INT, 24,  
										"endianness",G_TYPE_INT,4321,  
										"red_mask",G_TYPE_INT,0xff0000,  
										"green_mask",G_TYPE_INT,0x00ff00,  
										"blue_mask",G_TYPE_INT,0x0000ff,  
										"alpha_mask",G_TYPE_INT,0x000000ff,  
										NULL);  
#else  
	int bpp;  
	string mime="video/x-raw";  
	string format;  
	switch(internalPixelFormat){  
	case OF_PIXELS_MONO:  
		format = "GRAY8";  
		bpp = 8;  
		break;  
	case OF_PIXELS_RGB:  
		format = "RGB";  
		bpp = 24;  
		break;  
	case OF_PIXELS_RGBA:  
		format = "RGBA";  
		bpp = 32;  
		break;  
	case OF_PIXELS_BGRA:  
		format = "RGBA";  
		bpp = 32;  
		break;  
	default:  
		format = "RGB";  
		bpp=24;  
		break;  
	}  

This is the thing you have to change to make it work properly :

case OF_PIXELS_BGRA:
format = “RGBA”;

Return, RGBA format when BGRA is called.

Thats all.

great, btw what format are you using for video with alpha?

I used some .mov files for alpha.

And thas the only solution i found to have true colors.

Weird isnt it ?

:wink: