mirror of
https://github.com/ZoneMinder/zoneminder.git
synced 2026-11-30 12:14:36 -05:00
fix: report a passthrough keyframe interval longer than MaxImageBufferCount
Passthrough recording keeps every packet back to a video keyframe. When the camera's keyframe interval is longer than MaxImageBufferCount, queuePacket() has no later keyframe to trim to, so the packet queue holds the whole GOP whatever MaxImageBufferCount says. #5359 bounds the decoded copies in that case, which keeps memory down, but the queue still isn't working as configured and nothing said so specifically: the existing "queue is full" Warning also covers analysis falling behind. Log an Error naming MaxImageBufferCount and the fix (raise it above the keyframe interval, or shorten the camera's GOP) as soon as a GOP passes the limit with keep_keyframes on. Report it once; setMaxVideoPackets(), setKeepKeyframes() (a RELOAD) and clear() reset it. setKeepKeyframes() now takes the queue mutex, like the other setters. refs #5358 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
077ffce1a1
commit
3206bfd3a8
3 files changed
+76
-2
No files matched your search
+22
-1
@@ -45,7 +45,8 @@ PacketQueue::PacketQueue():
|
||||
next_queue_index_(0),
|
||||
first_queue_index_(0),
|
||||
released_before_(0),
|
||||
capped_before_(0)
|
||||
capped_before_(0),
|
||||
keyframe_interval_over_limit_(false)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -126,6 +127,18 @@ bool PacketQueue::queuePacket(std::shared_ptr<ZMPacket> add_packet) {
|
||||
max_keyframe_interval_ = frames_since_last_keyframe_;
|
||||
Debug(1, "Have new keyframe interval %d", max_keyframe_interval_.load());
|
||||
}
|
||||
// Passthrough keeps every packet back to a keyframe, so a GOP longer
|
||||
// than MaxImageBufferCount can't be trimmed: the queue holds all of it,
|
||||
// and releaseDecoded() can only bound the decoded copies.
|
||||
if (keep_keyframes and (max_video_packet_count > 0) and !keyframe_interval_over_limit_
|
||||
and (frames_since_last_keyframe_ + 1 > max_video_packet_count)) {
|
||||
keyframe_interval_over_limit_ = true;
|
||||
Error("The camera's keyframe interval is longer than MaxImageBufferCount (%d frames). "
|
||||
"Passthrough recording has to keep a whole keyframe interval of packets, so the packet queue "
|
||||
"can't stay within MaxImageBufferCount. Raise MaxImageBufferCount above the keyframe interval "
|
||||
"or shorten the camera's keyframe interval (GOP).",
|
||||
max_video_packet_count);
|
||||
}
|
||||
} else {
|
||||
frames_since_last_keyframe_ = 0;
|
||||
if (!max_keyframe_interval_) max_keyframe_interval_ = 1;
|
||||
@@ -562,6 +575,7 @@ void PacketQueue::clear() {
|
||||
packet_counts.reset();
|
||||
max_stream_id = -1;
|
||||
max_keyframe_interval_ = 0;
|
||||
keyframe_interval_over_limit_ = false;
|
||||
first_queue_index_ = next_queue_index_;
|
||||
|
||||
Debug(1, "Packetqueue is clear, notifying");
|
||||
@@ -929,6 +943,13 @@ void PacketQueue::setMaxVideoPackets(int p) {
|
||||
Debug(1, "Setting max_video_packet_count to %d", p);
|
||||
if (max_video_packet_count < 0)
|
||||
max_video_packet_count = 0;
|
||||
keyframe_interval_over_limit_ = false;
|
||||
}
|
||||
|
||||
void PacketQueue::setKeepKeyframes(bool k) {
|
||||
std::lock_guard<std::mutex> lck(mutex);
|
||||
keep_keyframes = k;
|
||||
keyframe_interval_over_limit_ = false;
|
||||
}
|
||||
|
||||
void PacketQueue::setPreEventVideoPackets(int p) {
|
||||
|
||||
Reference in new issue
Block a user