Motion - Bug Report 2006x 03x 11x 162137

BUG: Follow-Up to BugReport2006x02x07x162149 (snapshot timing)

I tried your and still have problem of the timing of the snapshots.

Comparing the "fix" you inserted to motion.c with the "proposed" fix I gave in original bug report makes good sense.

HOWEVER, the timestamp of the name of the created file still does not reflect the "intended" timestamp (with seconds ending with 00).

Instead it shows the actual timestamp and the seconds field of the filename is often "01" or even "02".

To fix this, I added ONE LINE to motion.c in the section "SNAPSHOT FEATURE SECTION" so that now that code works for me.

Also fixed compile error that someone else already noted that you fixed in daily motion-20060309-084350

Here is the section with my change:

    /* Did we get triggered to make a snapshot from control http? Then shoot a snap
     * If snapshot_interval is not zero and time since epoch MOD snapshot_interval = 0 then snap
     * We actually allow the time to run over the interval in case we have a delay
     * from slow camera.
     * Note: Negative value means SIGALRM snaps are enabled
     * httpd-control snaps are always enabled.

    /* time_current_frame is used both for snapshot and timelapse features */
    time_current_frame = cnt->currenttime;            

    if ( (cnt->conf.snapshot_interval > 0 && cnt->shots == 0 &&
          time_current_frame % cnt->conf.snapshot_interval <= 
          time_last_frame % cnt->conf.snapshot_interval) ||
        cnt->snapshot) {
            cnt->currenttime_tm->tm_sec = 0;  /* GS - REQUIRED FOR CORRECT TIMESTAMP OF THE FILE */
            event(cnt, EVENT_IMAGE_SNAPSHOT, newimg, NULL, NULL, cnt->currenttime_tm);
            cnt->snapshot = 0;

Note that I added: cnt->currenttime_tm->tm_sec = 0;

PLEASE add this to the "official" source code tree . Maybe you want to add an option to enable/disable this feature, that's up to you. I like to keep current with your development efforts but do not want to always have to patch the newest code with my silly little one line fix. THANKS. g.swift

Test case

See description in BugReport2006x02x07x162149


Motion version:
ffmpeg version: not used
Shared libraries: ffmpeg, mysql, postgresql
Server OS: Linux Fedora Core 4 , kernel 2.6.15-1.1833_FC4

-- GregSwift - 11 Mar 2006

Follow up

Fix record

Thanks for sharing your code. However I will not implement this solution.

I do not agree that the time stamp should be the "intended" time stamp. If the picture is taken 14:05:42 then the timestamp should say that. Many typical Motion users find it important that you can trust the timestamp 100%.

Also your solution only works for intervals that are whole minutes. What about 15 seconds? Some people may choose a 5 seconds interval. Your solution will make "00" 12 times in a row then.

So it may work in your special case - but I do not see your code as the way Motion should work.

You can do what you want without your fix. Just remove the seconds from the time stamp OR hardcode the "00" it in the text_right / filename.

You could instead have replaced the default text_right %Y-%m-%d\n%T with text_right %Y-%m-%d\n%H:%M:00

-- KennethLavrsen - 12 Mar 2006

Reply to Kenneth: I agree with your decision and understand your reasons. I will try hard-coding 00 in the snapshot_filename but will leave the correct seconds to be displayed with jpeg_filename and text_right. That will allow my php html scripts to correctly find the "intended" snapshot while still reporting/displaying the correct actual time. Thank you.
Topic revision: r3 - 12 Mar 2006, GregSwift
Copyright © 1999-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Please do not email Kenneth for support questions (read why). Use the Support Requests page or join the Mailing List.
This website only use harmless session cookies. See Cookie Policy for details. By using this website you accept the use of these cookies.