Streaming TV Using VLC
Hardware/Software :
- USB 1.0 V4L TV Tuner (using the usbvision)
- Linux 2.6.20 w/ Gentoo
- VLC 0.8.6b
- 15" Samsung Laptop w/ Centrino + Pentium-M 1.5GHz
What this does
- Connects to the V4L device, lists 5 items in the playlist corresponding to the 5 different free-to-air analog channels in London, UK.
- Captures video from /dev/video0 and audio from /dev/dsp (via the mic-in or line-in)
- Displays the output to the screen in full screen.
- Encodes the video and audio using MPEG-4 (via ffmpeg) and streams result using RTP to two local machines.
- Announces the stream location via SAP (Service Announcement Protocol)
- Enables the ncurses and http interface so you can change channels via SSH or remotely.
How to use it
- Save and run as "vlc.stream.sh"
- On a client machine which supports VLC (eg. Mac, Windows, Linux, BeOS), open up network stream on port "1234" or "1244".
- Alteratively, enable "SAP announcments" in options and it will appear in your VLC playlist
Remember
- Multicast kills the stream on wireless.
- Mute the Mic/Line In, but turn on capture for those
- The VLC stream is around 3-5 secs behind the display on the computer.
Screen Shot
vlc.stream.sh
#!/bin/sh
INTERFACE="--intf ncurses --extraintf http "
#INTERFACE="--extraintf http "
# itv1: 487250 : 23
# bbc1: 511250 : 26
# four: 543250 : 30
# bbc2: 567250 : 33
# five: 599250 : 37
TV_INPUT="v4l:/dev/video0:norm=pal:size=320x240:channel=0,adev=/dev/sound/dsp"
FREQS=( 487250 511250 543250 567250 599250 )
CHANS=( [487250]="itv" [511250]="bbc1" [543250]="four" [567250]="bbc2" [599250]="five" )
INPUTS=""
for freq in ${FREQS[@]}; do
chan=${CHANS[$freq]}
INPUTS="${INPUTS} ${TV_INPUT/:norm/:name=${chan}:norm}:frequency=${freq}"
done
OPTS_TRANS_VIDEO="vcodec=mp4v,vb=256,venc=ffmpeg{keyint=50,hurry-up},fps=25"
OPTS_TRANS_AUDIO="acodec=mp4a,ab=64,samplerate=22050,channels=1"
OPTS_TRANS_NOAUDIO="acodec=dummy"
OPTS_TRANS="transcode{${OPTS_TRANS_VIDEO},${OPTS_TRANS_AUDIO}}"
MCAST_ADDR="239.255.12.23"
BCAST_ADDR="192.168.1.255"
UNI_ADDR1="192.168.1.64"
UNI_ADDR2="192.168.1.66"
OPTS_UNI="std{access=udp,mux=ts,dst=${UNI1_ADDR},sap,name=McBookUni}"
OPTS_MCAST="std{access=udp,mux=ts,dst=${MCAST_ADDR}}"
OPTS_RTP1="rtp{dst=${UNI_ADDR1},port=1234,sdp=sap://,name=McBookProTV}"
OPTS_RTP2="rtp{dst=${UNI_ADDR2},port=1244,sdp=sap://,name=MacBeeTV}"
OPTS_DISPLAY="display"
OPTS_STREAM="duplicate{dst=${OPTS_RTP1},dst=${OPTS_RTP2}}"
OPTS_OUTPUT="duplicate{dst=${OPTS_DISPLAY}, dst=\"${OPTS_TRANS}:${OPTS_STREAM}\"}"
echo ${OPTS_OUTPUT}
vlc ${INTERFACE} -f --color --loop --volume 128 ${INPUTS} \
--sout "#${OPTS_OUTPUT}"