When the embedded recorder writes segments (live_mode on, live_record on),
the alarm clips now come from those segments and the old encoder is not
started, so the video is no longer encoded and written twice.
- Recorder: ServerConf::onSegmentDone is called for every closed segment
(file, local start time, duration, size).
- kernelModuleEmbedVideo keeps the closed segments of each path for
3 minutes. An alarm (saveStreamPicture -> clipAlarm) hands over the
segments within 5 s before / 5 s after it to the kernel like the old
encoder's clips (hard link <scratch>/<md5>.mp4 + EVT_CAPTURE_DONE). The
event is bound to the segment it happened in, with its frame offset.
Old and left-over segments are deleted (sweepClips); the MediaMTX
helper no longer indexes or deletes them.
- With live_record off the old encoder makes the clips as before.
- streamHandler: no encoder thread in decode-only mode (it left an empty
segment file in the scratch folder per stream).
- VIDEO_SEGMENT_INFO of EVT_CAPTURE_DONE is a heap copy owned by the
receiver (mojoKernel deletes it). The old encoder memcpy'd a struct
with std::vector members (shared buffers) and leaked the copy.
- streamHandler: m_mEncodedProtector was unlocked every frame without
being locked when EVE_WORK_WITH_MEDIAMTX is defined.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0139veDo3XyavMuVhdnHcN16