convert

Why mplayer doesn’t work in some scripts

Sometimes you need to get mplayer/mencoder inside a script. Let’s say you want to automatically grab a picture from your webcam every 10 seconds:

capture_w=here goes the capture width of your webcam
capture_h=and here the height
mplayer -slave -quiet -input file=/tmp/tmp.fifo \
-vf screenshot,eq2,scale=500:375 \
-tv driver=v4l:quality=90:height=$capture_h:width=$capture_w:input=0:norm=pal:\
noaudio:contrast=10:brightness=-25:saturation=100 tv:// \
-vo null &>/dev/null&
while :; do
echo "screenshot 0" >/tmp/tmp.fifo
sleep 10;
done

(parameters of the tv option may vary for your webcam)
or encode the last grabbed frames of the webcam in a video: