If camera time jumps back more than 10 seconds, fail the capture.

This commit is contained in:
Isaac Connor
2024-07-03 08:54:46 -04:00
parent efbe6ab219
commit aa1aee230f

View File

@@ -258,11 +258,11 @@ int FfmpegCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
// 32-bit wrap around?
Info("Suspected 32bit wraparound in input pts. %" PRId64, packet->pts);
return -1;
} else if (packet->pts - lastPTS < -20*stream->time_base.den) {
// -20 is for 20 seconds. Avigilon cameras seem to jump around by about 36 constantly
} else if (packet->pts - lastPTS < -10*stream->time_base.den) {
// -10 is for 10 seconds. Avigilon cameras seem to jump around by about 36 constantly
double pts_time = static_cast<double>(av_rescale_q(packet->pts, stream->time_base, AV_TIME_BASE_Q)) / AV_TIME_BASE;
double last_pts_time = static_cast<double>(av_rescale_q(lastPTS, stream->time_base, AV_TIME_BASE_Q)) / AV_TIME_BASE;
logPrintf(Logger::WARNING + monitor->Importance(), "Stream pts jumped back in time too far. pts %.2f - last pts %.2f = %.2f > 40seconds",
logPrintf(Logger::WARNING + monitor->Importance(), "Stream pts jumped back in time too far. pts %.2f - last pts %.2f = %.2f > 10seconds",
pts_time, last_pts_time, pts_time - last_pts_time);
if (error_count > 5)
return -1;