C# and brightness control

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
lallous
New Cone
New Cone
Posts: 6
Joined: 23 Jun 2008 10:09

C# and brightness control

Postby lallous » 23 Jun 2008 10:18

Hello

I have used the VLC / C# binding from the Wiki and created a small sample:

Code: Select all

private void button1_Click(object sender, EventArgs e) { try { video1.ClearPlayList(); video1.AddToPlayList(@"W:\Office.wmv", "Something", new string[] { }); video1.Play(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
I created another button for controlling brightness while the moving is playing:

Code: Select all

private void button1_Click_1(object sender, EventArgs e) { video1.Brightness = float.Parse(textBox1.Text); Text = video1.Brightness.ToString(); }
I know the brightness range is from 0.0 to 2.0 with default value of 1.0.

Now why when I set the brightness with this code, still it is value is 1.0 ? As if it is unchanged?

Can you please tell me how to set brightness correctly?

Thanks,
Elias

lallous
New Cone
New Cone
Posts: 6
Joined: 23 Jun 2008 10:09

Re: C# and brightness control

Postby lallous » 23 Jun 2008 12:54

Hi again,

It turned out after investigation that:

VlcObject vobj = new VlcObject(this.vlcHandle, objectType)

Is not initializing / returning a valid subobject, thus:

Code: Select all

public float GetVlcObjectFloat(ObjectType objectType, String propertyName, float errorReturn) { try { using(VlcObject vobj = new VlcObject(this.vlcHandle, objectType)) { vlc_value_t floatValue = new vlc_value_t(); if((vobj.SubObject != IntPtr.Zero) && (VlcError.Success == __var_Get(vobj.SubObject, propertyName, ref floatValue))) { return floatValue.f_float; } } } catch(Exception ex) { this.lastErrorMessage = ex.Message; } return errorReturn; }
using(VlcObject vobj = new VlcObject(this.vlcHandle, objectType))
It will create a vobj, but the vobj.subObj is always NULL

Looking further inside:

Code: Select all

public VlcObject(int vlcHandle, ObjectType objectType) { vlc = vlc_current_object(vlcHandle); if(IntPtr.Zero != vlc) { if(objectType == ObjectType.VLC_OBJECT_VLC) { subObject = vlc; } else { subObject = __vlc_object_find(vlc, objectType, ObjectSearchMode.FIND_CHILD); } } }
The __vlc_object_find() call isn't returning what is needed.

Please advise on how to properly use these functions and/or what is wrong with accessing those VLC variables?

lallous
New Cone
New Cone
Posts: 6
Joined: 23 Jun 2008 10:09

Re: C# and brightness control

Postby lallous » 23 Jun 2008 17:25

Hi Readers,

After a long day of research and debugging and getting to learn about VLC more, it turned out that the "adjust" video out filter must be loaded before you can access the "brightness" variables.

For that, you have to pass an option to VLC when adding the media file.

Initially, I tried to add the option as:

Code: Select all

video1.AddToPlayList(@"W:\Office.wmv", "Something", new string[] { "--vout-filter=adjust" });
But nothing happened...

I took a look at LibVlc.cs instead and say it has a AddTarget() that actually causes VLC to load the libadjust filter properly.
For that, I hacked the NativeVlc and mixed some of LibVlc into it, this is the quick hack, which ofcourse can be incorporated better later on:

Code: Select all

video1.Native().AddTarget2(@"w:\office.wmv", new string[] { ":vout-filter=adjust" });
Now, the "brightness" variable is there and I can control it using the initial code.

Hope that is of help,
Elias

jleroux61
New Cone
New Cone
Posts: 7
Joined: 25 Oct 2007 14:38

Re: C# and brightness control

Postby jleroux61 » 17 Jul 2008 18:55

Where did you post your hack?
Thanks
Jean

lallous
New Cone
New Cone
Posts: 6
Joined: 23 Jun 2008 10:09

Re: C# and brightness control

Postby lallous » 18 Jul 2008 09:08

My hack was posted here.

Just when adding a video to the playlist, make sure you pass an option to tell VLC to load the adjust filter, exactly as my last post demonstrates.

HTH
Elias


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 2 guests