we only use event_file if we are writing out a jpg, so only generate the event_file string if we are writing out jpgs

This commit is contained in:
Isaac Connor 2019-04-04 12:37:25 -04:00
parent 271937f005
commit f6d5038586
1 changed files with 7 additions and 9 deletions

View File

@ -456,9 +456,9 @@ void Event::AddFramesInternal( int n_frames, int start_frame, Image **images, st
frames++; frames++;
if ( monitor->GetOptSaveJPEGs() & 1 ) {
static char event_file[PATH_MAX]; static char event_file[PATH_MAX];
snprintf(event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames); snprintf(event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames);
if ( monitor->GetOptSaveJPEGs() & 1 ) {
Debug(1, "Writing pre-capture frame %d", frames); Debug(1, "Writing pre-capture frame %d", frames);
WriteFrameImage(images[i], *(timestamps[i]), event_file); WriteFrameImage(images[i], *(timestamps[i]), event_file);
} else { } else {
@ -539,27 +539,25 @@ void Event::AddFrame(Image *image, struct timeval timestamp, int score, Image *a
frames++; frames++;
if ( monitor->GetOptSaveJPEGs() & 1 ) {
static char event_file[PATH_MAX]; static char event_file[PATH_MAX];
snprintf(event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames); snprintf(event_file, sizeof(event_file), staticConfig.capture_file_format, path, frames);
if ( monitor->GetOptSaveJPEGs() & 1 ) {
Debug(1, "Writing capture frame %d to %s", frames, event_file); Debug(1, "Writing capture frame %d to %s", frames, event_file);
if ( ! WriteFrameImage(image, timestamp, event_file) ) { if ( ! WriteFrameImage(image, timestamp, event_file) ) {
Error("Failed to write frame image"); Error("Failed to write frame image");
} }
} else { } else {
//If this is the first frame, we should add a thumbnail to the event directory //If this is the first frame, we should add a thumbnail to the event directory
if ( frames == 1 || score > (int)max_score ) { if ( (frames == 1) || (score > (int)max_score) ) {
WriteFrameImage(image, timestamp, snapshot_file); WriteFrameImage(image, timestamp, snapshot_file);
} }
// The first frame with a score will be the frame that alarmed the event // The first frame with a score will be the frame that alarmed the event
if (!alarm_frame_written && score > 0) { if ( (!alarm_frame_written) && (score > 0) ) {
alarm_frame_written = true; alarm_frame_written = true;
WriteFrameImage(image, timestamp, alarm_file); WriteFrameImage(image, timestamp, alarm_file);
} }
} }
if ( videowriter != NULL ) { if ( videowriter != NULL ) {
Debug(3, "Writing video");
WriteFrameVideo(image, timestamp, videowriter); WriteFrameVideo(image, timestamp, videowriter);
} }
@ -625,7 +623,7 @@ Debug(3, "Writing video");
} }
} }
} }
} } // end if frame_type == ALARM
/* This makes viewing the diagnostic images impossible because it keeps deleting them /* This makes viewing the diagnostic images impossible because it keeps deleting them
if ( config.record_diag_images ) { if ( config.record_diag_images ) {