seconds

All you've ever wanted to know about the ActiveX, Mozilla plugins, the web interface and various PHP extensions
edon
New Cone
New Cone
Posts: 8
Joined: 23 Mar 2011 19:32

seconds

Postby edon » 23 Mar 2011 22:10

Hi .. i have posted a thread before but i'm posting another one.

I have to monitor like 15 network streams ... I can achieve this with firefox like this:
channel1
<embed type="application/x-vlc-plugin" name="VLC" autoplay="yes" loop="yes" volume="50" width="320" height="160" audio-visual="Spectrum" target="http://1.1.1.1:8001">
<input type="button" onclick="mute()" value="Mute" />
channel 2
<embed type="application/x-vlc-plugin" name="VLC" autoplay="yes" loop="yes" volume="50" width="320" height="160" audio-visual="Spectrum" target="http://1.1.1.1:8002">
<input type="button" onclick="mute()" value="Mute" />

channel 3 etc etc etc... they all show up playing and everything is fine.
what i'd like to do to save my bandwidth is get screenshots from those network sources every like 5 seconds or 3 seconds. is that possible?

meteornp
New Cone
New Cone
Posts: 7
Joined: 16 Jan 2011 22:15

Re: seconds

Postby meteornp » 24 Mar 2011 07:31

It seems like interesting task...
Have you tried to Pause / Play videos in loop, so that only one is active... it will be 15 times less bandwidth usage.
You can copy-paste and try this html/js code:

Code: Select all

<html><head></head><body><script type="text/javascript"> //////////////creating 15 instances of vlc with example h264 stream//////////////////////// for (i=0;i<15;i++) document.write("<div style='padding:2px;float:left'><embed type='applic" +"ation/x-vlc-plugin' id='VLC" +i +"' width='200' height='200'></div>"); for (i=0;i<15;i++) { var vlc =document.getElementById('VLC'+i); vlc.playlist.add( "http://89.212.47.123:8080/stream/?channel=z1&stream=500kb"); } /////////////////////////////timer play/pause////////////////////////////////////////////// function playNext() { var vlc1 =document.getElementById('VLC'+curr); if (++curr>14) curr=0; var vlc2 =document.getElementById('VLC'+curr); vlc1.playlist.togglePause(); vlc2.playlist.play(); settimer(); } function settimer() { setTimeout('playNext()', 5000); } //////////////////////////////////Main://////////////////////////////////////////////////// var curr =14; settimer(); </script></body></html>
For your purpose, you can put 300ms instead of 5000.
(by the way: it is so cool to see that GoogleChrome plays this well, thanks to LarryDar for problem reporting about multiple instances)
Last edited by meteornp on 03 Apr 2011 19:35, edited 2 times in total.

edon
New Cone
New Cone
Posts: 8
Joined: 23 Mar 2011 19:32

Re: seconds

Postby edon » 24 Mar 2011 18:05

Hey thanks .. that's pretty cool but the point is.
I need 15 different channels to monitor and that sequence ( the time out stuff is really cool) are going to happen in the same box.

example:

channel 1 - first box - play that channel every 3-5 seconds
channel 2 second box - play that channel every 3-5 seconds
channel 3 third box - play that channel every 3-5 seconds

and so on
that'd be very helpful

meteornp
New Cone
New Cone
Posts: 7
Joined: 16 Jan 2011 22:15

Re: seconds

Postby meteornp » 25 Mar 2011 01:04

i meant that if every channel is played for ~300 ms, then all 15 channels will be refreshed in about 4.5seconds... but that was theory... in my test values bellow 2000 miliseconds do not perform pausing well... But if your streams are faster (local) ... maybe you have better results.
.......
in above code example for 15 channels, line:
"http://89.212.47.123:8080/stream/?chann ... ream=500kb"); }
must be replaced for different channels with exactly this line:
"http://1.1.1.1:"+(8000+i) ); }
.......
timeout setting 5000 can go down to 2000 and ... also faster versions should be tested (500ms or below)
if value 800ms in timeout for example is lower limit for normal behaviour of page in your test... than you achieved "refreshing all 15 channels" in 12 seconds.
...........
NON-VLC solution for your aim, in my opinion, can be ffmpeg tool on the "server-side" to create jpg snap-shots of all channels in some endless bash or batch loop... and to have at client-side page ajax or some kind of refreshing IMG sources... But it will be good if 15 vlc plugins succeds ...the way you started.
Last edited by meteornp on 25 Mar 2011 21:55, edited 1 time in total.

edon
New Cone
New Cone
Posts: 8
Joined: 23 Mar 2011 19:32

Re: seconds

Postby edon » 25 Mar 2011 02:14

hey thnx. agian :]
i have a streaming server which is connected directly to the pc i wanna do this.
as I don't understand java .. please make an example of that code for two channels and how to add more.


"http://89.212.47.123:8080/stream/?chann ... ream=500kb"); }
must be replaced for different channels with exactly this line:
"http://1.1.1.1:"+(8000+i) ); -- can u make an example of two channels and let me know how to add more and more.
thank you

meteornp
New Cone
New Cone
Posts: 7
Joined: 16 Jan 2011 22:15

Re: seconds

Postby meteornp » 25 Mar 2011 17:04

ok, no problem, you can use this 9-lines html version for fast testing (just changing "vlcs value" and period)

Code: Select all

<html><head></head><body><script type="text/javascript"> var vlcs =3; var period=2000; var addr="http://1.1.1.1"; var firstPort =8000; var max=vlcs-1; for (i=0;i<vlcs;i++) document.write("<div style='padding:2px;float:left'><embed type='appl" +"ication/x-vlc-plugin' id='VLC" +i +"' width='200' height='200'></div>"); for (i=0;i<vlcs;i++) document.getElementById('VLC'+i).playlist.add( addr+":"+(firstPort+i) ); function playNext() { document.getElementById('VLC'+curr).playlist.togglePause(); if (++curr>max) curr=0; document.getElementById('VLC'+curr).playlist.play(); settimer(); } function settimer() { setTimeout('playNext()', period); } var curr =max; settimer(); </script></body></html>
and here is also, longer, easier to read version:

Code: Select all

<html> <head><style type='text/css'>.box { padding:2px; float:left; }</style></head> <body> <div class='box'><embed type='application/x-vlc-plugin' id='VLC0' target='http://1.1.1.1:8000' width='240' height='160'></div> <div class='box'><embed type='application/x-vlc-plugin' id='VLC1' target='http://1.1.1.1:8001' width='240' height='160'></div> <div class='box'><embed type='application/x-vlc-plugin' id='VLC2' target='http://1.1.1.1:8002' width='240' height='160'></div> <!-- ... ... add vlc3,4,5 ... and change accordinaly below "vlcs value"--> <script type="text/javascript"> var vlcs =3; ///////////////////////////////////////////////////////////////// var curr =vlcs-1; function playNext() { document.getElementById('VLC'+curr).playlist.togglePause(); curr =curr+1; if (curr > (vlcs-1)) curr=0; document.getElementById('VLC'+curr).playlist.play(); settimer(); } function settimer() { setTimeout('playNext()', 2000); } settimer(); </script> </body> </html>

edon
New Cone
New Cone
Posts: 8
Joined: 23 Mar 2011 19:32

Re: seconds

Postby edon » 25 Mar 2011 17:27

hey thank you soo muchhhhh .. it's actually working great for me :] Im gonna put it up and try it in real life :)

what would be nice here which is alot to ask.. is there anything u can do about .. if a certain stream is not coming thru for some reason .. can it alert me somehow? like from all these sources the channel number 2 is not working .. the box for example turns read or smth if it's not working or smth?

lol i'm asking too much.. i'm new to this .. i have never done smth like this . .I am a network engineer

meteornp
New Cone
New Cone
Posts: 7
Joined: 16 Jan 2011 22:15

Re: seconds

Postby meteornp » 25 Mar 2011 18:18

ok, glad it worked...
till now, above code used just 2 vlc-plugin's functions: vlc.playlist.togglePause(), and vlc.playlist.play() ...
...
For checking state, by vlc documentation, there is "vlc.playlist.isPlaying" and "vlc.input.state" properties... and the second one is probably what you need ( http://www.videolan.org/doc/play-howto/en/ch04.html )
if you add this code inside javascript (just before </script> tag):

Code: Select all

function alertStates() { dump="states\r\n"; for (i=0;i<vlcs;i++) dump +=document.getElementById('VLC'+i).input.state +"\r\n"; dump +="."; alert(dump); } setInterval('alertStates()', 5000);
then on every 5 seconds, you will have a messageBox alert with display of states of all channels. state 3 means playing, 4 - paused ... and those two states are "normal" ... so channels with non-normal states you want to be red-colored...
After test (if it behaves like we predict...) function alertStates() should be changed to do something else instead of alert, like this (pseudo-code):
if (vlc.inputstate isNot [3 or 4]) then vlc.parentDiv.BORDER = "2px solid RED" ... else BORDER-none.
----------------
... but changing BORder value of DIV is non-VLC-specific stuff, and if test pass ok, i can send you by PM... i am not sure if there is some solution to make direct vlc object red colored or something... but border of container div will work ok.

edon
New Cone
New Cone
Posts: 8
Joined: 23 Mar 2011 19:32

Re: seconds

Postby edon » 27 Mar 2011 00:42

Hey thnx.. ur thing is workign fine and stuff.. but here is what i did else

vlc.exe --video-filter=scene --vout=dummy --aout=dummy --intf=dummy --dummy-quiet --scene-width=150 --scene-height=150 --scene-replace --scene-format=png --scene-ratio=30 --scene-prefix=ktv --scene-path=C:\wamp\www\streams http://1.1.1.1:8005 vlc://quit

it works both on linux and windows

what this does is .. take a snapshot of the video and generate a small PNG file on the directory and everytime it generates files it resplaces the old one .. and i can have this on my apache server where i can have some java/php script to test the file size. .. if there is no stream the file size is 0.. so i modify java script and php to alert me or whatever. ( I have a friend who helps me about this)
on linux machine i have set it up with a script to email/text me if the file name is 0 which means one of the channels is down.

but the problem comes here .. now lol :]

when i put 30 instances of that command above .. it generates the pictures to fast ... which consumes my bandwidth cuz believe it or not I have to do this for 120 channels.. 40 each different languages (anyways)

can u come up with an idea to do this every like 30 seconds or a minute that way i'm gonna be better :]
thank you for all ur help

meteornp
New Cone
New Cone
Posts: 7
Joined: 16 Jan 2011 22:15

Re: seconds

Postby meteornp » 27 Mar 2011 06:32

well, maybe the same advice as previous ... (returning to the begin of topic) ... to run that command one by one circularly inside a loop for every channel, instead of 'all at once'... and add: "--start-time=0 --stop-time=0.5" in vlc params because, as i see, "vlc://quit" do not quits vlc without it.


Return to “Web and scripting”

Who is online

Users browsing this forum: No registered users and 2 guests