mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-03-21 23:32:56 -04:00
Save a snapshot image alongside the h264 video for thumbnail and poster use
This commit is contained in:
10
src/zm_event.cpp
Normal file → Executable file
10
src/zm_event.cpp
Normal file → Executable 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
2
src/zm_event.h
Normal file → Executable 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
36
src/zm_monitor.cpp
Normal file → Executable 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)) )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user