Skip to content

Add disk management, SD card replay/download, and alarm search#396

Open
lorek123 wants to merge 7 commits intoQuantumEntangledAndy:masterfrom
lorek123:feature/disk-subcommand
Open

Add disk management, SD card replay/download, and alarm search#396
lorek123 wants to merge 7 commits intoQuantumEntangledAndy:masterfrom
lorek123:feature/disk-subcommand

Conversation

@lorek123
Copy link

Summary

  • Disk management (MSG 102/103): neolink disk <camera> list and disk format to inspect and format SD cards
  • SD card replay & download (MSG 5/7/8/13-16/123/143): Full playback pipeline — file listing, download to MP4 with VFR-correct muxing, audio, and AI detection metadata
  • Alarm video search (MSG 175): Server-side filtering by alarm/AI type with replay alarm-search
  • E1 camera fixes: Protocol v2 header handling, partial-region AES decryption, graceful error handling for unsupported features

New subcommands

# Disk
neolink disk <camera> list
neolink disk <camera> format --disk 0

# Replay: list days / files
neolink replay <camera> days --start 2026-02-01 --end 2026-02-13
neolink replay <camera> files --date 2026-02-13

# Replay: download by filename (works on E1)
neolink replay <camera> download --name <file> --output out.mp4

# Replay: download by time range (NVR models; E1 returns 400)
neolink replay <camera> download-by-time --start 2026-02-13 --output out.mp4

# Alarm/AI search
neolink replay <camera> alarm-search --start 2026-02-13

Details

  • File listing: MSG 14/15 with pagination, AI tag display (people, vehicle, dog_cat, etc.), --ai-filter for client-side filtering
  • MP4 muxing: GStreamer pipeline with per-frame PTS from BcMedia timestamps, H.264/H.265 codec detection, AAC audio, metadata tags (camera name, date, AI detections)
  • E1 decryption: Partial-region AES decrypt using encryptPos/encryptLen from Extension XML; protocol v2 payload_offset for continuation packets (class 0x698d)
  • Record type fix: Separate FILE_SEARCH_RECORD_TYPES (manual,sched,md,pir,io) for MSG 14 — E1 cameras reject AI-specific tags in file search requests
  • Error handling: MSG 14 error 400 → "No files for this day"; MSG 175 error 405 → "not supported"; MSG 143 error 400 → suggests replay download instead
  • Wireshark dissector: Updated baichuan.lua with replay message ID decoding

Tested on

  • Reolink E1 (firmware v3.1.0.4450_2509011489)
    • disk list, days, files, download (MP4 with H.264 + AAC) all working
    • alarm-search gracefully reports "not supported"
    • download-by-time gracefully reports "not supported" (MSG 143 not implemented on E1)

Test plan

  • neolink disk <camera> list shows SD card info
  • neolink replay <camera> days --start <date> lists recording days
  • neolink replay <camera> files --date <date> lists files with AI tags and correct sizes
  • neolink replay <camera> download --name <file> --output test.mp4 produces playable MP4
  • Date with no recordings shows "No files for this day." instead of error
  • replay alarm-search returns results or "not supported" message
  • replay download-by-time returns clear error on cameras that don't support MSG 143

lorek123 and others added 7 commits February 5, 2026 00:32
- Add MSG_ID_HDD_INFO_LIST (102) and MSG_ID_HDD_INIT_LIST (103) in bc/model
- Add HddInfoList, HddInfo, FormatExpandCfg, HddInitList, HddInit XML types
- Add bc_protocol/disk.rs: get_hdd_list(), format_disk(init_ids, full_format)
- Add disk subcommand: 'neolink disk [list]' and 'neolink disk format --disk N [--full]'
- Default subcommand is list when omitted
- Fix UnintelligibleReply/UnintelligibleXml display and unused_assignments warnings
- Fix BcSubscription and MqttReplyRef lifetime elision warnings
Implement SD card replay and download for E1/E320 cameras:
- New `replay` subcommand with search, list, download, and play modes
- BC protocol replay flow (MSG 5/7/8/13-16/123) with BcMedia stream parsing
- GStreamer-based MP4 muxing with per-frame PTS for variable frame rate
- Fix E1 decryption: always read payload_offset for v2 protocol packets
- Fix over-decryption: only decrypt [encryptPos, encryptPos+encryptLen)
- Enhanced Wireshark dissector with replay message types and encryption fields
- BcMedia format documentation (BCMEDIA_REPLAY_FORMAT.md)

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
The camera's recordType field carries AI detection labels (people,
vehicle, face, dog_cat, package, visitor, etc.) alongside trigger
types (md, sched, manual, pir). These are now embedded as MP4 tags:
- GStreamer: Keywords (AI tags), Comment (full recordType), Description
  (start/end time), Title (camera name), Encoder (neolink replay)
- ffmpeg fallback: -metadata comment and description flags
- File listing: AI detections highlighted with [AI: ...] suffix

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Tag events sent via appsrc.send_event() don't reliably propagate to
the muxer. Use mp4mux's TagSetter interface (set before Playing state)
to write tags directly into the MP4 udta/meta atoms.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Recordings triggered only by AI detection (without md/sched) were missed
because the default record_type was "manual,sched,md". Now defaults to all
known types. Adds --ai-filter to `replay files` for client-side filtering
by AI detection tag (e.g. --ai-filter people,vehicle,dog_cat).

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Implements the findAlarmVideo protocol (MSG 175 / 0xAF) which allows
searching recordings by alarm/detection type on the camera itself.
Adds FindAlarmVideo and EventAlarmType XML types, alarm_video_search_start
and alarm_video_search_next protocol methods, and the `alarm-search`
CLI subcommand with --alarm-types filtering.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Fix MSG 14 regression: separate FILE_SEARCH_RECORD_TYPES (manual,
  sched,md,pir,io) from ALL_RECORD_TYPES. E1 cameras reject unknown
  AI-specific tags in file search with error 400.
- Handle MSG 14 error 400 gracefully as "no files for this day"
- Handle MSG 175 error 405 gracefully as "not supported"
- Downgrade per-packet replay logs from info to debug
- Remove E1 strip diagnostic logging from replay stream
- Reduce binary progress logging from every 20 to every 200 packets
- Fix file size display: show KB for files under 1MB
- Remove debug eprintln! from main.rs replay dispatch

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
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