Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/bin/sh
- # record-ping_cam1.sh
- # Check 24h if cam is alive, in case of error code 1 (offline) start record-waitfor_xxx.sh
- #
- IPCAM=192.168.xxx.xxx
- ping -w 86400 -i2 $IPCAM 0>/dev/null
- OFFLINE=$?
- if [ $OFFLINE -eq 1 ]
- then
- source /home/xxx/record-ping-waitfor_cam1.sh
- fi
- #!/bin/sh
- # record-ping-waitfor_cam1.sh
- # Check if Cam is alive, if yes (exit code 0) then execute record-ping-reconnect_xxx.sh
- #
- # Ping with infinitive loop - as soon as reachable (exit code 0) then go on with record script
- IPCAM=192.168.xxx.xxx
- while true; do ping -c1 $IPCAM > /dev/null && break; done
- ONLINE=$?
- if [ $ONLINE -eq 0 ]
- then
- source /home/xxx/record-ping-reconnect_cam1.sh
- fi
- #!/bin/sh
- # record-ping-reconnect_cam1.sh
- # Record IPcam after any case of signal lost
- #
- # This will print the current date and time in a format appropriate for storage
- STARTTIME=$(/bin/date +"%d.%m.%Y")-"("$(/bin/date +"%H").$(/bin/date +"%M")Uhr")"
- #
- ## IP Camera Names ##
- # Creating date stamps for each of the Cameras
- CAM=Cam1_$STARTTIME
- #
- ## Network and Local Storage Locations ## #Trailing '/' is necessary here
- RCDIR="/home/xxx/Reconnect/"
- #
- ## Record Time per File sec ##
- LENGTH="86400" # (24h)
- #
- ## Record Settings ##
- #
- # wait until cam is ready to capture again
- sleep 40s
- # start capture this camsource
- ffmpeg -v 0 -rtsp_transport tcp -i "rtsp://device:port/11" -vcodec copy -an -t $LENGTH $RCDIR$CAM1.mkv & echo $! > /home/xxx/Reconnect/PIDs/ffmpeg_cam1.pid
- # start the ping routine, check the cam for connectivity
- source /home/xxx/record-ping_cam1.sh & echo $! > /home/xxx/Reconnect/PIDs/ping_cam1.pid
- exit
Add Comment
Please, Sign In to add comment