To watch (with stereo sound from jack) a camera with MPlayer:
mkfifo /tmp/fifo mplayer tv:// \ -tv adevice=\"plug:SLAVE=jack\":immediatemode=0:alsa:forcechan=2:amode=1:driver=v4l2:width=640:input=1:height=400:norm=PAL-I \ -vf bmovl=0:0:/tmp/fifo \ -vo xv
Use as an mplayer include file.
# Use as mkfifo /tmp/fifo; mplayer -include thisfile tv:// tv=driver=v4l2:device=/dev/video0:adevice="plug:SLAVE=jack":immediatemode=0:alsa=1:forcechan=2:amode=1:input=1:norm=PAL-I vf=bmovl=0:0:/tmp/fifo vo=xv
The big one. This sets up a stream to be read by localhost. It can be watched locally once with mplayer, but is best used as an input to vlc, which is great at sending multicast streams, but not so good at talking to soundcards and cameras, so you may want to disable sound on vlc to stop it crashing Jack.
Though you may test it with mplayer -nocache http://localhost:8080/, the preferred way is to use vlc http://localhost:8080/ --ttl 2 --sout "#duplicate{dst=std{access=rtp,mux=ts,dst=239.255.0.0:5004}}" on your server and mplayer -nocache rtp://239.255.0.0:5004/ on your clients. You can use a program like smcroute to span networks on your routers.
If you can use IPv6, switch 239.255.0.0 for an RFC 3306 address like [ff3e:40:2001:db8:1337:cafe:d0be:f00d] which is unique globally. Substitute 2001:db8:1337:cafe/64 to your own IPv6 prefix. d0be:f00d may be any number from 8000:0000 through ffff:ffff.
mplayer did not support receiving an IPv6 stream, but ffmpeg and ffplay were tested and do receive it.
#!/bin/bash
STREAM=tv://
if test "$1" != ""
then
STREAM="${1}"
fi
mkfifo /tmp/fifo
fuser -k /dev/video0
exec 3>&0
exec 4>&2
nc6 --continuous -l -s 127.0.0.1 -l -p 8080 -s 127.0.0.1 -e $'/bin/bash -c $\'
FILE=~/wensley/tessellate.png
T1=$(file -b ${FILE})
T2=$(cut -d"," -f2 <<<"${T1}")
read WIDTH X HEIGHT <<<"${T2}"
(echo RGBA32 ${WIDTH} ${HEIGHT} 0 0 0 0; convert ${FILE} rgba:-) > /tmp/fifo &
echo -ne "HTTP/1.0 200 OK\r\nContent-Type: video/mpeg\r\n\r\n"
exec mencoder -nocache -really-quiet -include settings '"${STREAM}"$' 0>&3 2>&4
\''
For VLC 1.0.4 it is possible to pipeline it directly from mencoder:
FILE=~/wensley/tessellate.png
T1=$(file -b ${FILE})
T2=$(cut -d"," -f2 <<<"${T1}")
read WIDTH X HEIGHT <<<"${T2}"
(echo RGBA32 ${WIDTH} ${HEIGHT} 0 0 0 0; convert ${FILE} rgba:-) > /tmp/fifo &
mencoder -nocache -really-quiet -include settings tv:// -o - | cvlc - --ttl 2 --sout "#rtp{access=udp,mux=ts,dst=ff3e:40:2001:db8:1337:cafe:d0be:f00d,port=5004}"
VLC had long supported IPv6, though release 1.0.4 provides stable playback via JACK.
vlc rtp://@[ff3e:40:2001:db8:1337:cafe:d0be:f00d]:5004 --aout jack
A settings file is needed to do the encoding
abitrate=224 antd vbitrate=1152 work well on the IEEE 802.3 network called Fast Ethernet.
abitrate=56 and vbitrate=144 work on IEEE 802.11b network called wireless lan.
# check validity with mencoder -include settings tv:// -o /dev/null of=mpeg=yes mpegopts=format=mpeg2:tsaf=yes:muxrate=2000 oac=lavc=yes ovc=lavc=yes lavcopts=acodec=mp2:abitrate=224:vcodec=mpeg2video:vbitrate=1152:keyint=15:mbd=2:aspect=4/3:threads=8 tv=adevice="plug:SLAVE=jack":immediatemode=0:alsa=1:forcechan=2:amode=1:driver=v4l2:input=1:norm=PAL-I vf=bmovl=0:0:/tmp/fifo msglevel=all=-1 o=-