Motion - Bug Report 2008x 04x 12x 152823

BUG: post_capture seems to stop on max_mpeg_time frown, sad smile

I set my post_capture at an equivalent of 45 seconds (accurate with the use of the fillter frame patch) and my max_mpeg_time at 120 seconds. I create some motion in front of the camera for around 100 seconds and the result is I get 1 single video of exactly 120 seconds in length.

As the post_capture only ran 20 of it's 45 seconds, I'd expect motion to open another video file with the remaining 25 seconds but this never happens frown, sad smile

EDIT: One other thing I noticed is everytime max_mpeg_time is reached, motion forces a new event. Should a new video file always mean a new event? - max_mpeg_time for me just makes sure I don't have to wait a very long time to open a video over the Internet but as I still get the "output best" image for all the videos, I can also pick exactly what part of the same event I want to watch which is very nice.

EDIT2: As a temporary solution what I've done is under the ACTIONS AND EVENT CONTROL SECTION, I changed how postcap was handled to:

{{{

} else if (cnt->postcap) {
/* No motion, doing postcap /
/
cnt->current_image->flags |= (IMAGE_POSTCAP | IMAGE_SAVE); */
cnt->current_image->flags |= (IMAGE_TRIGGER | IMAGE_SAVE);
cnt->postcap--;
cnt->detecting_motion = 1;
motion_detected(cnt, cnt->video_dev, cnt->current_image);
}}}

Probably broke something but seems to work for now smile

Environment

Motion version: 3.2.10
ffmpeg version:  
Shared libraries: ffmpeg, mysql, postgresql
Server OS:  

-- RomanGaufman - 12 Apr 2008

Follow up

Roman attach your config files please , i've applied blank frame patch to svn trunk , so your "patch" should go there not to 3.2.10 yet.

-- AngelCarpintero - 14 Apr 2008

This patch can break two things, gap time and preview image (if using center). With patch gap is from the start of the new event/movie and not from last frame with motion.

I don't think we should commit this patch to SVN as it breaks the intension of the flags, a post capture frame can't be a trigger frame! A trigger frame is intended to be able to start a new event. In your case you want to do that, but I think it we should have more discussion what max_mpeg_time does do. It ends the event if it is longer than n sec. If there is still motion a new event is started. The important thing here is that there must be motion to start a new event. So I think this option should be renamed to max_event_time.

What you want to have is more like a max_movie_time, if the movie is longer than n sec, the current movie is closed and a new one is created. If we do this there is some problems to deal with:

1. Should a preview image be saved to the second movie?

2. How should the movie, and preview (if any), be named?

The event number is same.

Should the timestamp to the movie filename be from the event start? Movie start?

3. What should be saved into a SQL database (if configured)?

-- DagErlandsson - 14 Apr 2008

Ah, I see, I don't use gap or center preview image smile -- I noticed with my "patch" motion seems to detect more false movement now though (or maybe it's just a coincivence?). Another thing is if it breaks gap, why wouldn't it break post_capture? - I thought these 2 options are basically the same only 1 saves frames and the other doesn't - I use post_capture instead of gap because I need those frames for audio sync.

1) I think a preview image should be saved for the second movie - with "output_normal best" and a shorter max_movie_time you can get a really good idea of what happened for the entire duration of the event without even opening the movies.

2) I think the movie should be named the same as max_mpeg_time does now with the only difference being %v shouldn't be incremented and post_capture should be honoured.

3) Hmm, not sure about sql, I assume the same as max_mpeg_time does now too?

Attached my motion config, sorry about the mess in there it is generated by a python script for each camera.

-- RomanGaufman - 14 Apr 2008

I haven't looked into if it can trigger motion more easy with your patch, it might due to you set that a post capture frame would start an new event even if there isn't any motion, and it is there ignoring minimum_motion_frames (in your patch).

To change the code to create more than one preview / movie for one event there is needed some magor redesign in the code so it wouldn't happen in near future. If we do it we also have a solution to the issues with timestamp, filenames and SQL. In 2 and 3 it mention name it as before, but it isn't possible as it ends the event and it is dependent on the event.

-- DagErlandsson - 14 Apr 2008

Hmm, I see. How difficult would it be to force a new event on max_mpeg_time if postcap>1 - that way it's a new event but post_capture is honoured and it shouldn't ignore minimum_motion_frames as the trigger frame is only done once. Good/bad idea?

-- RomanGaufman - 16 Apr 2008

It should be possible to get it to work. If I have to do it I had let the event end just as it is to day and added code that checks if you are in an event and have a postcap frame. If not start a new event, just something like

if ( (cnt->current_image->flags & IMAGE_POSTCAP) && (cnt->event_nr == cnt->prev_event) ) {

cnt->current_image->flags |= IMAGE_TRIGGER;

motion_detected(cnt, cnt->video_dev, cnt->current_image);
}


Thanks for that, I will apply that now to my motion boxes and report of any problems. Thanks again smile

-- RomanGaufman - 18 Apr 2008

Here's how I set it up and unfortunately I tried generating motion with output_all and moving the camera with PTZ controls and it still only creates one 2 minute video and dumps the remaining post_capture frown, sad smile

Index: dist/trunk/motion.c
===================================================================
--- dist/trunk/motion.c (revision 332)
+++ dist/trunk/motion.c (working copy)
@@ -1487,6 +1487,11 @@

/***** MOTION LOOP - ACTIONS AND EVENT CONTROL SECTION ****/

+ if ( (cnt->current_image->flags & IMAGE_POSTCAP) && (cnt->event_nr = cnt->prev_event) ) {
+ cnt->current_image->flags |
IMAGE_TRIGGER;
+ motion_detected(cnt, cnt->video_dev, cnt->current_image);
+ }
+
if (cnt->current_image->diffs > cnt->threshold) {
/
flag this image, it have motion /
cnt->current_image->flags |= IMAGE_MOTION;
@@ -1616,7 +1621,7 @@

cnt->makemovie = 0;
/
Reset post capture /
- cnt->postcap = 0;
+ /
cnt->postcap = 0; /

/
Finally we increase the event number */
cnt->event_nr++;

-- RomanGaufman - 19 Apr 2008

Can you try to move the if() to just before this code

/* Update last frame saved time, so we can end event after gap time */
if (cnt->current_image->flags & IMAGE_SAVE) {
cnt->lasttime = cnt->current_image->timestamp;
}

In the place you have the IMAGE_POSTCAP flag haven't been set yet so the condition is never true.

Sorry that I can't test it just now as my Linux compile machine is down and dead.

-- DagErlandsson - 19 Apr 2008

Thanks but I still only get a single 2 minute video frown, sad smile -- Attached is the patch against 334.

-- RomanGaufman - 19 Apr 2008

I need to fix my compile machine, learn the code better or realy look in the code..... It should be
if ( (cnt->current_image->flags & IMAGE_POSTCAP) && (cnt->event_nr != cnt->prev_event) ) { 

-- DagErlandsson - 19 Apr 2008

Lol, that fixed it smile - it works beautifully now, thank you very much - I will test this over the next day or so and report of any problems.

-- RomanGaufman - 19 Apr 2008

Been running for a while now and seems to work without breaking anything far as I can tell. - I will carry on keeping a close eye on it.

-- RomanGaufman - 20 Apr 2008

Lets review possible side effects in trunk.

-- AngelCarpintero - 22 May 2008

Fix record

BugReportForm edit

TopicTitle post_capture seems to stop on max_mpeg_time frown, sad smile
BugStatus Monitored
AssignedBugTo
SubmittedBy TWikiGuest
Topic attachments
I Attachment Action Size Date Who Comment
honour_postcap.patchpatch honour_postcap.patch manage 806 bytes 22 May 2008 - 00:59 RomanGaufman Working patch to make sure motion honours postcap and not just dumps it on_mpeg_end (which ends event)
motion-conf.confconf motion-conf.conf manage 1 K 14 Apr 2008 - 12:31 RomanGaufman  
r334_not_working.patchpatch r334_not_working.patch manage 805 bytes 19 Apr 2008 - 13:35 RomanGaufman Postcapture still isn't honoured frown, sad smile
Topic revision: r17 - 22 May 2008, AngelCarpintero
Copyright © 1999-2017 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.