stream a webcam, using highly compressed h264 instead of typical mpg

Got a logitech webcam c300, it uses the “uvcvideo” kernel module.
Typically you would grab video using “motion” and stream it on mpeg, well that’s rubbish if you want better
compression, so let’s do it using the best of the best: h264.
#!/bin/ksh
DEV=/dev/logitechcam
ps -ef | grep -i vlc | grep -v grep |grep -i logitechcam | awk ‘{ print $2 }’| while read P;do
kill -9 $P
done
VLC=”/usr/local/bin/cvlc v4l2://$DEV :input=2 :input-slave=alsa://hw:2,0 –alsa-samplerate=32000
–v4l2-controls-reset –v4l2-auto-white-balance=1 –v4l2-do-white-balance=1 –v4l2-autogain=1 –sout ”
21/433
CAM=”transcode{vcodec=h264,acodec=mp4a,width=320,height=240,vb=64,ab=24,channels=1,venc=x264}:standard{access=http,dst=0.0.0.0:8090/stream.flv}”
22/433
23/433
#CAM=”transcode{vcodec=mjpg,width=320,height=240}:duplicate{dst=std{access=http{mime=multipart/x-mixed-replace;boundary=–7b3cc56e5f51db803f790dad720ed50a}.mux=mpjpeg,dst=0.0.0.0:8090/m.mjpg}}”
${VLC} “#$CAM”
this produces a very decent quality stream at around 100kbps, audio also included!
Enjoy!
24/433

Leave a Reply

Your email address will not be published. Required fields are marked *