Current version

v1.10.4 (stable)

Navigation

Main page
Archived news
Downloads
Documentation
   Capture
   Compiling
   Processing
   Crashes
Features
Filters
Plugin SDK
Knowledge base
Donate
Contact info
Forum
 
Other projects
   Altirra

Search

Archives

01 Dec - 31 Dec 2013
01 Oct - 31 Oct 2013
01 Aug - 31 Aug 2013
01 May - 31 May 2013
01 Mar - 31 Mar 2013
01 Feb - 29 Feb 2013
01 Dec - 31 Dec 2012
01 Nov - 30 Nov 2012
01 Oct - 31 Oct 2012
01 Sep - 30 Sep 2012
01 Aug - 31 Aug 2012
01 June - 30 June 2012
01 May - 31 May 2012
01 Apr - 30 Apr 2012
01 Dec - 31 Dec 2011
01 Nov - 30 Nov 2011
01 Oct - 31 Oct 2011
01 Sep - 30 Sep 2011
01 Aug - 31 Aug 2011
01 Jul - 31 Jul 2011
01 June - 30 June 2011
01 May - 31 May 2011
01 Apr - 30 Apr 2011
01 Mar - 31 Mar 2011
01 Feb - 29 Feb 2011
01 Jan - 31 Jan 2011
01 Dec - 31 Dec 2010
01 Nov - 30 Nov 2010
01 Oct - 31 Oct 2010
01 Sep - 30 Sep 2010
01 Aug - 31 Aug 2010
01 Jul - 31 Jul 2010
01 June - 30 June 2010
01 May - 31 May 2010
01 Apr - 30 Apr 2010
01 Mar - 31 Mar 2010
01 Feb - 29 Feb 2010
01 Jan - 31 Jan 2010
01 Dec - 31 Dec 2009
01 Nov - 30 Nov 2009
01 Oct - 31 Oct 2009
01 Sep - 30 Sep 2009
01 Aug - 31 Aug 2009
01 Jul - 31 Jul 2009
01 June - 30 June 2009
01 May - 31 May 2009
01 Apr - 30 Apr 2009
01 Mar - 31 Mar 2009
01 Feb - 29 Feb 2009
01 Jan - 31 Jan 2009
01 Dec - 31 Dec 2008
01 Nov - 30 Nov 2008
01 Oct - 31 Oct 2008
01 Sep - 30 Sep 2008
01 Aug - 31 Aug 2008
01 Jul - 31 Jul 2008
01 June - 30 June 2008
01 May - 31 May 2008
01 Apr - 30 Apr 2008
01 Mar - 31 Mar 2008
01 Feb - 29 Feb 2008
01 Jan - 31 Jan 2008
01 Dec - 31 Dec 2007
01 Nov - 30 Nov 2007
01 Oct - 31 Oct 2007
01 Sep - 30 Sep 2007
01 Aug - 31 Aug 2007
01 Jul - 31 Jul 2007
01 June - 30 June 2007
01 May - 31 May 2007
01 Apr - 30 Apr 2007
01 Mar - 31 Mar 2007
01 Feb - 29 Feb 2007
01 Jan - 31 Jan 2007
01 Dec - 31 Dec 2006
01 Nov - 30 Nov 2006
01 Oct - 31 Oct 2006
01 Sep - 30 Sep 2006
01 Aug - 31 Aug 2006
01 Jul - 31 Jul 2006
01 June - 30 June 2006
01 May - 31 May 2006
01 Apr - 30 Apr 2006
01 Mar - 31 Mar 2006
01 Feb - 29 Feb 2006
01 Jan - 31 Jan 2006
01 Dec - 31 Dec 2005
01 Nov - 30 Nov 2005
01 Oct - 31 Oct 2005
01 Sep - 30 Sep 2005
01 Aug - 31 Aug 2005
01 Jul - 31 Jul 2005
01 June - 30 June 2005
01 May - 31 May 2005
01 Apr - 30 Apr 2005
01 Mar - 31 Mar 2005
01 Feb - 29 Feb 2005
01 Jan - 31 Jan 2005
01 Dec - 31 Dec 2004
01 Nov - 30 Nov 2004
01 Oct - 31 Oct 2004
01 Sep - 30 Sep 2004
01 Aug - 31 Aug 2004

Stuff

Powered by Pivot  
XML: RSS feed 
XML: Atom feed 

§ Your video is now a garish purple blotch

Ever tried to do something with a video player, and gotten a fluorescent green or purple blotch where your video was supposed to be? Like take a screenshot, move it to a second monitor, or show it on TV out?

This is caused by the use of a hardware video overlay. This is a second video screen that is overlaid over the primary surface by the video hardware. Because the two are only generated at scanout, and even then sometimes only on the primary monitor, attempts to capture the video by screen capture will just give you the underlying window instead, even though you can see the video just fine.

The easiest way to work around this problem is to change the video acceleration options for your video player to use a lower setting, which usually disables use of the video overlay. A few applications, most notably DVD players, won't let you do this, in which case you'll either need to find a screencap application that hooks DirectX, or loop TV out into a video capture device, assuming your video card can display the overlay on TV out (some can't, or don't when the TV is the secondary monitor).

Activation of video overlays

Video overlays are created on Windows using the DirectDraw API, and only through that API. GDI and Direct3D need not apply. The overlay is exposed as a special type of surface; it can be locked and filled as any other video memory surface, but is rather special in that it can often be flipped independently of the main display. This means it can be easily updated in a tear-free manner by updating the back buffer and calling Flip(), without having to worry about the overhead of a blit when scheduling the flip. Because overlays are merged into the display without actually writing to the framebuffer, they can be shown, hidden, and moved extremely cheaply, much faster than even an accelerated blit.

The other main advantage of hardware video overlays is that they usually support YCbCr formats for image data, doing the conversion on the video card itself for free. On slower systems, this was a significant cost to video decoding and helped performance significantly. On modern CPUs it's not nearly so bad, and on a 3D card one or two pixel shaders (or a series of fixed-function blending hacks) will do the job equally as well. However, although you'll still find systems that can't do hardware 3D, you'd be hard pressed to find ones that can't support a hardware video overlay.

If you're a programmer and want to play with overlays, the DirectDraw Test application (ddtest.exe) from the DirectX SDK is the best way to do so. Just make sure you don't expand the overlay full-screen and make it impossible to see anything.

The colorkey

The reason for the purple blotch where the video should be in a desktop screenshot of a video player is that it's the colorkey for clipping the overlay. With a rare exception here and there, overlays usually can't be directly clipped to anything more complex than a rectangle, or perhaps not at all. This is a problem when windows or title graphics need to overlap the overlay, so most hardware supports a destination colorkey, where the overlay is only shown if a specific color is drawn on the underlying primary surface. Any windows on top don't draw colorkey-colored pixels — hopefully, at least — so the overlay is hidden there and gets covered like the rest of the player window. Ugly and seldom-used colors are chosen for the colorkey to minimize collisions. I hate seeing flashes of nasty magenta or cyan when manipulating a video window, so VirtualDub uses #008000 dark green instead — which occasionally causes some interesting effects when I open Task Manager on top or stop the program at a breakpoint and look at some code comments where the overlay is still active.

Using a colorkey for clipping does have the nice benefit of clipping 100% correctly, whereas blits frequently don't since the complex region gets cut up into subrects and the subrects then have coordinates rounded to integers, leading to seams. Direct3D uses a special blit command for its Present() that preserves enough data to avoid the rounding errors, but for some reason this capability wasn't added to DirectDraw's Blt().

If you know DirectDraw programming and have an unsuspecting buddy, you can do some wicked practical jokes with a full-screen overlay surface that uses a white destination colorkey to show images in the background of random windows. Not that I've ever done that before.

Quirks

With most hardware, you only get one overlay. If you try opening two players that both want to use the overlay, the second player will either fail or blit instead.

Overlay hardware generally only supports YCbCr color spaces. You might find a video card somewhere that supports an RGB overlay, but I don't know of any modern video cards that do. On the other hand, supporting UYVY and YUY2 overlays will work on just about everything. You do have to cover both, because I've seen ones that only support one and not the other.

Image interpolation is often not up to par on the overlay. Chroma is not fully interpolated, and I used to curse at NVIDIA constantly for disabling vertical interpolation entirely on later versions of the TNT2 drivers. ATI uses an edge-sensitive interpolation algorithm that can show ringing around the borders of the image.

Some video drivers play goofy tricks with overlays, like replacing a secondary TV-out monitor with the overlay when both are active. There isn't a way to detect this, although newer video drivers make the behavior configurable. The overlay also frequently has different color adjustment controls than the primary surface, although again these are regrettably not available programmatically.

On some video cards, there is a limit to how small the overlay can get horizontally, instead of how wide. There isn't a speed problem with making the overlay larger, since it's only being merged at scanout, and isn't actually writing over a huge number of pixels in the framebuffer. However, making it narrower is a problem because it means the video hardware has to fetch pixels faster over a shorter amount of time. This leads to the strange result that the overlay can be made full screen, but can't be made too small because the bandwidth requirements become too high. I have an old Toshiba Tecra laptop with a Chips & Technologies 65550 video chip that shows artifacts in the overlay is made too small.

Comments

Comments posted:


Wouldn’t a color like #037F01 look almost the same and be less likely to be used by other programs?

Chris - 01 03 06 - 10:28


Short blog entry about VMR-7 and VMR-9 and Overlay would be nice, I am hoping most Video Player/Encoder developers read this page and after that they would support VMR also so there wouldn't be need for ATI theater mode or NVIDIA Overlay settings on multimonitor (or monitor+TV) environment.

007 - 01 03 06 - 11:03


Chris:
You're assuming that the display is actually able to represent that color as distinguishable from #008000; this isn't true if the display depth is lower than 24-bit. You can set a range for the color key on some hardware, but you'd have to know what range to set. There isn't a clean way to determine the true RGB format of a GDI display, so it's safest to choose colors that, at the very least, are cleanly representable on a 555 surface.

I've seen programs that tried to use a color just lighter than black. Couldn't figure out what the color fringing was from in my Photoshop image until I remembered about the player in the background.

007:
I don't know too much about the Video Mixing Renderers, but I do know that VMR-7 is DirectDraw based while VMR-9 is Direct3D 9 based. This means that hardware video overlay is only possible with VMR-7. Unless you're running on a system prior to XP, it's hard NOT to get a VMR in your playback graph; you'd have to construct it manually or use the Capture Graph Builder to end up with the old Video Renderer instead.

Phaeron - 02 03 06 - 00:44


We already support VMR7/9 in all modes (Windowed/Windowless/Renderless), although Renderless exclusive mode is a pain in the a$$.

However, in VMR7/9 mode when not using the overlay and using a YUV output mode, both ATI and NVIDIA seem to output a luma range of 16-235, which is a pain considering the monitor works in rgb where the luma range is 0-255, requiring either a software conversion to 0-255, or to specifically adjust the hardware color controls to compensate.

Blight (link) - 02 03 06 - 13:31


FYI, with Aero Glass turned on in Vista, overlays are not allowed (everything uses VMR).

Derek - 05 03 06 - 19:25


I don't have my Vista-equipped machine on to test, but I can believe that the DWM would disable overlays. The good news is that any system that can run Aero Glass has pixel shader 2.0 and is thus far more than powerful enough to do any YCbCr-to-RGB conversion on the GPU.

Phaeron - 05 03 06 - 23:57


Hi,i have a problem with my display of my laptop, i think is the same about what you comment. When i play a video it appears like with a purple layer or something like that, it just doesnt look normal. And when i was trying to correct it i discover that when i uncheck the hardware video overlay, it dissapear, but the problem is that sometimes the video blackout or play slowly. Someone know what happened, because some days ago, i didnt have that problem.

Sergio - 28 03 06 - 14:39

Comment form


Please keep comments on-topic for this entry. If you have unrelated comments about VirtualDub, the forum is a better place to post them.
Name:  
Remember personal info?

Email (Optional):
Your email address is only revealed to the blog owner and is not shown to the public.
URL (Optional):
Comment: /

An authentication dialog may appear when you click Post Comment. Simply type in "post" as the user and "now" as the password. I have had to do this to stop automated comment spam.



Small print: All html tags except <b> and <i> will be removed from your comment. You can make links by just typing the url or mail-address.