Dynamically changing contrast/hue/saturation

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
rs3d
New Cone
New Cone
Posts: 4
Joined: 19 Oct 2007 03:09

Dynamically changing contrast/hue/saturation

Postby rs3d » 19 Oct 2007 03:17

I'm currently using the VLC OCX v1 under Visual Basic Express 2005 and want to
change color proporties like contrast/hue/saturation dynamically while playback.

Is there a way to use ".Setvariable" to do this? I always create a crash, regardless
of the data structure I try to send. I browsed this forum extensively but couldn't
find infos about the filter effect usage...

Thanks in advance,
Rob

divx118
Blank Cone
Blank Cone
Posts: 95
Joined: 22 Jun 2006 18:19

Re: Dynamically changing contrast/hue/saturation

Postby divx118 » 19 Oct 2007 17:54

I used the v2 in my MCE plugin so i didn't have the setvariable. I solved it by taking the index where the video is, stopped it and changed the contrast hue and saturation by adding options. Then start the video at the index i got before the video was stopped.
I know it isn't the best solution but for me it was the only one.
Maybe this will work for you if you can't get the setvariable to work.

Maurice 8)

rs3d
New Cone
New Cone
Posts: 4
Joined: 19 Oct 2007 03:09

Re: Dynamically changing contrast/hue/saturation

Postby rs3d » 20 Oct 2007 11:38

Nice Idea Maurice!

As the V2 Plugin has no ".AddTarget", how do you communicate the options?

The documentation is very minimalistic and V2 seems to have even less
possibilities...

Thanks, Rob

divx118
Blank Cone
Blank Cone
Posts: 95
Joined: 22 Jun 2006 18:19

Re: Dynamically changing contrast/hue/saturation

Postby divx118 » 20 Oct 2007 16:13

From the documentation pages see below there are some more functions in v2 only the get and setvariable which are great aren't in there.
Build HTML pages that use the plugin (version > 0.8.5.1)
Additionally to viewing video on all pages, you can build custom pages that will use the advanced features of the plugin, using Javascript functions to control playback or extract information from the plugin.

The vlc plugin exports serveral objects that can be accessed for setting and getting information. When used improperly the API's will throw an exception that includes a string that explains what happened. For example when asking for vlc.input.length when there is no playlist item playing.

The vlc plugin knows the following objects:

audio : Access audio properties.

input : Access input properties.

playlist : Access playlist properties.

video : Access video properties.

log : Access log properties.

messages : Access to log message properties.

iterator : Access to log iterator properties.

The following JavaScript code shows howto get a reference to the vlc plugin. This reference can then be used to access the objects of the vlc plugin.

<html>
<title>VLC Mozilla plugin test page</title>
<body>
<embed type="application/x-vlc-plugin" pluginspage="http://www.videolan.org" version="VideoLAN.VLCPlugin.2"
width="640"
height="480"
id="vlc">
</embed>
<script language="Javascript">
<!--
var vlc = document.getElementById("vlc");
vlc.audio.toggleMute();
!-->
</script>
</body>
</html>
Root object
readonly properties

VersionInfo : returns version information string

read/write properties

none

methods

vlc.versionInfo() : returns version information string

Audio object
readonly properties

none

read/write properties

vlc.audio.mute : boolean value to mute and ummute the audio

vlc.audio.volume : a value between [0-200] which indicates a percentage of the volume.

methods

vlc.audio.toggleMute() : boolean toggle that mutes and unmutes the audio based upon the previous state

Input object
readonly properties

vlc.input.length : length of the input file in number of milliseconds

vlc.input.fps : frames per second returned as a float

vlc.input.hasVout : a boolean that returns true when the video is being displayed, it returns false when video is not displayed

read/write properties

vlc.input.position : normalized position in multimedia stream item given as a float value between [0.0 - 1.0]

vlc.input.time : the absolute position in time given in milliseconds, this property can be used to seek through the stream

<!-- absolute seek in stream !-->
vlc.input.time = <absolute seek>
<!-- relative seek in stream !-->
vlc.input.time = vlc.input.time + <relative seek>
vlc.input.state : current state of the input chain given as enumeration (IDLE/CLOSE=0, OPENING=1, BUFFERING=2, PLAYING=3, PAUSED=4, STOPPING=5, ERROR=6)

vlc.input.rate : input speed given as float (1.0 for normal speed, 0.5 for half speed, 2.0 for twice as fast, etc.)

methods

none

Playlist object
readonly properties

vlc.playlist.itemCount : number that returns the amount of items currently in the playlist

vlc.playlist.isPlaying : a boolean that returns true if the current playlist item is playing and false when it is not playing

read/write properties

none

methods

vlc.playlist.add(mrl) : add a playlist item as MRL (Multimedia Resource Locator). The MRL must be given as a string.

vlc.playlist.add(mrl,name,options) : add a playlist item as MRL (Multimedia Resource Locator), with metaname 'name' and options 'options'. All input values must be given as string.

vlc.playlist.play() : start playing the current playlist item

vlc.playlist.togglePause() : toggle the pause state for the current playlist item

vlc.playlist.stop() : stop playing the current playlist item

vlc.playlist.next() : iterate to the next playlist item

vlc.playlist.prev() : iterate to the previous playlist item

vlc.playlist.clear() : empty the current playlist, all items will be deleted from the playlist

vlc.playlist.removeItem(number) : remove the given item number (which cannot be greater then vlc.playlist.itemCount)

Video object
readonly properties

vlc.video.width : returns the horizontal size of the video

vlc.video.height : returns the vertical size of the video

read/write properties

vlc.video.fullscreen : when set to true the video will be displayed in fullscreen mode, when set to false the video will be shown inside the video output size. The property takes a boolean as input.

vlc.video.aspectRatio : get and set the aspect ratio to use in the video screen. The property takes a string as input value. Valid values are: "1:1", "4:3", "16:9", "16:10", "221:100" and "5:4"

methods

vlc.video.toggleFullscreen() : toggle the fullscreen mode based on the previous setting

Log object
readonly properties

vlc.log.messages : returns a messages object

read/write properties

vlc.log.verbosity : write number [-1,0,1,2,3] for changing the verbosity level of the log messages. The numbers have the following meaning: -1 disable, 0 info, 1 error, 2 warning, 3 debug.

methods

none

Messages object
readonly properties

messages.count : returns number of messages in the log

messages.severity : number that indicates the severity of the log message (0 = info, 1 = error, 2 = warning, 3 = debug)

message.name : name of VLC module that printed the log message (e.g: main, http, directx, etc...)

message.type : type of VLC module that printed the log message (eg: input, access, vout, sout, etc...)

message.message : the message text

read/write properties

none

methods

messages.clear() : clear the current log buffer. It should be called as frequently as possible to not overflow the plugins logging buffer. Call this method after the log messages of interest are read.

messages.iterator() : returns a messages iterator object, which is used to iterate over the messages in the log. <b>Don't clear the log buffer while holding an iterator object.</b>

Iterator object
readonly properties

iterator.hasNext : returns a boolean that indicates when true, that wheter vlc.log.messages.next() returns the next message.

read/write properties

none

methods

iterator.next() : returns the next message object it the log
You can also look at the source of the example page http://people.videolan.org/~damienf/plugin-0.8.6.html

Maurice 8)

rs3d
New Cone
New Cone
Posts: 4
Joined: 19 Oct 2007 03:09

Re: Dynamically changing contrast/hue/saturation

Postby rs3d » 22 Oct 2007 14:03

Thanks Maurice, so to understand you completely: You are playing the
same video with changed parameters from the same position? A snippet
of code would be really useful.

Thanks in advance, Rob

divx118
Blank Cone
Blank Cone
Posts: 95
Joined: 22 Jun 2006 18:19

Re: Dynamically changing contrast/hue/saturation

Postby divx118 » 22 Oct 2007 17:41

Ok i will look if i can filter out the code so you can understand it. Please note i did it in javascript, but at least you get the idea.
I will do it tonight and post the code.

Maurice 8)

divx118
Blank Cone
Blank Cone
Posts: 95
Joined: 22 Jun 2006 18:19

Re: Dynamically changing contrast/hue/saturation

Postby divx118 » 22 Oct 2007 19:42

Ok here is the code, I made a little html page so you can try it in your internet browser.
Just copy and paste in notepad and save it as test.htm
If you open the htm page you have to first fill in the MRL any path to a videofile on your hd ie "C:\test.avi" without the quotes.
I commented the code, but if you don't understand it just ask.
It works great the only problem is you see the player start and stop.

Maurice 8)


Code: Select all

<html> <script language="javascript"> function getVLC(name) { if (window.document[name]) { return window.document[name]; } if (navigator.appName.indexOf("Microsoft Internet")==-1) { if (document.embeds && document.embeds[name]) return document.embeds[name]; } else // if (navigator.appName.indexOf("Microsoft Internet")!=-1) { return document.getElementById(name); } } function doGo(targetURL,gamma,brightness,hue,contrast,saturation) { var vlc = getVLC("vlc"); var options = new Array(":vout-filter=adjust",":gamma="+gamma,":brightness="+brightness,":hue="+hue,":contrast="+contrast,":saturation="+saturation); if (vlc.input.state==3) {stop=vlc.input.position;vlc.playlist.stop();} // Check if the player is playing , retreive the playing position and stop the player else {stop=0} while (vlc.input.state!=0) { //wait until the player is stopped } vlc.playlist.items.clear(); while( vlc.playlist.items.count > 0 ) { // clear() may return before the playlist has actually been cleared // just wait for it to finish its job } //alert(targetURL+" , "+options); var itemId = vlc.playlist.add(targetURL, null, options); if( itemId != -1 ) { // clear the message log and enable error logging vlc.log.verbosity = 1; vlc.log.messages.clear(); // play MRL vlc.playlist.playItem(itemId); } else { // disable log vlc.log.verbosity = -1; alert("cannot play at the moment !"); } while (vlc.input.state!=3 ) { //wait until the player is playing } try { var mediaLen = vlc.input.length;//check if it is not a life stream } catch(e) { var mediaLen=0 } if( mediaLen > 0 ) {vlc.input.position=stop}//if it is not a life stream jump to the previous position }; function doChangeAspectRatio(arValue) { var vlc = getVLC("vlc"); if( vlc.input.state && vlc.input.hasVout ) { vlc.video.aspectRatio = arValue; } aspectRatio = arValue; }; </script> <head> <meta http-equiv="Content-Type" content="text/html; charset=windows-1252"> <title>CHANGE HUE SATURATION CONTRAST BRIGHTNESS</title> </head> <TABLE> <TR><TD colspan="2"> MRL: <INPUT size="90" id="targetTextField" value=""><br> Gamma (0-10):<INPUT size="10" id="gamma" value="1"> Brightness (0-2):<INPUT size="10" id="brightness" value="1"> Hue (0-360):<INPUT size="10" id="hue" value="0"> Contrast (0-2):<INPUT size="10" id="contrast" value="1"> Saturation (0-3):<INPUT size="10" id="saturation" value="1"> <INPUT type=submit value="Go" onClick="doGo(document.getElementById('targetTextField').value,document.getElementById('gamma').value,document.getElementById('brightness').value,document.getElementById('hue').value,document.getElementById('contrast').value,document.getElementById('saturation').value);"> </TD></TR> <TR><TD align="center" colspan="2"> <!-- Insert VideoLAN.VLCPlugin.2 --> <OBJECT classid="clsid:9BE31822-FDAD-461B-AD51-BE1D1C159921" codebase="http://downloads.videolan.org/pub/videolan/vlc/latest/win32/axvlc.cab#Version=0,8,6,0" width="640" height="480" id="vlc" events="True"> <param name="MRL" value="" /> <param name="ShowDisplay" value="True" /> <param name="AutoLoop" value="False" /> <param name="AutoPlay" value="False" /> <param name="Volume" value="50" /> <param name="StartTime" value="0" /> <EMBED pluginspage="http://www.videolan.org" type="application/x-vlc-plugin" progid="VideoLAN.VLCPlugin.2" width="640" height="480" name="vlc"> </EMBED> </OBJECT> </TD></TR> <TR><TD colspan="2"> <SELECT readonly onChange='doChangeAspectRatio(this.value)'> <OPTION value="default">Default</OPTION> <OPTION value="1:1">1:1</OPTION> <OPTION value="4:3">4:3</OPTION> <OPTION value="16:9">16:9</OPTION> <OPTION value="221:100">221:100</OPTION> <OPTION value="5:4">5:4</OPTION> </SELECT> <TABLE> <body bgcolor="#047943"> </body> </html>

rs3d
New Cone
New Cone
Posts: 4
Joined: 19 Oct 2007 03:09

Re: Dynamically changing contrast/hue/saturation

Postby rs3d » 22 Oct 2007 23:28

Very cool! Hope the ActiveX is still in development, but so this work for now!

Thank you so much Maurice!


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 26 guests