Index: motion.c
===================================================================
--- motion.c	(revision 211)
+++ motion.c	(working copy)
@@ -330,6 +330,9 @@
 			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 @@
 		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 @@
 			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);
 			}
Index: motion.h
===================================================================
--- motion.h	(revision 211)
+++ motion.h	(working copy)
@@ -272,6 +272,9 @@
 	/* 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 */
Index: picture.c
===================================================================
--- picture.c	(revision 211)
+++ picture.c	(working copy)
@@ -648,6 +648,8 @@
 	const char *jpegpath;
 	char previewname[PATH_MAX];
 	char filename[PATH_MAX];
+	struct tm tmptime;
+	int tmpshots;
 
 	if(cnt->preview_max){
 #ifdef HAVE_FFMPEG
@@ -662,6 +664,11 @@
 			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 @@
 		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;
 	}
 }
