From 22dc449836b47c615e7c90ec5974b3832ce090f6 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 29 Mar 2012 16:19:07 +0200 Subject: [PATCH] Zeitstempel verbessert --- Dump.sh | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Dump.sh b/Dump.sh index 53d3315..c57f9b0 100755 --- a/Dump.sh +++ b/Dump.sh @@ -33,14 +33,19 @@ trap 'quit 0' SIGINT SIGTERM EXIT do_record() { for i in $CAMERAS; do echo "starting recording for camera $i" >&2 - OUTFILE_START=dump_cam${i}_$(date +%s) - ( wget --ignore-length --http-user=$USERNAME --http-passwd=$PASSWORD http://${SERVER_IP}:$PORT/cam/$i/stream.mjpeg -O $OUTFILE_START -q 2>&1 >> /dev/null ) & - THIS_WGET_PID=$! - ( - while ps -p $THIS_WGET_PID >> /dev/null 2>&1; do sleep 1; done - mv $OUTFILE_START ${OUTFILE_START}_$(date +%s).mjpg + OUTFILE_START=tmp_dump_cam_${i}_$(date +%s)_RANDOM$RANDOM.mjpg + ( + EXACT_START_TIME=$(date +%s.%N) + outfile_close_trap() { + EXACT_END_TIME=$(date +%s.%N) + touch $OUTFILE_START + mv $OUTFILE_START dump_cam_${i}_${EXACT_START_TIME}_${EXACT_END_TIME}.mjpg + echo trapped + } + trap outfile_close_trap SIGINT SIGTERM EXIT + wget --ignore-length --http-user=$USERNAME --http-passwd=$PASSWORD http://${SERVER_IP}:$PORT/cam/$i/stream.mjpeg -O $OUTFILE_START -q 2>&1 >> /dev/null ) & - WGET_PIDS="$WGET_PIDS $THIS_WGET_PID" + WGET_PIDS="$WGET_PIDS $!" done echo "$WGET_PIDS" > ${PIDFILE_BASE}_${1}