You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was wondering if anyone else has seen an issue where the snapshot occurs too frequently because the system clock is being set backwards by periodic NTP updates? I suspect the issue applies to time lapse videos as well.
I'm going to post my experience here for the benefit of anyone else who comes across this rare issue.
I'm running motion 4.3.2 on a very old arm 32 platform called the Seagate Central. I have "snapshot_interval 3600" configured to take a snapshot photo once an hour.
This platform keeps time very poorly. Every 30 minutes the NTP update service runs and the system clock gets set backwards abruptly by up to about 10 seconds!
What this means is, the "snapshot_interval" feature decides it needs to take a snapshot because it discovers that the current frame's timestamp (cnt->time_current_frame) is less than the timestamp of the last frame processed (cnt->time_last_frame). (See mlp_snapshot() )
I have a very simple patch that seems to fix the problem. It simply makes sure that when cnt->currenttime is gathered in mlp_prepare() that it hasn't gone backwards. The problem is that it may potentially stop video / image capture for up to a second because if the allotted number of "shots" have already been taken in the second when the time changes, then the system will have to wait for the next second to tick over before is starts taking shots again.
This issue could be completely fixed if motion changed to using something like clock_gettime(CLOCK_MONOTONIC_RAW, ...) to find the current time. CLOCK_MONOTONIC_RAW counts the time the system has been up irrespective of NTP updates or manual system time adjustments. The thing with CLOCK_MONOTONIC_RAW is that it's not always supported....at least on my very old system it isn't!! It would also make the code more complicated because you'd have to keep track of one time stamp for snapshots and another for labelling images with a human readable timestamp.
I hope this saves someone else the time it took me to troubleshoot this weird issue!
All the best!
Berto
Patch:
--- src/motion.c.orig 2021-09-26 13:35:35.079558871 +1000
+++ src/motion.c 2021-09-27 13:42:59.364269223 +1000
@@ -1897,6 +1897,14 @@ static void mlp_prepare(struct context *
/* Get time for current frame */
cnt->currenttime = time(NULL);
+ /* Sanity check time */
+ if (cnt->currenttime < cnt->lastframetime) {
+ /*
+ * System time has gone backwards. NTP update?
+ */
+ cnt->lastframetime = cnt->currenttime;
+ }
+
/*
* localtime returns static data and is not threadsafe
* so we use localtime_r which is reentrant and threadsafe
This discussion was converted from issue #1414 on March 14, 2022 05:05.
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Reported on the mail list: https://sourceforge.net/p/motion/mailman/message/37356939/
Patch:
Beta Was this translation helpful? Give feedback.
All reactions