How to build a free, cheap in recourses but efficient video streaming server in minutes!
I was playing during the last months with red5, crtmp and others, trying to build a live streaming video server for the needs of my site.
Red5 is very powerful but very difficult to set up and lacks in support and manuals. Crtmp is easier, but still… I did some setups with both platforms, but I managed to setup the ultimate easy, in-minute and for n00bies platform to create a live video (or audio) streaming service with recording capabilities.
I have to mention that this solution is for use just by you and manually and not by clients / reselling / others.
The VLC solution
I was familiar with VLC, but as powerful it is, also hungry for resources is. Not always.
For our example, you will need a vps with as much BW as you can (or need). I used a box with 1GB memory and 2 virtual cores and I had 0.03 – 0.10 load when just re-transmitting stream and 0.22 – 0.35 load when I was re-encoded the stream. Memory was as low as 70 – 90MB! These values was valid with 4-5 viewers, I couldn’t test it with more. When I will use it for live site, I will update this.
You can manage your vlc via terminal, of course, but it is much easier if you start and configure your streams via remote desktop. The load values I wrote earlier, are with tightvnc remote console open, in an lxde desktop.
Install lxde desktop (or any other desktop you prefer) and a vnc server to your box. I used debian with lxde and vnc4server.
Create a non-root user (in our example user1) for your vnc and manage remotely your vps via desktop with that user (if you use root user, then vlc won’t open).
Install vlc both in your home pc and your vps.
Go to your home pc. Open a video to vlc or a capture device.
I used wmv3 encoding, because it is very powerful in lower bitrates and easily embed in a web page, but of course you can use any encoding you prefer. I also prefer h264 when retransmitting my video for watching in vlc or any media player and don’t want to embed it in a web page.
When opening the video or capture device, don’t select play but stream.
Add a http destination, chose port (you have to redirect in to your pc in your router, if you don’t have direct access to the web) and path (any name you want. If you don’t use path, then your address will be http://xx.xx.xx.xx:port/).
In transcoding options, chose “activate transcoding” and in the right, create a new profile for your needs.
I created for the wmv example, an ASF encapsulation, wmv2 video and audio profile.
Select the profile and press “stream”.
Now, go to your vps via remote desktop and open VLC.
Open “network stream” and use the address of your home pc (http://xx.xx.xx.xx:port/). I use no-ip to my router, so, I always have a url (http://example.no-ip.info) to use for my streams. Then, don’t select play but stream. In destination tab, create a http new destination, chose a port (you have to open the port to your iptables or any other firewall you use), select “activate transcoding” and then create a new profile, as you did in your home pc. To use fewer resources, check “keep original video and audio tracks” in the video and audio codec tab. It will not transcode the stream and will keep server load at minimum.
Then, press “stream”.
Now, your live stream is up and going. Watch it in a media player (e.g. vlc or classic media player).
If you want to embed it, that’s easy: create an .asx file like this:
<ASX version ="3.0"> <TITLE>live</TITLE> <ENTRY> <REF HREF ="http://xx.xx.xx.xx:yourport"/> </ENTRY> </ASX>
You will use your vps ip with the port that you used for streaming in the vps’s VLC.
Save it and use it in a web page, that has to contain this in the body section:
<embed src ="livestream.asx" width="xxx" height="xxx">
Use width and height same with your stream.
Voila! You are streaming to the world with your own server!
PS: I wanted to publish help code for installing xlde and vnc with separate users, but editing system didn't let me do it... Too long? Maybe, but when I tried to edit it I had a cloudflare message asked me for a captcha that didn't even shown!_