Don't both updating analysis fps unless we are doing motion detection

This commit is contained in:
Isaac Connor 2021-03-02 09:59:32 -05:00
parent 9beaf613bf
commit 832eabbd79
1 changed files with 20 additions and 17 deletions

View File

@ -2267,7 +2267,8 @@ bool Monitor::Analyse() {
// Only do these if it's a video packet. // Only do these if it's a video packet.
shared_data->last_read_index = snap->image_index; shared_data->last_read_index = snap->image_index;
analysis_image_count++; analysis_image_count++;
UpdateAnalysisFPS(); if ( function == MODECT or function == MOCORD )
UpdateAnalysisFPS();
} }
shared_data->last_read_time = time(nullptr); shared_data->last_read_time = time(nullptr);
packetqueue.clearPackets(snap); packetqueue.clearPackets(snap);
@ -2543,23 +2544,25 @@ int Monitor::Capture() {
Debug(2, "Have packet stream_index:%d ?= videostream_id:(%d) q.vpktcount(%d) event?(%d) ", Debug(2, "Have packet stream_index:%d ?= videostream_id:(%d) q.vpktcount(%d) event?(%d) ",
packet->packet.stream_index, video_stream_id, packetqueue.packet_count(video_stream_id), ( event ? 1 : 0 ) ); packet->packet.stream_index, video_stream_id, packetqueue.packet_count(video_stream_id), ( event ? 1 : 0 ) );
if (packet->packet.stream_index == video_stream_id) { if (packet->packet.stream_index == video_stream_id) {
if (video_fifo) { if (video_fifo) {
if ( packet->keyframe ) { if ( packet->keyframe ) {
// avcodec strips out important nals that describe the stream and // avcodec strips out important nals that describe the stream and
// stick them in extradata. Need to send them along with keyframes // stick them in extradata. Need to send them along with keyframes
AVStream *stream = camera->get_VideoStream(); AVStream *stream = camera->get_VideoStream();
video_fifo->write( #if LIBAVCODEC_VERSION_CHECK(57, 64, 0, 64, 0)
static_cast<unsigned char *>(stream->codecpar->extradata), video_fifo->write(
stream->codecpar->extradata_size, static_cast<unsigned char *>(stream->codecpar->extradata),
packet->pts); stream->codecpar->extradata_size,
packet->pts);
#endif
}
video_fifo->writePacket(*packet);
}
} else if (packet->packet.stream_index == audio_stream_id) {
if (audio_fifo)
audio_fifo->writePacket(*packet);
} }
video_fifo->writePacket(*packet);
}
} else if (packet->packet.stream_index == audio_stream_id) {
if (audio_fifo)
audio_fifo->writePacket(*packet);
}
if ( (packet->packet.stream_index != video_stream_id) and ! packet->image ) { if ( (packet->packet.stream_index != video_stream_id) and ! packet->image ) {
// Only queue if we have some video packets in there. Should push this logic into packetqueue // Only queue if we have some video packets in there. Should push this logic into packetqueue