#!/bin/shSTART=''DURATION=''usage(){ cat <<ENDusage: `basename $0` -s start -d duration -- mencoder_optionsthe start and duration should be expressed in the form hh:mm:ssif no start is given the recording begins immediatlyif the duration is empty mencoder should be stoped with a SIGINTExamples:# start recording at 6 AM and stop after 1 hour and 45 minutes# using full size PAL and a video bitrate of 900 kbpm`basename $0` -s 6:00:00 -d 1:45:00 -- -tv width=704:height=576 -lavcopts vbitrate=900ENDexit 1}while getopts :s:d: opt; do case $opt in s) START="$OPTARG" ;; d) DURATION="$OPTARG" ;; *) usage ;; esacdoneshift $(( $OPTIND - 1 ))EXTRAOPTS=''[ -n "$DURATION" ] && EXTRAOPTS="-endpos $DURATION"if [ -z "$START" ]; then INTERVAL=0else INTERVAL=$(( `date -d "$START" +%s` - `date +%s` )) # in seconds [ $INTERVAL -lt 0 ] && INTERVAL=$(( $INTERVAL + 3600 * 24 )) # add a dayfiecho "waiting $INTERVAL seconds..."sleep $INTERVAL# capture the sound from the Auxiliary port# (if it's the audio cable plugs into line-in use "Line", for CD-in use "CD")amixer set Aux cap# encodemencoder -quiet -oac mp3lame -lameopts vbr=2:q=7:mode=3 -ovc lavc \ -lavcopts vcodec=mpeg4:autoaspect:vlelim=-4:vcelim=7:lumi_mask=0.3:dark_mask=0.3:vbitrate=500 \ -tv driver=v4l2:width=352:height=288 $EXTRAOPTS \ -o /src/tv/tv_`date '+%Y-%m-%d_%H:%M:%S'`.avi "$@" tv://# reset capture device to microphoneamixer set Mic cap