📜 ⬆️ ⬇️

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, the authorities themselves) learned about the existence of IP cameras, and urgently decided to buy and install them into the office. The choice fell on the D-link DCS 2102-2121, since they found nothing more (expensive axis - one cost as 3 such). All would not be bad, but there was one condition to display a picture of them in a great network.

And so what problems confront us. Raise the web server (good ip "white"), choose a server for streaming video streaming and transcoding it into a less suitable format, proper maintenance and monitoring of the system. Everything is quite simple in the framework of long-laid materials. By default, the server is spinning on Windows Server 2003 sp2 (and because it didn’t succeed in running the vlc as it should in frya).

First, select the server for video broadcasting. VLC media player was chosen as the most popular means of organizing such things. Following a rather nice window interface, we see that it is quite simple to configure vlc to broadcast to http.



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



Pay attention to the item parameters in it describes all the parameters that you just chose. That is, if you do this

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

That we will receive the same only already configured.
Now we put apache + php in it. Flowplayer tune it to the http channel and voila, here it is our streaming broadcast. You can read more about this in other articles. Look =), find.
But that's not the problem, the server rebooted and all our vlc windows flew to smithereens. Pancake! Here comes one clever idea - autoload, but can mb be even cooler? Why not make it work still cooler, or rather install the service with vlc. How to do it? The horror, I was not at all clamoring (Russian-speaking, of course), until I realized in pieces that there was nothing complicated, in general, the vlc is so multifaceted that one can only sit and wonder what is impossible here! So, the vlc with the streaming parameters that we set can be run 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 a road 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, of course you can write something else, for example, you need to create different services running at the same time, do not write anything by default called VLC media player. To remove the service write

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

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




Well, now everything works like a clock, but a problem looms on the horizon, even though the cameras are in Loop mode, but from time to time they still fall off and we need to go and rebuild our newly created service. Why shouldn't great PHP be assigned to handle this annoying event? Create a page with the following content:

<?php exec("net stop vlc");exec("net start vlc");?>

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

Source: https://habr.com/ru/post/115020/


All Articles