diff --git a/CHANGELOG b/CHANGELOG index 29101ba5..13c5b4d0 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -12,8 +12,9 @@ Bugfixes http://www.lavrsen.dk/twiki/bin/view/Motion/MjpegToYUV420pPatch (Marius Rieder, Angel Carpintero). * Fixed a problem with locate and fixed mask overlay (Dag Erlandsson). + * Preview pictures get the timestamp of moment they were captured (Dag Erlandsson). + - 3.2.8 Formal Release - Summary of Changes Features diff --git a/CREDITS b/CREDITS index b4dd0cad..f547ccb7 100644 --- a/CREDITS +++ b/CREDITS @@ -386,6 +386,7 @@ Dag Erlandsson * Fixed a problem with locate and fixed mask overlay * Added preview center feature. http://www.lavrsen.dk/twiki/bin/view/Motion/PreviewCenter + * Fixed timestamp for preview pictures. Stephen Farrugia * Fixing the division by zero problem. diff --git a/ffmpeg.c b/ffmpeg.c index 283f1e56..296bf81e 100644 --- a/ffmpeg.c +++ b/ffmpeg.c @@ -127,7 +127,7 @@ static int mpeg1_write_trailer(AVFormatContext *s) void ffmpeg_init() { av_register_all(); - av_log_set_callback( (void *)ffmpeg_avcodec_log ); +// av_log_set_callback( (void *)ffmpeg_avcodec_log ); /* Copy the functions to use for the append file protocol from the standard * file protocol. diff --git a/motion.c b/motion.c index 6396f48c..49de2968 100644 --- a/motion.c +++ b/motion.c @@ -330,6 +330,9 @@ static void motion_detected(struct context *cnt, int diffs, int dev, unsigned ch memcpy(cnt->imgs.preview_buffer, newimg, cnt->imgs.size); cnt->preview_max = diffs; cnt->preview_cent_dist = distX*distX + distY*distY; + cnt->preview_time = cnt->currenttime; + cnt->preview_shots = cnt->shots; + /* We haven't yet draw the location on the image, do it if configured */ if (cnt->locate == LOCATE_PREVIEW || cnt->locate == LOCATE_ON) { alg_draw_location(location, imgs, imgs->width, cnt->imgs.preview_buffer, LOCATE_NORMAL); @@ -362,6 +365,9 @@ static void motion_detected(struct context *cnt, int diffs, int dev, unsigned ch memcpy(cnt->imgs.preview_buffer, newimg, cnt->imgs.size); cnt->preview_max = diffs; cnt->preview_cent_dist = distX*distX + distY*distY; + cnt->preview_time = cnt->currenttime; + cnt->preview_shots = cnt->shots; + if (cnt->locate == LOCATE_PREVIEW) { alg_draw_location(location, imgs, imgs->width, cnt->imgs.preview_buffer, LOCATE_NORMAL); } @@ -377,6 +383,9 @@ static void motion_detected(struct context *cnt, int diffs, int dev, unsigned ch memcpy(cnt->imgs.preview_buffer, newimg, cnt->imgs.size); cnt->preview_max = diffs; cnt->preview_cent_dist = distance; + cnt->preview_time = cnt->currenttime; + cnt->preview_shots = cnt->shots; + if (cnt->locate == LOCATE_PREVIEW) { alg_draw_location(location, imgs, imgs->width, cnt->imgs.preview_buffer, LOCATE_NORMAL); } diff --git a/motion.h b/motion.h index 9f7307c0..bf7cf562 100644 --- a/motion.h +++ b/motion.h @@ -272,6 +272,9 @@ struct context { /* Current preview frame, movement to img center distance * Note Dist is calculated distX*distX + distY*distY */ unsigned long preview_cent_dist; + time_t preview_time; /* Timestamp of preview image */ + int preview_shots; /* Shot of preview buffer image */ + int locate; struct coord location; /* coordinates for center and size of last motion detection*/ struct rotdata rotate_data; /* rotation data is thread-specific */ diff --git a/picture.c b/picture.c index c5640095..037a0d74 100644 --- a/picture.c +++ b/picture.c @@ -646,8 +646,10 @@ void preview_save(struct context *cnt) int use_jpegpath; #endif /* HAVE_FFMPEG */ const char *jpegpath; - char previewname[PATH_MAX]; + static char previewname[PATH_MAX]; char filename[PATH_MAX]; + struct tm tmptime; + int tmpshots; if(cnt->preview_max){ #ifdef HAVE_FFMPEG @@ -662,6 +664,11 @@ void preview_save(struct context *cnt) return; } #endif /* HAVE_FFMPEG */ + /* Save shots while processing preview image */ + tmpshots = cnt->shots; + cnt->shots = cnt->preview_shots; + localtime_r(&cnt->preview_time, &tmptime); + /* Save best preview-shot also when no movies are recorded or jpegpath is used. Filename has to be generated - nothing available to reuse! */ //printf("preview_shot: different filename or picture only!\n"); @@ -673,8 +680,11 @@ void preview_save(struct context *cnt) else jpegpath = (char *)DEF_JPEGPATH; - mystrftime(cnt, filename, sizeof(filename), jpegpath, cnt->currenttime_tm, NULL, 0); + mystrftime(cnt, filename, sizeof(filename), jpegpath, &tmptime, NULL, 0); snprintf(previewname, PATH_MAX, "%s/%s.%s", cnt->conf.filepath, filename, imageext(cnt)); put_picture(cnt, previewname, cnt->imgs.preview_buffer , FTYPE_IMAGE); + + /* Restore shots */ + cnt->shots = tmpshots; } }