From 6a7b38dac666ee9a1e5ae21494a51361f5f00a32 Mon Sep 17 00:00:00 2001 From: Chris Wiggins Date: Thu, 19 Sep 2013 21:55:56 +1200 Subject: [PATCH] update changes --- src/zm_ffmpeg_camera.cpp | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index f9222c658..0911c32c1 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -267,7 +267,28 @@ int FfmpegCamera::CaptureAndRecord( Image &image, bool recording, char* event_di uint8_t* directbuffer; //Warning("Recording: %d", (int)recording); - + + if(recording && !wasRecording){ + //Instanciate the video storage module + char fileName[4096]; + snprintf(fileName, sizeof(fileName), "%s/event.mkv", event_directory); + videoStore = new VideoStore((const char *)fileName, "matroska", mFormatContext->streams[mVideoStreamId]); + wasRecording = true; + strcpy(oldDirectory, event_directory); + + }else if(!recording && wasRecording){ + Warning("Deleting videoStore instance"); + delete videoStore; + } + + //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) ){ + delete videoStore; + char fileName[4096]; + snprintf(fileName, sizeof(fileName), "%s/event.mkv", event_directory); + videoStore = new VideoStore((const char *)fileName, "matroska", mFormatContext->streams[mVideoStreamId]); + strcpy(oldDirectory, event_directory); + } /* Request a writeable buffer of the target image */ directbuffer = image.WriteBuffer(width, height, colours, subpixelorder);