Click here to Skip to main content
13,051,803 members (66,610 online)
Click here to Skip to main content
Add your own
alternative version


30 bookmarked
Posted 7 Feb 2008

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.


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)

'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)

If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Brightness) > 0 Then
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Contrast) > 0 Then
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Hue) > 0 Then
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Mask) > 0 Then
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.None) > 0 Then
End If
If (f_VideoMixerProcampControl.dwFlags And VMR9ProcAmpControlFlags.Saturation) > 0 Then
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)

'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)

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.


This is the first version of this code..


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


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 , then you can read some chunks of info on my blog , with some extra handy links to more articles and forums.

You may also be interested in...

Comments and Discussions

QuestionProcamp - Could you please send the source code? Pin
Roms15-Feb-08 18:00
memberRoms15-Feb-08 18:00 
AnswerRe: Procamp - Could you please send the source code? Pin
Jarno Burger19-Feb-08 23:26
memberJarno Burger19-Feb-08 23:26 
GeneralRe: Procamp - Could you please send the source code? Pin
Noctris15-Jul-08 11:10
memberNoctris15-Jul-08 11:10 

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

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

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