views:

711

answers:

2

I have noticed (on my Vista 64bit machine) that a video being shown in a WPF MediaElement has different colors than when being played in Windows Media Player. Inside the MediaElement, the video has a slightly desaturated look with lower contrast.

The videos I have tried so far are WMV videos that were produced by different people with different tools, so I'd rule out problems with the video material. All "Video Settings" sliders in Windows Media Player (Hue, Saturation, Brightness, Contrast) are on their default values.

That's why at first I suspected an issue in my software which is making extensive use of animated opacity and content being placed over the video.

But I have been able to reproduce the behavior with a simple test program where the XAML looks like this:

<Window x:Class="MediaElementTest.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">

    <MediaElement Source="D:\Test\Video.wmv" />
</Window>

Am I doing something wrong? Is there a workaround?

+1  A: 

Since I'm pretty sure the MediaElement will use the VMR9 on XP and the EVR on Vista, you might be seeing the behavior explained here

I'm guessing Windows Media Player uses either the VMR7 or default Video Renderer so it doesn't have that behavior. OR Microsoft has compensated in some way.

Bryce Kahle
Thanks a lot! The blog post linked to in the answer mentions the "WPFMediaKit" for which the source code is available on CodePlex.Instead of using the classes of that library for video playback, I tried the "DeeperColor" shader effect in isolation, i.e. I assigned an instance of the DeeperColor class to the Effect property of my MediaElement and colors were fine!The DeeperColor class can be found in the Effects folder inside the WPFMediaKit project. Be sure to set the build action of "DeeperColor.ps" to "Resource" if you want to use it directly in your own project.
Roland Weigelt
A: 

If you video card supports it, there are sometimes some software options to fix this.

If you have an NVidia card, goto the NVidia control panel. Click on "Video" in the options tree. Select the monitor and click the "With NVidia Settings" radio button. In the advanced tab, select "Dynamic Range 0-255".

Thats it!

Jeremiah Morrill