Video playback with brightness/contrast ? RRS feed

  • Question

  • Hi guys.  I am writing a C# app ( but C++ answers are fine, I have a C# DShow wrapper, and I can code C++ fine ), and the client has sprung an extra requirement on me, namely video playback ( which is trivial ) on what was before a still image viewer.  They want the same controls on video, however, which means they want to rotate the video, and they want to set brightness and contrast on the video during playback.  I've googled, and the WMP seems to have an interface, but it doesn't work ( just exposed for skinning ) and I can't see how to do this with DX either.

    Any help appreciated.


    Sunday, September 10, 2006 6:52 AM

All replies

  • How are you handling the contrast/brightness for the still images?  You may be able to do something similar to the images as they pass down the filter graph (a la sample grabber).

    Flipping video (left->right or top->bottom) shouldn't present any particular difficulty.  In fact, I've written a c# DMO that does just that.  However, the rotation isn't going to be quite so simple.  When the graph is built, the filters are told (via AM_MEDIA_TYPE) about the format of the video stream.  They allocate buffers, etc based on this info.  And most of them aren't going to be too happy about seeing a 320x240 video suddenly turning into a 240x320.  You'd probably need to re-build the graph.  Do-able.  Just not simple.

    Unless you are talking about grabbing still images from the stream and fiddling with them.  That should be relatively straight forward.

    If you are interested in that DMO, it is one of the samples at in the DmoFlip project.  Source is included.

    Sunday, September 10, 2006 5:42 PM
  • That's for the reply. 

    No, I don't want to grab stills, I want the stream itself to reflect the changes.  I'm doing brightness/contrast via matrix operations on the graphics object for stills.  I am more than able to write a low level c++ brightness/contrast filter, however, it's getting it applied to the video that is the problem.

    Thanks, I'll look at that sample.  If it's flipping the bits, then I'm assuming I can change that code to instead apply a filter to them.


    Thursday, September 14, 2006 8:38 PM
  • Thanks - I've looked at the sample, and like all samples I've found, it seems to work on a video capture device.  I want it to work on a mpg file that I have locally on my system.  Can you point me in the direction of how to use it in that scenario ?


    Thursday, September 14, 2006 10:29 PM
  • The DMO doesn't care where the samples are coming from.  You can add it anywhere you like in the graph.  I use a capture source in the sample only because it is easy to show.
    Thursday, September 21, 2006 3:57 PM
  • There are two ways, both have good and bad points.

    Using the Video Overlay2 Filter:

    Overlay is the older way of rendering but it is also the most widespread in implementation.  The overlay also makes some things easier including the various colors controls for brightness, contrast, hue, saturation, and gamma.  The drawback is that the Overlay can be a pain to work beyond just showing video.  Adding a sample grabber that works with any video format (RGB, YUY2, etc.) and can still return usable data is buggy at best.  Anyone who has tried to sample grab a DivX can attest to that.

    Using VMR9:

    I highly recommend you use the VMR9 filter because it does everything really well, the drawback is that it can be a little harder to work with.

    Basically, everything you want is exposed by one interface, the IVMRMixerControl9 interface.

    You can adjust the video colour controls if your video card supports it.  Meaning you can change the brightness, contrast, hue, saturation, gamma, sharpness, etc.  As easily as changing the value of a gauge bar or other slider control.  The actual code you would need for each slider control would be ~10 lines or less so it is still nothing major... just slightly tougher than the overlay interface which is something like 3 lines of code.

    There is a bonus to using the VMR9 filter if you don't need full screen playback.  VMR9 has flawless frame grabbing to bitmap when in Windowless mode.  As noted above, this is problematic in Overlay mode without custom filters to deal with the myriad of colour space implementations used out there.

    I hope that helps.
    Saturday, September 23, 2006 10:00 PM
  • Somehow it doubled posted - edited to save KB
    Saturday, September 23, 2006 10:00 PM
  • I am using the vmr9 with the ProcAmpControl. On Vista only the brigntness and the contrast work, the hue and the saturation doesn't work I cannot understand I got no error after executing the SetProcAmpControl funtion and under Windows XP it doesn't work at all.

    I have to say too that I am working on Delphi,... but it logically it changes nothing.
    Wednesday, April 11, 2007 7:23 AM
  • hi, you can't use ProcAmpControl, you can use the wmp control.

    then you can using IWMPVideoSettingsCtrl to change the video settings.


    here is the sample:

    Thursday, July 3, 2008 9:13 AM