diff --git a/src/zm_event.cpp b/src/zm_event.cpp old mode 100644 new mode 100755 index 23450e651..97407c0ab --- a/src/zm_event.cpp +++ b/src/zm_event.cpp @@ -645,7 +645,7 @@ void Event::AddFrame( Image *image, struct timeval timestamp, int score, Image * */ } -void Event::AddVideoFrame( struct timeval timestamp, int score ) +void Event::AddVideoFrame( Image *image, struct timeval timestamp, int score ) { if ( !timestamp.tv_sec ) { @@ -653,9 +653,15 @@ void Event::AddVideoFrame( struct timeval timestamp, int score ) return; } + //If this is the first frame, we should add a thumbnail to the event directory + if(frames == 10){ + char snapshot_file[PATH_MAX]; + snprintf( snapshot_file, sizeof(snapshot_file), "%s/snapshot.jpg", path ); + WriteFrameImage( image, timestamp, snapshot_file ); + } frames++; - //Warning("Adding video frame"); + struct DeltaTimeval delta_time; DELTA_TIMEVAL( delta_time, timestamp, start_time, DT_PREC_2 ); diff --git a/src/zm_event.h b/src/zm_event.h old mode 100644 new mode 100755 index 6b8e47ac5..1b2600744 --- a/src/zm_event.h +++ b/src/zm_event.h @@ -132,7 +132,7 @@ public: void AddFrames( int n_frames, Image **images, struct timeval **timestamps ); void AddFrame( Image *image, struct timeval timestamp, int score=0, Image *alarm_frame=NULL ); - void AddVideoFrame( struct timeval timestamp, int score=0 ); + void AddVideoFrame( Image *image, struct timeval timestamp, int score=0 ); public: static const char *getSubPath( struct tm *time ) diff --git a/src/zm_monitor.cpp b/src/zm_monitor.cpp old mode 100644 new mode 100755 index 6d6391515..1de9a50f8 --- a/src/zm_monitor.cpp +++ b/src/zm_monitor.cpp @@ -1404,10 +1404,8 @@ bool Monitor::Analyse() event = new Event( this, *timestamp, "Continuous", noteSetMap ); shared_data->last_event = event->Id(); + //set up video store data snprintf(video_store_data->event_directory, sizeof(video_store_data->event_directory), "%s", event->getEventDirectory()); - //Error("1store event directory: %s", event->getEventDirectory()); - //Error("2store event directory: %s", video_store_data->event_directory); - video_store_data->recording = true; @@ -1419,31 +1417,6 @@ bool Monitor::Analyse() shared_data->state = state = TAPE; } - - //if ( config.overlap_timed_events ) - //TODO: Remove this as the if false was here before I was playing around with it - not sure what it's meant to do. chriswiggins - /*if ( false ) - { - int pre_index = ((index+image_buffer_count)-pre_event_count)%image_buffer_count; - int pre_event_images = pre_event_count; - while ( pre_event_images && !image_buffer[pre_index].timestamp->tv_sec ) - { - pre_index = (pre_index+1)%image_buffer_count; - pre_event_images--; - } - - if ( pre_event_images ) - { - for ( int i = 0; i < pre_event_images; i++ ) - { - timestamps[i] = image_buffer[pre_index].timestamp; - images[i] = image_buffer[pre_index].image; - - pre_index = (pre_index+1)%image_buffer_count; - } - event->AddFrames( pre_event_images, images, timestamps ); - } - }*/ } } if ( score ) @@ -1611,11 +1584,10 @@ bool Monitor::Analyse() { //Video Storage patch , Activate only for ffmpeg cameras if(config.use_mkv_storage && camera->IsFfmpeg()){ - //Info("ZMA: Setting to 10"); video_store_data->recording = true; - //if(video_store_data->frameNumber > lastVideoEventFrame){ - event->AddVideoFrame(*timestamp); - //} + //Need to pass in the image object so that a snapshot image may be saved if it is required + event->AddVideoFrame(snap_image, *timestamp); + }else{ if ( !(image_count%(frame_skip+1)) ) {