Save a snapshot image alongside the h264 video for thumbnail and poster use

This commit is contained in:
Chris Wiggins
2013-09-28 18:50:54 +12:00
parent a1a407d543
commit 65afc830b1
3 changed files with 13 additions and 35 deletions

10
src/zm_event.cpp Normal file → Executable file
View File

@@ -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 );

2
src/zm_event.h Normal file → Executable file
View File

@@ -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 )

36
src/zm_monitor.cpp Normal file → Executable file
View File

@@ -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)) )
{