fre, 14.04.2006 kl. 22.02 skrev Petter Gundersen:
> On 4/14/06, Kyrre Ness Sjobak <[EMAIL PROTECTED]> wrote:
> > Hello!
> >
> > How can i time when a "cat" recording is about to start, and how long it
> > should continue - without killing and starting it manually?
> >
> > Is there any bash command that could kill it for me after a set time, or
> > some built-in tool in ivtv that does this (ivtv-encoder? What does this
> > do?)
> >
> 
> See the simple bash script below. It waits one hour, and makes a 30
> min recording.
> 
> ----------------------
> #!/bin/bash
> sleep 1h # Instead of using sleep here, you can start the script by using
>          # the at command, see 'man at'.
> 
> cat /dev/video0 > /path/to/some/filename.mpg &
> 
> CAT_PID=$!
> # $! is PID of last job running in background.
> 
> sleep 30m
> # You should add some check here to make sure cat is still running,
> # otherwise you might accidentally kill some other process.
> kill $CAT_PID
> 
> 
> 
> Regards,
> Petter
> 


Thanks, that has some really elegant elements, compared to my own
solution. I think ill modyfy it (to keep the "general purposeness"), and
place it in /usr/local/bin :)

if [ $1 = "--help" ]; then
    echo "Usage: ivtv-time filename recordtime(secounds)"
    exit
fi

cat /dev/video0 > $1 &
catpid=$(ps -C "cat /dev/video0" -o pid=)
echo "Recording, finished in " $2 " secounds"
sleep $2
kill $catpid

One thing: How accurate is sleep?


_______________________________________________
ivtv-users mailing list
[email protected]
http://ivtvdriver.org/mailman/listinfo/ivtv-users

Reply via email to