From dc26b5d46c0c9784e99f61b7ec8fb76b647fbdaf Mon Sep 17 00:00:00 2001 From: DagErlandsson Date: Sun, 17 Feb 2008 08:34:45 +0000 Subject: [PATCH] Added a startup delay of 2 sec. If not fps is wrong in movie if it starts within this time e.g. output_all. --- motion.c | 9 +++++++-- motion.h | 1 + 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/motion.c b/motion.c index 7ec8e399..8296873f 100644 --- a/motion.c +++ b/motion.c @@ -753,6 +753,8 @@ static int motion_init(struct context *cnt) /* Prevent first few frames from triggering motion... */ cnt->moved = 8; + /* 2 sec startup delay so FPS is calculated correct */ + cnt->startup_frames = cnt->conf.frame_limit * 2; return 0; } @@ -987,6 +989,9 @@ static void *motion_loop(void *arg) /* Increase the shots variable for each frame captured within this second */ cnt->shots++; + if (cnt->startup_frames > 0) + cnt->startup_frames--; + if (get_image){ if (cnt->conf.minimum_frame_time) { minimum_frame_time_downcounter = cnt->conf.minimum_frame_time; @@ -1429,13 +1434,13 @@ static void *motion_loop(void *arg) * If post_capture is enabled we also take care of this in the this * code section. */ - if (cnt->conf.output_all) { + if ( cnt->conf.output_all && (cnt->startup_frames == 0) ) { cnt->detecting_motion = 1; /* Setup the postcap counter */ cnt->postcap = cnt->conf.post_capture; cnt->current_image->flags |= (IMAGE_TRIGGER | IMAGE_SAVE); motion_detected(cnt, cnt->video_dev, cnt->current_image); - } else if (cnt->current_image->flags & IMAGE_MOTION) { + } else if ( (cnt->current_image->flags & IMAGE_MOTION) && (cnt->startup_frames == 0) ) { /* Did we detect motion (like the cat just walked in :) )? * If so, ensure the motion is sustained if minimum_motion_frames */ diff --git a/motion.h b/motion.h index 28de5fa9..c2a7476d 100644 --- a/motion.h +++ b/motion.h @@ -348,6 +348,7 @@ struct context { time_t connectionlosttime; /* timestamp from connection lost */ int lastrate; + unsigned short int startup_frames; unsigned short int moved; unsigned short int pause; int missing_frame_counter; /* counts failed attempts to fetch picture frame from camera */