|
Hoinăreală
|
|
|
Inregistrare sub linux a imaginilor de pe camera IP Camera Foscam 8918W
Recording images under Linux on IP Camera Foscam 8918W
Version 1 - Recording with vlc
IPCamera_record
#!/bin/bash
MINUTES=$(date +%M)
echo $MINUTES
HOUR=60
let LEFT=$HOUR-$MINUTES
echo $LEFT
let FIRSTTIME=$LEFT*60
for ((;;))
do
if [ $LEFT -gt 0 ]; then
vlc -vvv "http://hostname:port/videostream.cgi?user=username&pwd=password&resolution=32&rate=11" --no-sout-audio --sout "#std{mux=avi,access=file,dst=/pathname/$(date +%Y%m%d-%H%M).avi}" --run-time $FIRSTTIME --stop-time=$FIRSTTIME vlc://quit
fi
for (( i = 0 ; i <= 24; i++ ))
do
vlc -vvv "http://hostname:port/videostream.cgi?user=username&pwd=password&resolution=32&rate=11" --no-sout-audio --sout "#std{mux=avi,access=file,dst=/pathname/$(date +%Y%m%d-%H%M).avi}" --run-time 3600 --stop-time=3600 vlc://quit
done
done
exit 0
Record based Alarm
#!/bin/bash
for (( ;; ))
do
result=`lynx -dump -auth=Adminuser:password http://hostname:port/get_params.cgi | grep alarm_motion_armed`
if [ ${result:23:1} = 1 ]; then
vlcon=`ps x | pgrep vlc`
if [ -z $vlcon ]; then
vlc -vvv "http://hostname:port/videostream.cgi?user=username&pwd=password&resolution=32&rate=11" --no-sout-audio --sout "#std{mux=avi,access=file,dst=/pathname/$(date +%Y%m%d-%H%M).avi}" --run-time 3600 --stop-time=3600 vlc://quit
fi
else
VLCon=`ps x | pgrep vlc`
if [ -z $VLCon ]; then
echo VLC not started
else
kill -9 `ps x | pgrep vlc`
fi
fi
sleep 3
done
exit 0
Version 2 - Recording with avconv
alarm_record file
#!/bin/bash
#for (( ;; ))
while [ true ]
do
{
result=`/usr/bin/lynx -dump -auth=AdminUser:password http://hostname:port/get_params.cgi | grep alarm_motion_armed`
if [ ${result:23:1} == 1 ]; then
avconvon1=`ps x | pgrep avconv`
# Check if $avconv1 string is null
if [ -z "$avconvon1" ]; then
nohup /pathname/avconv -y -analyzeduration 0 -i "http://hostname:port/videostream.asf?user=AdminUser&pwd=password" -vf drawtext="fontfile='/usr/share/fonts/dejavu/DejaVuSans.ttf':text='%F %T' :x=10:y=10:fontsize=14:fontcolor=black@0.5" -qscale 4 -r 6 -c:v msmpeg4v2 /pathname/$(date +%Y%m%d_%H%M%S).asf >/dev/null 2>&1 &
pid=$!
fi
# On midnight record in another file
midnight=`date +%k%M%S`
if [ $midnight -le "000006" ]; then
# if $pid is non-zero
if [ -n "$pid" ]; then
kill ${pid}
unset $pid
fi
fi
else
avconvon2=`ps x | pgrep avconv`
# Check if $avconvon2 string is not null
if [ -n "$avconvon2" ]; then
kill ${pid}
unset pid
fi
fi
sleep 5s
}
done
exit 0
Copyright © 2021; All right reserved Hoinăreală.
|