Hello Everybody!
I have tried to develop a script, which automatically records video files from a usb capture device ( it is a Vga to usb capture device) at system start- up. The script should also restart the Encoding application and proceed with the recording, if the Vga source is being changed. I have tried to develop a pair of scripts: The first starts Mencoder and restarts it, if Mencoder gets interrupted. The second looks after the Vga source and interrupts Mencoder, if there is no singal. Due to me being pretty inexperienced, the code is pretty lame, but when i run both scirpts in a shell- everything works fine: Regardless of how often i pull and reinsert the vga cable- it restarts Mencoder and begins to record a new avi- file. When i run both scripts through /etc/rc.local however, the video gets recorded to the same same file after i pull and reinsert the plug. Furthermore- it stops recording alltogether after the third test of reinserting the cable.
I will be greatful for any help.
If it has any relevance, i am running Ubuntu 9.04 Here are the scripts:
vgaSignal.sh:
Code:
while [ 1 ]
do
# Check if the capture device is recieving signal
# This is done by reading the otput of an application provided by the vendor
# Possible outputs: "v2u: detected 1024x768 (60.0 Hz)" if there is a vga signal, or
# "v2u: failed to detect video modea" if there is no signal
if /home/stream/v2u | grep "v2u: detected"
then
echo Recieving Signal
else
# If not- kill mencoder, so that the other script could do a restart
killall mencoder
fi
sleep 2
done
recording.sh:
Code:
while [ 1 ]
do
# Check if mencoder is running
if pidof mencoder
then
echo Running
# If not, start it whith the appropriate settings
else
mencoder \
-oac lavc \
-ovc lavc \
-lavcopts vcodec=mpeg4:keyint=100:vbitrate=8000:vhq -noaspect \
-o /home/stream/Recording_from_`date +%Y%m%d-%H%M%S`.avi \
-tv noaudio:driver=v4l:outfmt=bgr24:device=/dev/video0 tv://
fi
sleep 2
done
/etc/rc.local:
Code:
#
# By default this script does nothing.
cd /home/stream/vga2usb/ && make load
chmod 777 /dev/vga2usb0
/bin/sh /home/stream/scripts/recording.sh
/bin/sh /home/stream/scripts/vgaSignal.sh
exit 0
Best regards,
bmpenev