diff --git a/src/zm_ffmpeg_camera.cpp b/src/zm_ffmpeg_camera.cpp index 062868e92..f294367cc 100644 --- a/src/zm_ffmpeg_camera.cpp +++ b/src/zm_ffmpeg_camera.cpp @@ -869,6 +869,10 @@ int FfmpegCamera::CaptureAndRecord( Image &image, timeval recording, char* event if ( packet.stream_index == mVideoStreamId ) { if ( keyframe ) { Debug(3, "Clearing queue"); + if ( packetqueue->packet_count(mVideoStreamId) >= monitor->GetImageBufferCount() ) { + Warning("ImageBufferCount is too small. Either increase it or decrease time between keyframes"); + } + packetqueue->clearQueue(monitor->GetPreEventCount(), mVideoStreamId); packetqueue->queuePacket(&packet); } else if ( packetqueue->size() ) { diff --git a/src/zm_monitor.h b/src/zm_monitor.h index b98f5953f..2f3b43637 100644 --- a/src/zm_monitor.h +++ b/src/zm_monitor.h @@ -456,6 +456,7 @@ public: void SetVideoWriterEventId( unsigned long long p_event_id ) { video_store_data->current_event = p_event_id; } unsigned int GetPreEventCount() const { return pre_event_count; }; + int GetImageBufferCount() const { return image_buffer_count; }; State GetState() const; int GetImage( int index=-1, int scale=100 ); Snapshot *getSnapshot() const; diff --git a/src/zm_packetqueue.cpp b/src/zm_packetqueue.cpp index 3fc4d72e9..8a14c3a5e 100644 --- a/src/zm_packetqueue.cpp +++ b/src/zm_packetqueue.cpp @@ -25,7 +25,7 @@ zm_packetqueue::zm_packetqueue( int p_max_stream_id ) { max_stream_id = p_max_stream_id; packet_counts = new int[max_stream_id+1]; for ( int i=0; i <= max_stream_id; ++i ) - packet_counts = 0; + packet_counts[i] = 0; } zm_packetqueue::~zm_packetqueue() {