browser icon
You are using an insecure version of your web browser. Please update your browser!
Using an outdated browser makes your computer unsafe. For a safer, faster, more enjoyable user experience, please update your browser today or try a newer browser.

VLC Streaming video across the LAN

Posted by on January 2, 2009

Setting up a VLC Streaming Server

In a previous post I got the TV Card to work. Its great, recording from the video camera is a dream in Ubuntu.

We have a TV in the lounge with DSTV, a PC in the ‘study’ (corner of the lounge) and on the other side of the house a media PC in the bedroom. Its time to get the DSTV into the bedroom since we spend more time watching stuff there than in the lounge. I have the extra-view port of the DSTV decorder plugged into the TV card in the lounge and I can watch DSTV on the PC now.  So to get the ‘signal’ to the bedroom the logical solution was to stream it over the LAN rather than run a new RF cable and move the TV card into the other machine. Some research on the interwebs revealed vlc to be the popular choice.

Now vlc has always been my player of choice, but unfortunately ubuntu is a little slow on the updates. And in particular with backporting. At the time of writing, the latest vlc in the ubuntu archives is 0.8 and I need 0.9 in order to get v4l2 to work. So pop on over to tombuntu who have a post on how to get the latest installed without having to roll-your-own.

Once I got the new vlc installed it was simply a matter of browsing the vlc wiki and forums until I came up with the ideal settings for my stream.

To get VLC to play the DSTV channel on my TV Card (single line):

vlc -vvv v4l2:///dev/video0:width=720:height=576:input=1:tuner=0:tuner-frequency=471250:v4l2-adev=”hw:0,0″:v4l2-audio-method=3:v4l2-stereo:v4l2-samplerate=44100

To get VLC to stream a file onto the network (single line):

vlc -vvv /home/rob/myfile.avi  –sout ‘#transcode{vcodec=mp4v,acodec=mpga,vb=1200, ab=128,deinterlace}:rtp{mux=ts,dst=239.255.12.42,sap, name=”MyStream”}’

To get VLC to stream a file without showing a gui you can use -I to specify an alternate interface.
Popular options are: ncurses, logger and dummy

vlc -I logger <input> <output>

Putting it all together:
Create a run file for easy starting: ~/.vlc-streaming.sh and put the following line in it (single line).

vlc -I logger  v4l2:///dev/video0:width=720:height=576:input=1:tuner=0:tuner-frequency=471250:v4l2-adev=”hw:0,0″:v4l2-audio-method=3:v4l2-stereo:v4l2-samplerate=44100 –sout ‘#transcode{vcodec=mp4v,acodec=mpga,vb=1200, ab=128,deinterlace}:rtp{mux=ts,dst=239.255.12.42,sap, name=”MyStream”}’

Then you need to make the file executable:

chmod +x ~/vlc-streaming.sh

And thats it. To start the stream all you need do is run the script.

~/vlc-streaming.sh

This still requires you to keep the terminal open, so once you have everything tested and you want to make it completely backgrounded, you can edit the file and switch “-I logger” for “–daemon -I dummy”.

Connecting to the VLC Streaming Server from another machine:

This could not be easier. Because of the SAP announcement, all we need to do is open VLC on any other machine on the LAN, open the playlist and in the playlist options subscribe to SAP Announcements. Then within a minute or two (normally a few seconds), there will be a new playlist entry which we can watch.

Comments are closed.