Skip to content

Commit

Permalink
If using WallClockTimestamps, don't sweat a big jump in time.
Browse files Browse the repository at this point in the history
  • Loading branch information
Isaac Connor committed Oct 22, 2024
1 parent 0287157 commit e600472
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions src/zm_ffmpeg_camera.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,11 +260,13 @@ int FfmpegCamera::Capture(std::shared_ptr<ZMPacket> &zm_packet) {
Info("Suspected 32bit wraparound in input pts. %" PRId64, packet->pts);
return -1;
} 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 > 10seconds",
pts_time, last_pts_time, pts_time - last_pts_time);
if (!monitor->WallClockTimestamps()) {
// -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 > 10seconds",
pts_time, last_pts_time, pts_time - last_pts_time);
}
if (error_count > 5)
return -1;
error_count += 1;
Expand Down

0 comments on commit e600472

Please sign in to comment.