Roadmap M2: Dahua adapter #5
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Cang needs to understand the folder structure written by Dahua NVRs so it can locate video clips and their associated snapshot images.
Dahua NVRs organise recordings under a root directory with the camera serial as the top-level folder, then date, channel, and hour sub-directories. Video clips are
.davfiles; each clip has a matching set of per-second JPEG snapshots stored in a paralleljpg/tree. Clips that recorded a motion event carry an[M]flag in the filename; the first frame of a recording sequence carries[F].This milestone delivers the adapter layer that turns that raw folder tree into structured
IncomingClipobjects that the rest of the pipeline can consume, without needing to know any Dahua-specific details.Findings
Explored the real NVR folder tree from
dahua-folders-files.txt:<serial>/<YYYY-MM-DD>/<channel>/dav/<HH>/<stem>.dav<serial>/<YYYY-MM-DD>/<channel>/jpg/<HH>/<MM>/<SS>[flags].jpgHH.MM.SS-HH.MM.SS[flags][0@0][0][M]= motion event,[F]= first frame of recording sequence[0@0][0]suffix is always present but carries no useful information.idxsidecar files exist for every.dav— skip/ignore themclip.start <= snapshot_time <= clip.end), not by filename stemPlan of attack
src/cang/adapters/base.py—IncomingClipdataclass (path, serial, date, channel, start, end, motion, first_frame, snapshots) +BaseAdapterABC withscan(root) -> Iterator[IncomingClip]tests/adapters/test_dahua.py— failing tests first (TDD):_parse_clip_stem,_parse_snapshot_path, boundary inclusion/exclusiontmp_pathtree, assert 2 clips yielded with correct snapshot listssrc/cang/adapters/dahua.py—DahuaAdapter.scan()walks the tree, parses filenames with regex, matches snapshots per the timestamp range logic; skips.idxfilesBranch:
feat/issue-5-m2-dahua-adapter