Click here to Skip to main content
Click here to Skip to main content
Go to top

ProcAmp for DirectShow.Net

, 14 Feb 2008
Rate this:
Please Sign up or sign in to vote.
How to use use brightness, contrast, saturation, hue in your DirectShow.Net filtergraph.

Introduction

I am starting out multiple articles that will describe parts of how to use DirectShow.Net. When I have finished with enough examples, I will combine them into a complete video player program written in VB.NET.

This article will explain how to extend your filtergraph to use the ProcAmp control. The ProcAmp is a really cool thing. Let's make your movie all the colors of the rainbow! I am using the DirectShow.Net library. It lets you build DirectShow stuff in VB.NET/C#. Be aware, not all filtergraphs support this trick. The if then code part tries to catch that..

Using the code

Please create a filtergraph first. I am only giving an example for brightness here, but with some extra lines of code, hue, contrast, and saturation will work the same.

This part of the code is placed behind your .renderstream function. f_VideoMixing_Renderer is a VideoMixingRenderer9 object (that is part of my filtergraph).

f_VideoMixerProcampControl is a control (VMR9ProcAmpControl) that gives you access to colorizing your video.

f_VideoMixerProcampRange (VMR9ProcAmpControlRange) is the object that you put in and get out of your ProcAmp control. You always have to marshal.sizeof when getting/setting something in your ProcAmp.

'********************************** video procamp *****************************************
'new setup mixer control
Dim f_VideoMixerControl As IVMRMixerControl9 = _
       CType(f_VideoMixingRenderer, IVMRMixerControl9)
DsError.ThrowExceptionForHR(hr)

'new setup procamp control
Dim f_VideoMixerProcampControl As VMR9ProcAmpControl
f_VideoMixerProcampControl.dwSize = Marshal.SizeOf(f_VideoMixerProcampControl)
f_VideoMixerProcampControl.dwFlags = 0
hr = f_VideoMixerControl.GetProcAmpControl(0, f_VideoMixerProcampControl)
DsError.ThrowExceptionForHR(hr)

If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Brightness) > 0 Then
    Debug.WriteLine("brightness")
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Contrast) > 0 Then
    Debug.WriteLine("constrast")
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Hue) > 0 Then
    Debug.WriteLine("hue")
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Mask) > 0 Then
    Debug.WriteLine("mask")
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.None) > 0 Then
    Debug.WriteLine("none")
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Saturation) > 0 Then
    Debug.WriteLine("saturation")
End If

'get procamp control range for brightness
Dim f_VideoMixerProcampRange As VMR9ProcAmpControlRange
f_VideoMixerProcampRange.dwProperty = VMR9ProcAmpControlFlags.Brightness
f_VideoMixerProcampRange.dwSize = Marshal.SizeOf(f_VideoMixerProcampRange)
hr = f_VideoMixerControl.GetProcAmpControlRange(0,f_VideoMixerProcampRange)
DsError.ThrowExceptionForHR(hr)

'set the brightness in ProcAmp , tell that the size has changed
Dim brightpos As Double = 0.1       
f_VideoMixerProcampControl.Brightness = _
   CSng(f_VideoMixerProcampRange.MinValue + brightpos * _
   (f_VideoMixerProcampRange.MaxValue - f_VideoMixerProcampRange.MinValue))
               
'set the new value in ProcAmp to the videomixercontrol
f_VideoMixerProcampControl.dwSize = Marshal.SizeOf(f_VideoMixerProcampControl)
hr = f_VideoMixerControl.SetProcAmpControl(0, f_VideoMixerProcampControl)
DsError.ThrowExceptionForHR(hr)

Points of Interest

It took me two years to learn VB.NET, half year to learn DirectShow, and half a day to do ProcAmp. You have to go and read about every command I used if you are a newbie to this.

History

This is the first version of this code..

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

Share

About the Author

Jarno Burger

Netherlands Netherlands
Jarno Burger
i am videojockey for festivals.
i am getting fed up with the vj programs at the moment , so i am trying to go and write my own one.
 
if you wanna read some more stuff about directshow.net , then you can read some chunks of info on my blog , with some extra handy links to more articles and forums.
 
http://jarnoburger.blogspot.com/

Comments and Discussions

 
QuestionProcamp - Could you please send the source code? PinmemberRoms15-Feb-08 18:00 
AnswerRe: Procamp - Could you please send the source code? PinmemberJarno Burger19-Feb-08 23:26 
GeneralRe: Procamp - Could you please send the source code? PinmemberNoctris15-Jul-08 11:10 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web02 | 2.8.140921.1 | Last Updated 14 Feb 2008
Article Copyright 2008 by Jarno Burger
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid