VLC Multicasting for IPTV into TVHeadend¶
Requirements¶
Various other video formats exist that are not natively able to be displayed within TV Headend, these include systems such as CCTV, v4l devices and various other inputs. Generally if they can be viewed/opened by VLC then they should be able to be transcoded by VLC and multicast which allows TV Headend to receive them as an IPTV channel.
Implementation¶
To implement this you need to have VLC and whatever video plugins required to read/encode various formats. In my example the source is an mjpeg stream (Produced by http://motion.sourceforge.net common v4l cctv software for linux. Each camera provides an mjpeg stream on a specific http port). Therefore on my (headless) TVH server I installed vlc (Debian package).
First you should check VLC will decode and display your input stream, so in my case running (On a machine with X11 or X11 forwarding, or windows machine with VLC for testing):
vlc -vvv http://192.168.0.1:8001
Allowed me to stream and watch the video being produced. (In this case my motion server was on 192.168.0.1 and the webcam_port defined in motion set to 8001).
VLC transcoding¶
To get vlc to transcode (headless), you simply run the vlc stream adding an sout command which will incorporate the transcode options as well as the multicast destination and port (Remember multicast is 'broadcast' on your network, so you must ensure your network adapter has MULTICAST enabled too). So for my example, to multicast my webcam I would use:
cvlc -v http://192.168.0.1:8001 --sout "#transcode{vcodec=mp2v,vb=800,scale=1,acodec=none}:std{access=udp{ttl=1},mux=ts,dst=239.0.0.1:1234}"
So this sends to multicast address (group) 239.0.0.1 on UDP port 1234. When you've ran this command you should get output from vlc showing it open the stream and begin the multicast.
Jump back to your testing machine and then run:
vlc -vvv udp://239.0.0.1:1234
You should see your multicast stream. If so then you're multicasting! You can now add the stream into TV Headend. If you don't receive your stream, slowly increase the number of v's on the command line for your streamer (the cvlc above) or the client until you get enough debug to see the issue. Generally if your input stream drops frames or is slow to respond then you may have issues with the transcode (Dropped frames/slow replies are bad for multicast/transcoded streams).
TV Headend¶
In TV Headend you need to add your stream, go to Configuration > IPTV and add a service, you should fill in the details based on your cvlc command, so as my example above you would enter:
Enabled - ticked Channel name - The name you wish to appear in your main channel line-ups Interface - the ethernet interface you're multicasting on (Typically eth0 for most single-adapter machines) Group - This is the multicast address, so 239.0.0.1 here UDP Port - the port defined in your multicast, so 1234 here
Save changes, and you should now see this channel in your channel line-up (Add a channel number) and tune into the channel, you should get your CCTV stream.
NOTE : There are various caveats within VLC to get this working which are outside the scope of this document, until you can get VLC streaming/multicasting then don't proceed! It may take trial and error to get this part right.
- andyb2000 31/August/2012
Updated by Andy Brown over 12 years ago · 2 revisions