Skip to content

Ignore motion while the camera is moved over PTZ - #8

Open
hyngsk wants to merge 1 commit into
codextde:mainfrom
hyngsk:feat/mute-motion-during-ptz
Open

hyngsk wants to merge 1 commit into
codextde:mainfrom
hyngsk:feat/mute-motion-during-ptz

Conversation

@hyngsk

@hyngsk hyngsk commented Nov 24, 2026

Copy link
Copy Markdown

Problem

Moving a PTZ camera changes the whole picture. Every pan or tilt from the app or the web UI therefore raised a motion event, sent a push notification, and in motion recording mode kept the segment. Checking the event snapshots on my camera, the latest events were all the camera turning, not anything happening in the room.

Change

  • The PTZ endpoint calls motion.ptzActivity(cameraId, action) for move, stop and preset before it sends the ONVIF command, so the first frames of the move are already covered.
  • PtzQuiet (in motion.ts) decides how long each camera stays quiet:
    • move: quiet until the matching stop, capped at 60 s in case the stop never arrives (app killed, network drop).
    • stop: 5 s more, so the last step and the video delay can pass.
    • preset: 15 s, because there is no stop for a preset. A later stop does not cut it short.
  • While a camera is quiet, scene scores are dropped before they reach the tracker. ffmpeg keeps running and scoring, so nothing restarts. An event that was already running ends on its usual quiet timeout.
  • Three unit tests for PtzQuiet in test/motion.test.ts.

The timings are constants for now. I am happy to move them into settings if you prefer.

Testing

  • bun test passes 76 of 76, and tsc --noEmit is clean.
  • On a real pan/tilt camera I panned right for 2 s, stopped, then panned left for 2 s and stopped, watching for 10 s after each. No new motion events were raised. Before this change, the same moves produced events. Scene scores keep flowing while the camera is idle.

Turning a PTZ camera changes the whole picture, so every pan or tilt from
the app raised a motion event and a push notification, and in motion
recording mode kept the segment.

The PTZ endpoint now tells the motion detector about each command before
sending it. PtzQuiet keeps the camera quiet:
- move: until the matching stop, capped at 60 s in case the stop is lost
- stop: 5 s more, for the last step and the video delay
- preset: 15 s, since a preset has no stop

Scene scores that arrive while quiet are dropped before they reach the
tracker; an event that was already running ends on its usual quiet
timeout.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant