Fix movie file names

This commit is contained in:
MrDave
2021-07-03 18:04:39 -06:00
committed by Mr-Dave
parent a51b4cc454
commit 5fa2fb9290
3 changed files with 50 additions and 7 deletions

View File

@@ -52,9 +52,9 @@ static void algsec_img_show(ctx_cam *cam, Mat &mat_src
std::vector<int> param(2);
char wstr[10];
(void)algmethod;
testdir = cam->conf->target_dir;
imwrite(testdir + "/src_" + algmethod + ".jpg", mat_src);
//imwrite(testdir + "/src_" + algmethod + ".jpg", mat_src);
algmdl.isdetected = false;
for (indx0=0; indx0<src_pos.size(); indx0++) {
@@ -84,7 +84,7 @@ static void algsec_img_show(ctx_cam *cam, Mat &mat_src
snprintf(wstr, 10, "%.4f", fltr_weights[indx0]);
putText(mat_src, wstr, Point(r.x,r.y), FONT_HERSHEY_PLAIN, 1, 255, 1);
}
imwrite(testdir + "/detect_" + algmethod + ".jpg", mat_src);
// imwrite(testdir + "/detect_" + algmethod + ".jpg", mat_src);
}
/* We check the size so that we at least fill in the first image so the

View File

@@ -487,6 +487,7 @@ static void event_extpipe_end(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
int retcd;
(void)evnt;
(void)img_data;
(void)fname;
@@ -503,7 +504,11 @@ static void event_extpipe_end(struct ctx_cam *cam, motion_event evnt
if ((cam->conf->movie_retain == "secondary") && (cam->algsec_inuse)) {
if (cam->algsec->isdetected == false) {
remove(cam->extpipefilename);
retcd = remove(cam->extpipefilename);
if (retcd != 0) {
MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO
, _("Unable to remove file %s"), cam->extpipefilename);
}
} else {
event(cam, EVENT_FILECLOSE, NULL, cam->extpipefilename, (void *)FTYPE_MPEG, ts1);
}
@@ -511,7 +516,6 @@ static void event_extpipe_end(struct ctx_cam *cam, motion_event evnt
event(cam, EVENT_FILECLOSE, NULL, cam->extpipefilename, (void *)FTYPE_MPEG, ts1);
}
}
}
@@ -742,6 +746,7 @@ static void event_movie_closefile(struct ctx_cam *cam, motion_event evnt
,struct ctx_image_data *img_data, char *fname, void *ftype, struct timespec *ts1)
{
int retcd;
(void)evnt;
(void)img_data;
(void)fname;
@@ -753,9 +758,14 @@ static void event_movie_closefile(struct ctx_cam *cam, motion_event evnt
free(cam->movie_norm);
}
cam->movie_norm = NULL;
if ((cam->conf->movie_retain == "secondary") && (cam->algsec_inuse)) {
if (cam->algsec->isdetected == false) {
remove(cam->newfilename);
retcd = remove(cam->newfilename);
if (retcd != 0) {
MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO
, _("Unable to remove file %s"), cam->newfilename);
}
} else {
event(cam, EVENT_FILECLOSE, NULL, cam->newfilename, (void *)FTYPE_MPEG, ts1);
}
@@ -769,10 +779,15 @@ static void event_movie_closefile(struct ctx_cam *cam, motion_event evnt
if (cam->movie_motion != NULL) {
free(cam->movie_motion);
}
cam->movie_motion = NULL;
if ((cam->conf->movie_retain == "secondary") && (cam->algsec_inuse)) {
if (cam->algsec->isdetected == false) {
remove(cam->motionfilename);
retcd = remove(cam->motionfilename);
if (retcd != 0) {
MOTION_LOG(ERR, TYPE_EVENTS, SHOW_ERRNO
, _("Unable to remove file %s"), cam->motionfilename);
}
} else {
event(cam, EVENT_FILECLOSE, NULL, cam->motionfilename, (void *)FTYPE_MPEG_MOTION, ts1);
}

View File

@@ -1746,6 +1746,16 @@ int movie_init_norm(struct ctx_cam *cam, struct timespec *ts1)
retcd = movie_open(cam->movie_norm);
if (retcd == 0) {
/* We set this after the movie open so we get the extension */
retcd = snprintf(cam->newfilename, PATH_MAX, "%s",cam->movie_norm->filename);
if ((retcd < 0) || (retcd >= PATH_MAX)) {
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO
,_("Error setting file name"));
return -1;
}
}
return retcd;
}
@@ -1798,6 +1808,15 @@ int movie_init_motion(struct ctx_cam *cam, struct timespec *ts1)
retcd = movie_open(cam->movie_motion);
if (retcd == 0) {
retcd = snprintf(cam->motionfilename, PATH_MAX, "%s",cam->movie_motion->filename);
if ((retcd < 0) || (retcd >= PATH_MAX)) {
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO
,_("Error setting file name"));
return -1;
}
}
return retcd;
}
@@ -1858,6 +1877,15 @@ int movie_init_timelapse(struct ctx_cam *cam, struct timespec *ts1)
retcd = movie_open(cam->movie_timelapse);
}
if (retcd == 0) {
retcd = snprintf(cam->timelapsefilename, PATH_MAX, "%s",cam->movie_timelapse->filename);
if ((retcd < 0) || (retcd >= PATH_MAX)) {
MOTION_LOG(ERR, TYPE_ENCODER, NO_ERRNO
,_("Error setting file name"));
return -1;
}
}
return retcd;
}