Репозиторий Sisyphus
Последнее обновление: 1 октября 2023 | Пакетов: 18631 | Посещений: 37549551
en ru br
Репозитории ALT

Группа :: Мониторинг
Пакет: acti-recorder

 Главная   Изменения   Спек   Патчи   Исходники   Загрузить   Gear   Bugs and FR  Repocop 

acti-recorder-0.2/000075500000000000000000000000001153643150700141015ustar00rootroot00000000000000acti-recorder-0.2/Makefile000064400000000000000000000003751153643150700155460ustar00rootroot00000000000000DESTDIR=/

.PHONY: install remove

install:
install -pD acti-recorder.conf $(DESTDIR)/etc/acti-recorder.conf
install -pD acti-recorder $(DESTDIR)/usr/bin/acti-recorder
remove:
rm -f $(DESTDIR)/etc/acti-recorder.conf $(DESTDIR)/usr/bin/acti-recorder

acti-recorder-0.2/acti-recorder000075500000000000000000000054371153643150700165630ustar00rootroot00000000000000#!/bin/bash

# ACTI Recorder.
# Copyright (C) 2010 Denis Klimov
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.



if [ -z "$1" ]; then
if [ -f "acti-recorder.conf" ]; then
CONFIG="acti-recorder.conf"
elif [ -f "/etc/acti-recorder.conf" ]; then
CONFIG="/etc/acti-recorder.conf"
elif [ -f "/usr/local/etc/acti-recorder.conf" ]; then
CONFIG="/usr/local/etc/acti-recorder.conf"
fi
else
CONFIG="$1"
fi

if [ ! -f "$CONFIG" ]; then
echo "Config doesn't exist"
exit 1
fi

echo "Using config $CONFIG"
. $CONFIG


if [ ! -d "$VIDEO_DIR" ]; then
echo "Directory $VIDEO_DIR doesn't exist. Trying create.."
mkdir -p "$VIDEO_DIR"
fi


RECORD_RUNING=0
STOP_DELAY_COUNTER=$STOP_DELAY

function start_record() {
rname=`date +/%Y/%Y-%m/%Y-%m-%d/%Y-%m-%d_%H:%M:%S`
full_path="$VIDEO_DIR/$rname.avi"
mkdir -p `dirname $full_path`
cvlc rtsp://$HOST:$RTSP_PORT --sout "file/avi:$full_path" >/dev/null 2>&1 &
echo $!
}

function stop_record() {
cvlc_pid="$1"
kill "$cvlc_pid"
}

while true; do
if [ "$RECORD_MODE" == "trigger" ]; then
# Get alarm bit from camera
HEX=`curl "http://$HOST/cgi-bin/mpeg4?USER=$USER&PWD=$PASSWORD&DIO_STATUS" 2>/dev/null|cut -d 'x' -f2`
BIN=`echo "ibase=16; obase=2; $HEX"| bc`
BYTE=`printf "%08d" $BIN`
i=`echo "8-$RECORD_BIT"|bc`
BIT=`echo $BYTE|cut -c $i`
echo -n "$BIT"

# Start record
if [ "$BIT" == "1" -a "$RECORD_RUNING" == "0" ]; then
cvlc_pid=`start_record`
RECORD_RUNING=1

if [ ! -z "$ALARM_COMMAND" ]; then
eval $ALARM_COMMAND
fi
fi

# Reset stop delay counter
if [ "$BIT" == "1" ]; then
STOP_DELAY_COUNTER=$STOP_DELAY
fi

# Decrease stop delay counter
if [ "$BIT" == "0" -a "$STOP_DELAY_COUNTER" != "0" ]; then
STOP_DELAY_COUNTER=`echo "$STOP_DELAY_COUNTER-1"|bc`
fi

# TODO: More accurate stop recording
if [ "$BIT" == "0" -a "$RECORD_RUNING" == "1" -a "$STOP_DELAY_COUNTER" == "0" ]; then
echo -e "\nStop recording"
stop_record $cvlc_pid
RECORD_RUNING=0
fi

sleep 1
elif [ "$RECORD_MODE" == "forever" ]; then
# Records each hour in one file.
cvlc_pid=`start_record`
while [ "$(date +%M:%S)" != "00:00" ]; do
sleep 1
done
sleep 1
stop_record $cvlc_pid
else
echo "Wrong RECORD_MODE: $RECORD_MODE"
exit 1
fi
done

acti-recorder-0.2/acti-recorder.conf000064400000000000000000000005121153643150700174710ustar00rootroot00000000000000VIDEO_DIR="$HOME/CameraRecords"
HOST="192.168.1.100"
RTSP_PORT=7070
USER="Admin"
PASSWORD="123456"

RECORD_MODE=forever # trigger or forever

# Trigger mode options
RECORD_BIT=4
STOP_DELAY=10 # In seconds


FPS=8
SCALE="1280:1024"
VBITRATE=1024

ALARM_COMMAND="play -t mp3 /home/zver/Downloads/alerts/alarm_3.wav >/dev/null 2>&1"
 
дизайн и разработка: Vladimir Lettiev aka crux © 2004-2005, Andrew Avramenko aka liks © 2007-2008
текущий майнтейнер: Michael Shigorin