Back to Home

VLC as a Windows service

streaming

VLC as a Windows service

After a long walk in the google world, I still found a solution to my problem. The problem was as follows - the company (or rather, directly to the authorities) found out about the existence of IP cameras, and urgently decided to buy and install them in the office. The choice fell on the D-link DCS 2102-2121 because they did not find anything else (expensive axis - one cost as much as 3 of these). Everything would not be bad, but there was one condition to bring the picture from them into a great network.

And so what problems confront us. Raise a web server (the benefit of ip is “white”), select a server for broadcasting streaming video and transcoding it to a more or less suitable format, actually servicing and monitoring the system. Everything is quite simple within the framework of long-stated materials. By default, our server is spinning on Windows Server 2003 sp2 (but because vryc didn’t work properly in vlc).

First, select a server for broadcasting video. VLC media player was chosen as the most popular means of organizing such things. Following a pretty good windowed interface, we see that setting up vlc to broadcast to http is pretty simple.




Here in the first window we select the source, click the stream, in the second we select the destination path http broadcast port and the file name that we will request from the host.



Pay attention to the parameters item, it describes all the parameters that you just selected. That is, if you do so,

vlc.exe rtsp://192.168.0.40:554/play2.sdp :sout=#transcode{vcodec=h264,vb=800,fps=15,scale=0,acodec=mp4a,ab=128,channels=2,samplerate=44100}:http{dst=:8081/1.flv} :no-sout-rtp-sap :no-sout-standard-sap :ttl=1 :sout-keep

then we will get the same thing just configured.
Now we put apache + php in it flowplayer we configure it on the http channel and voila, here it is our streaming broadcast. You can read more about this in other articles. Look =), you will find.
But here is no problem, the server rebooted and all our vlc windows flew to the smithereens. Pancake! Here comes one clever idea - startup, but can MB even cooler? Why not make it work even better, or rather, install the service with vlc. How to do it? Horror, I didn’t climb all (Russian-speaking, of course), until I realized bit by bit that there was nothing complicated, in general vlc is so multifaceted that it remains only to sit and wonder what is impossible here! So vlc with the streaming parameters we set can be started like this:

start /D "C:\Program Files\VideoLAN\VLC\" vlc.exe -I ntservice --ntservice-install --ntservice-name=VLC --ntservice-extraintf=dummy --ntservice-options="rtsp://192.168.0.40:554/play2.sdp --rtsp-caching=1200 –loop
--sout=#transcode{vcodec=h264,vb=256,fps=10,scale=0,acodec=mp4a,ab=64,channels=1,samplerate=22050}:http{dst=:8081/1.flv} --no-sout-rtp-sap --no-sout-standard-sap --ttl=1 --sout-keep"


Here I will explain some parameters. –I means launching vlc with a non-default interface, they are different such as http and others if you need to go to the vlc documentation. As you can see, the line --ntservice-install means to install the vlc service, --ntservice-name = VLC and this is its name, you can write of course, for example, you need to create different services that work at the same time, do not write anything by default it will be called VLC media player. To delete a service we write

start /D "C:\Program Files\VideoLAN\VLC\" vlc.exe -I ntservice --ntservice-uninstall --ntservice-name=VLC

Now the ntservice-extraintf = dummy parameter means in which interface the service will work. Dummy means that it is not there, if you specify http then an http interface will be created, but again, read about it in the documentation. --ntservice-options = "" and here in quotation marks, as you already understood, we indicate with what parameters our service should be launched.




Now everything works fine like a clock, but here, too, a problem looms, the cameras, although in Loop mode, periodically disappear anyway and you need to go and rebuild our newly created service. Why shouldn't great PHP assign processing to this annoying event? We create a page with the following contents:



Well, now if the camera "died" it and my director can reboot himself, then in the morning we sleep longer and stronger.

Read Next