Doing something similar I use mplayer and / or mencoder. The following scripts show how!
Code:
#mplayer tv:// -tv driver=v4l:width=352:height=288:output=yv12:device=/dev/video0
# $1 = device, e.g. /dev/video0
# $2 = length in frames
#mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=/dev/video0 -frames 10
mplayer tv:// -tv driver=v4l:width=352:height=288:outfmt=yv12:device=$1 -frames $2
Code:
echo This script only records 30 seconds of video
# $1 = device, e.g. /dev/video0
# $2 = length in seconds
# $3 = output filename
#mencoder -tv driver=v4l:width=352:height=288:device=/dev/video0 \
# -ovc lavc -lavcopts vcodec=mpeg4 \
# -endpos 30 \
# -o output.avi tv://
mencoder -tv driver=v4l:width=352:height=288:device=$1 \
-ovc lavc -lavcopts vcodec=mpeg4 \
-endpos $2 \
-o $3.avi tv://
Both scripts i've left the crud in to help explain and both need you to pass cmdl args...
p.s. My cams are set up using v4l (video 4 linux)
Have fun!