Convert from event_directory to event file as per Video branch
This commit is contained in:
parent
25bfedc9d6
commit
ba425edd0f
|
@ -167,7 +167,8 @@ Event::Event( Monitor *p_monitor, struct timeval p_start_time, const std::string
|
||||||
video_name[0] = 0;
|
video_name[0] = 0;
|
||||||
|
|
||||||
/* Save as video */
|
/* Save as video */
|
||||||
if ( monitor->GetOptVideoWriter() == 1 ) {
|
|
||||||
|
if ( monitor->GetOptVideoWriter() != 0 ) {
|
||||||
int nRet;
|
int nRet;
|
||||||
snprintf( video_name, sizeof(video_name), "%d-%s", id, "video.mp4" );
|
snprintf( video_name, sizeof(video_name), "%d-%s", id, "video.mp4" );
|
||||||
snprintf( video_file, sizeof(video_file), video_file_format, path, video_name );
|
snprintf( video_file, sizeof(video_file), video_file_format, path, video_name );
|
||||||
|
|
|
@ -159,8 +159,8 @@ public:
|
||||||
return( Event::getSubPath( localtime( time ) ) );
|
return( Event::getSubPath( localtime( time ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
char* getEventDirectory(void){
|
char* getEventFile(void){
|
||||||
return path;
|
return video_file;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -470,7 +470,7 @@ void *FfmpegCamera::ReopenFfmpegThreadCallback(void *ctx){
|
||||||
}
|
}
|
||||||
|
|
||||||
//Function to handle capture and store
|
//Function to handle capture and store
|
||||||
int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_directory )
|
int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_file )
|
||||||
{
|
{
|
||||||
AVPacket packet;
|
AVPacket packet;
|
||||||
uint8_t* directbuffer;
|
uint8_t* directbuffer;
|
||||||
|
@ -514,29 +514,27 @@ int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_di
|
||||||
//Video recording
|
//Video recording
|
||||||
if(recording && !wasRecording){
|
if(recording && !wasRecording){
|
||||||
//Instantiate the video storage module
|
//Instantiate the video storage module
|
||||||
char fileName[4096];
|
|
||||||
snprintf(fileName, sizeof(fileName), "%s/event.mp4", event_directory);
|
videoStore = new VideoStore((const char *)event_file, "mp4", mFormatContext->streams[mVideoStreamId],mAudioStreamId==-1?NULL:mFormatContext->streams[mAudioStreamId],startTime);
|
||||||
videoStore = new VideoStore((const char *)fileName, "mp4", mFormatContext->streams[mVideoStreamId],mAudioStreamId==-1?NULL:mFormatContext->streams[mAudioStreamId],startTime);
|
|
||||||
wasRecording = true;
|
wasRecording = true;
|
||||||
strcpy(oldDirectory, event_directory);
|
strcpy(oldDirectory, event_file);
|
||||||
|
|
||||||
}else if(!recording && wasRecording && videoStore){
|
}else if(!recording && wasRecording && videoStore){
|
||||||
Warning("Deleting videoStore instance");
|
Info("Deleting videoStore instance");
|
||||||
delete videoStore;
|
delete videoStore;
|
||||||
videoStore = NULL;
|
videoStore = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
//The directory we are recording to is no longer tied to the current event. Need to re-init the videostore with the correct directory and start recording again
|
//The directory we are recording to is no longer tied to the current event. Need to re-init the videostore with the correct directory and start recording again
|
||||||
if(recording && wasRecording && (strcmp(oldDirectory, event_directory)!=0) && (packet.flags & AV_PKT_FLAG_KEY) ){ //don't open new videostore until we're on a key frame..would this require an offset adjustment for the event as a result?...if we store our key frame location with the event will that be enough?
|
if(recording && wasRecording && (strcmp(oldDirectory, event_file)!=0) && (packet.flags & AV_PKT_FLAG_KEY) ){ //don't open new videostore until we're on a key frame..would this require an offset adjustment for the event as a result?...if we store our key frame location with the event will that be enough?
|
||||||
Info("Re-starting video storage module");
|
Info("Re-starting video storage module");
|
||||||
if(videoStore){
|
if(videoStore){
|
||||||
delete videoStore;
|
delete videoStore;
|
||||||
videoStore = NULL;
|
videoStore = NULL;
|
||||||
}
|
}
|
||||||
char fileName[4096];
|
|
||||||
snprintf(fileName, sizeof(fileName), "%s/event.mp4", event_directory);
|
videoStore = new VideoStore((const char *)event_file, "mp4", mFormatContext->streams[mVideoStreamId],mAudioStreamId==-1?NULL:mFormatContext->streams[mAudioStreamId],startTime);
|
||||||
videoStore = new VideoStore((const char *)fileName, "mp4", mFormatContext->streams[mVideoStreamId],mAudioStreamId==-1?NULL:mFormatContext->streams[mAudioStreamId],startTime);
|
strcpy(oldDirectory, event_file);
|
||||||
strcpy(oldDirectory, event_directory);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if(videoStore && recording){
|
if(videoStore && recording){
|
||||||
|
|
|
@ -417,7 +417,7 @@ Monitor::Monitor(
|
||||||
trigger_data->trigger_showtext[0] = 0;
|
trigger_data->trigger_showtext[0] = 0;
|
||||||
shared_data->valid = true;
|
shared_data->valid = true;
|
||||||
video_store_data->recording = false;
|
video_store_data->recording = false;
|
||||||
snprintf(video_store_data->event_directory, sizeof(video_store_data->event_directory), "nothing");
|
snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "nothing");
|
||||||
video_store_data->size = sizeof(VideoStoreData);
|
video_store_data->size = sizeof(VideoStoreData);
|
||||||
//video_store_data->frameNumber = 0;
|
//video_store_data->frameNumber = 0;
|
||||||
} else if ( purpose == ANALYSIS ) {
|
} else if ( purpose == ANALYSIS ) {
|
||||||
|
@ -1397,7 +1397,7 @@ bool Monitor::Analyse()
|
||||||
if ( event )
|
if ( event )
|
||||||
{
|
{
|
||||||
//TODO: We shouldn't have to do this every time. Not sure why it clears itself if this isn't here??
|
//TODO: We shouldn't have to do this every time. Not sure why it clears itself if this isn't here??
|
||||||
snprintf(video_store_data->event_directory, sizeof(video_store_data->event_directory), "%s", event->getEventDirectory());
|
snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "%s", event->getEventFile());
|
||||||
|
|
||||||
int section_mod = timestamp->tv_sec%section_length;
|
int section_mod = timestamp->tv_sec%section_length;
|
||||||
if ( section_mod < last_section_mod )
|
if ( section_mod < last_section_mod )
|
||||||
|
@ -1427,7 +1427,7 @@ bool Monitor::Analyse()
|
||||||
event = new Event( this, *timestamp, "Continuous", noteSetMap, videoRecording );
|
event = new Event( this, *timestamp, "Continuous", noteSetMap, videoRecording );
|
||||||
shared_data->last_event = event->Id();
|
shared_data->last_event = event->Id();
|
||||||
//set up video store data
|
//set up video store data
|
||||||
snprintf(video_store_data->event_directory, sizeof(video_store_data->event_directory), "%s", event->getEventDirectory());
|
snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "%s", event->getEventFile());
|
||||||
video_store_data->recording = true;
|
video_store_data->recording = true;
|
||||||
|
|
||||||
Info( "%s: %03d - Opening new event %d, section start", name, image_count, event->Id() );
|
Info( "%s: %03d - Opening new event %d, section start", name, image_count, event->Id() );
|
||||||
|
@ -1489,7 +1489,7 @@ bool Monitor::Analyse()
|
||||||
event = new Event( this, *(image_buffer[pre_index].timestamp), cause, noteSetMap, videoRecording );
|
event = new Event( this, *(image_buffer[pre_index].timestamp), cause, noteSetMap, videoRecording );
|
||||||
shared_data->last_event = event->Id();
|
shared_data->last_event = event->Id();
|
||||||
//set up video store data
|
//set up video store data
|
||||||
snprintf(video_store_data->event_directory, sizeof(video_store_data->event_directory), "%s", event->getEventDirectory());
|
snprintf(video_store_data->event_file, sizeof(video_store_data->event_file), "%s", event->getEventFile());
|
||||||
video_store_data->recording = true;
|
video_store_data->recording = true;
|
||||||
|
|
||||||
Info( "%s: %03d - Opening new event %d, alarm start", name, image_count, event->Id() );
|
Info( "%s: %03d - Opening new event %d, alarm start", name, image_count, event->Id() );
|
||||||
|
@ -2878,12 +2878,11 @@ int Monitor::Capture()
|
||||||
|
|
||||||
//Check if FFMPEG camera
|
//Check if FFMPEG camera
|
||||||
if((GetOptVideoWriter() == 2) && camera->SupportsNativeVideo()){
|
if((GetOptVideoWriter() == 2) && camera->SupportsNativeVideo()){
|
||||||
captureResult = camera->CaptureAndRecord(*(next_buffer.image), video_store_data->recording, video_store_data->event_directory);
|
captureResult = camera->CaptureAndRecord(*(next_buffer.image), video_store_data->recording, video_store_data->event_file);
|
||||||
}else{
|
}else{
|
||||||
captureResult = camera->Capture(*(next_buffer.image));
|
captureResult = camera->Capture(*(next_buffer.image));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if ( FirstCapture ) {
|
if ( FirstCapture ) {
|
||||||
FirstCapture = 0;
|
FirstCapture = 0;
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -2893,7 +2892,7 @@ int Monitor::Capture()
|
||||||
//Check if FFMPEG camera
|
//Check if FFMPEG camera
|
||||||
if((GetOptVideoWriter() == 2) && camera->SupportsNativeVideo()){
|
if((GetOptVideoWriter() == 2) && camera->SupportsNativeVideo()){
|
||||||
//Warning("ZMC: Recording: %d", video_store_data->recording);
|
//Warning("ZMC: Recording: %d", video_store_data->recording);
|
||||||
captureResult = camera->CaptureAndRecord(*capture_image, video_store_data->recording, video_store_data->event_directory);
|
captureResult = camera->CaptureAndRecord(*capture_image, video_store_data->recording, video_store_data->event_file);
|
||||||
}else{
|
}else{
|
||||||
/* Capture directly into image buffer, avoiding the need to memcpy() */
|
/* Capture directly into image buffer, avoiding the need to memcpy() */
|
||||||
captureResult = camera->Capture(*capture_image);
|
captureResult = camera->Capture(*capture_image);
|
||||||
|
|
|
@ -159,7 +159,7 @@ protected:
|
||||||
typedef struct
|
typedef struct
|
||||||
{
|
{
|
||||||
uint32_t size;
|
uint32_t size;
|
||||||
char event_directory[4096];
|
char event_file[4096];
|
||||||
uint32_t recording; //bool arch dependent so use uint32 instead
|
uint32_t recording; //bool arch dependent so use uint32 instead
|
||||||
//uint32_t frameNumber;
|
//uint32_t frameNumber;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue