Recording of stream
Hello,
I have done some testing to record the stream of the cams.
The FTP recording is not working, so i tried some other options.
First USB, by soldering a usb stick to the connector.
The USB is visible (via telnet) in cat /proc/kmsg and as /dev/1-1 and /dev/usbdev1.3.
But mounting seems not possible, not sure why, because I have a limited knowledge of Linux.
Next try, direct recording by my router with openrts on OpenWrt (you could also use your nas).
Openrtsp has very litle overhead, it only uses 2-3% CPU/stream
First by monitoring the logfile of the FTP server, used by the cam for uploading pictures.
I used Router + Openwrt + Pureftp + openRTSP
I changed the decoding of the main stream to 1280x720 CBR and 10 frames/s, to reduce filesize.
script
Code:
#!/bin/sh
FILE="/var/log/pureftpd.log"
SAVEMAP="/home/ftp/"
CAM111URL="rtsp://192.168.XXX.111:554/user=admin2_password=admin_channel=1_stream=0.sdp"
CAM222URL="rtsp://192.168.XXX.222:554/user=admin2_password=admin_channel=1_stream=0.sdp"
CAM111="cam111.mp4"
CAM222="cam222.mp4"
RECORDTIME="30"
LAST=`ls -l "$FILE"`
while true; do
sleep 1
NEW=`ls -l "$FILE"`
if [ "$NEW" != "$LAST" ]; then
MP4DATE=`date +%Y%m%d_%H%M%S`
openRTSP -b 3000000 -V -v -4 -d "$RECORDTIME" -w 1280 -h 720 -f 10 "$CAM111URL" > "$SAVEMAP$MP4DATE$CAM111" &
openRTSP -b 3000000 -V -v -4 -d "$RECORDTIME" -w 1280 -h 720 -f 10 "$CAM111URL" > "$SAVEMAP$MP4DATE$CAM222" &
wait
LAST=`ls -l "$FILE"`
fi
done
..
But with this option you record both streams at the same time and not only the the activated cam.
So next try was with the alarmserver on the IPCAM and netcat on the router to monitor an alarm.
I used Router + Openwrt + openRTSP + netcat
On IPcam activated alarmserver on port 15002
IP adress in my alarm message is inverter and in hex, therefore I use the hex code (CAM111HEX).
Check your hexcode on commandline with nc -l -p portno.
This will record the CAM on alarm output for 30 seconds.
script
Code:
#!/bin/sh
ALARMPORT="15002"
SAVEMAP="/home/ftp/"
LOGFILE="alarmlog.txt"
CAMURL="user=admin2_password=admin_channel=1_stream=0.sdp"
CAM111URL="rtsp://192.168.XXX.111:554/"
CAM222URL="rtsp://192.168.XXX.222:554/"
CAM111HEX="0x6F00A8C0"
CAM222HEX="0xDE00A8C0"
CAM111FILE="cam111.mp4"
CAM222FILE="cam222.mp4"
RECORDTIME="30"
while true; do
ALARMCALL=`nc -l -p "$ALARMPORT"`
FILEDATE=`date +%Y%m%d_%H%M%S`
echo $FILEDATE $ALARMCALL >> $SAVEMAP$LOGFILE
RUNNINGPROGS=`ps | grep openRTSP`
if [ -z "${ALARMCALL##*$CAM111HEX*}" ] && ! [ -z "${RUNNINGPROGS##*$CAM111URL*}" ]; then
openRTSP -b 3000000 -V -v -4 -d "$RECORDTIME" -w 1280 -h 720 -f 10 "$CAM111URL$CAMURL" > "$SAVEMAP$FILEDATE$CAM111FILE" &
fi
if [ -z "${ALARMCALL##*$CAM222HEX*}" ] && ! [ -z "${RUNNINGPROGS##*$CAM222URL*}" ]; then
openRTSP -b 3000000 -V -v -4 -d "$RECORDTIME" -w 1280 -h 720 -f 10 "$CAM222URL$CAMURL" > "$SAVEMAP$FILEDATE$CAM222FILE" &
fi
done
..