Color Keying with Freescale G-Streamer video4linux plugin

Published on July 3, 2010

Archived Notice

This article has been archived and may contain broken links, photos and out-of-date information. If you have any questions, please Contact Us.

The Freescale i.MX51 has support for color-keying of the video overlay or YUV layer, exposed through the custom frame-buffer ioctl MXCFB_SET_CLR_KEY. Unfortunately, this feature appears to be available only for X-Windows applications in the Freescale G-Streamer video4linux plugin (mfw_v4lsink). In addition, when used with gst-launch (not in an X-Windows application), the transparency of the YUV layer is hard-coded to 50%, blending the video and graphics layers. This video shows the overall effect. This video was taken from a Boundary Devices Nitrogen board running Ubuntu Karmic. With 50% transparency, the word 'background' kinda loses its meaning. One of the windows open is the Clutter demo application test-depth. The video being played is a 720P MPEG-4 Freescale test video. The overall CPU usage bounces around in the range of 40-50%. Although it's hard to see in this low-res cell-phone capture, the monitor resolution is also 720P (1280x720@60Hz). Overall, this is really nice. It shows the power of the video accelerator for video decoding, and that of the 3D graphics processor. In order to use this power in an application, though, we'll need to get some control over the video. As mentioned earlier, the G-Streamer plugin from Freescale provides support for color-keying for X applications through setpara, but not for other applications. The color-keying patch at https://boundarydevices.com/git?p=gst-fsl-plugin-1.7.3.git adds what I think is a more straightforward G-Streamer control parameter to the mfw_v4lsink plugin. It adds a color-key variable. If set, any pixels in the graphics layer of the specified color will become transparent, and the video layer will show through. This example shows the effect with a value of 0xCECBCE, the background color of the Clutter demo. You can see the Freescale video playing in the background area. The video itself appears a bit washed out, but that's only because the YouTube video is low-resolution. WIth full resolution, you would instead see graininess, which occurs because the background area of the test-depth application isn't uniform. Instead it appears to be dithered. The following video shows things a bit more clearly (literally). The color-key parameter is now set to zero (black), and I'm generating some black regions by selecting areas within a terminal window. This also highlights how you can see different segments of the video as the black area moves.