SentrySearch
repository·master·Indexed 26 days ago
https://github.com/ssrajadh/sentrysearchA tool for performing semantic search over video footage using natural language queries. SentrySearch indexes video files into a local ChromaDB vector database and allows users to retrieve trimmed clips of specific events. It supports multiple backends including Gemini, Qwen Cloud, and local Qwen3-VL-Embedding models. Key features include anomalous highlight detection, customizable chunking and preprocessing, and support for .mp4 and .mov formats.
What's inside sentrysearch
- SentrySearch is a semantic retrieval tool for video footage. It allows users to find specific events within video files using natural language descriptions or images. Once a match is found, the system automatically crops and saves the relevant video segments. It is part of a workflow that includes SentryMerge for multi-camera tracking and SentryBlur for sensitive area blurring.
How SentrySearch Works
masterSentrySearch operates by splitting video footage into overlapping segments. These segments are vectorized using one of three backends:
- Google Gemini Embedding API
- Alibaba DashScope (qwen-cloud)
- Local Qwen3-VL model
The resulting vectors are stored in a local ChromaDB instance. During a search, your text query (or image) is embedded into the same vector space to find matches. The best matches are then automatically cropped from the original files and saved as independent clips.
Configure SentrySearch requirements and compatibility
masterSupported Video Formats
.mp4.mov- The directory scanner recursively finds these files regardless of folder structure.
System Requirements
- Python: 3.11+
- FFmpeg: Must be on
PATH(on macOS, usebrew install ffmpeg). - Gemini Backend: Requires a Gemini API key.
- Local Backend: Requires a GPU with CUDA or Apple Metal.
Configure API Keys with sentrysearch init
masterUse the
initcommand to configure your environment. This is required if you are using the default Gemini backend. The command will prompt you for your Gemini API Key, write it to a.envfile, and run an embedding test to verify the configuration.When you can skip this:
- If you are using the local backend via
--backend local. - If you have already configured
DASHSCOPE_API_KEYin your.envfile and are using--backend qwen-cloud.
sentrysearch init- If you are using the local backend via
Search video by text
masterSearch your indexed footage using natural language queries. The tool will return matches with similarity scores and automatically save the best matching clip.
Common Options:
--results <N>: Number of results to show.--output-dir <DIR>: Directory to save clips.--no-trim: Skip automatic clip trimming (only shows results).--threshold <float>: Adjust the confidence cutoff (default is 0.41).--save-top <N>: Save the top N clips instead of just the best one.--overlay: Overlay Tesla telemetry data (speed, GPS, time) on the clips.--backend <backend>/--model <model>: Override the inferred backend or model.
$ sentrysearch search "red truck running a stop sign"Overlay Tesla telemetry data
masterWhen searching, you can overlay speed, GPS, and time data onto the resulting clips if they are sourced from Tesla dashcam files.
Requirements:
- Tesla firmware 2025.44.25 or higher.
- Hardware version HW3+.
- SEI metadata (available in driving footage, not parked/Sentry mode).
- For city/road names,
geopymust be installed (uses OpenStreetMap Nominatim API).
Installation:
uv tool install ".[tesla]"sentrysearch search "car cutting me off" --overlaySearch video with text queries
masterSearch your indexed footage using natural language queries. SentrySearch returns ranked matches with similarity scores and timestamps.
Options:
--results <N>: Number of results to return.--output-dir <DIR>: Directory to save clips.--no-trim: Skip automatic trimming of clips.--threshold <float>: Confidence cutoff (default:0.41).--save-top <N>: Save the top N clips instead of just the best match.--dedupe <float>: Cosine similarity ceiling (0–1) to drop near-duplicate chunks. A value of0.9is recommended.--rerank: Use a VLM to re-rank the top candidates before trimming.--backend <backend>/--model <model>: Override the auto-detected backend/model.--overlay: (Tesla only) Burn speed, location, and time onto trimmed clips.
# Save top 5 clips, dropping near-duplicates sentrysearch search "red truck" --save-top 5 --dedupe 0.9 # Re-rank the top 10 embedding matches with a VLM before trimming sentrysearch search "pedestrian crossing behind the car" --rerank --results 10Install and Setup SentrySearch
masterTo use SentrySearch for natural language video search, you need uv and Python 3.11+.
- Clone and install the repository:
git clone https://github.com/ssrajadh/sentrysearch.git cd sentrysearch uv sync- For Tesla telemetry support (enables reverse geocoding for overlays), install the extra dependency:
uv sync --extra tesla- Configure your Gemini API key:
Run the initialization command to prompt for your key, which will be written to a
.envfile and validated:
sentrysearch initAlternatively, you can set the
GEMINI_API_KEYenvironment variable directly.git clone https://github.com/ssrajadh/sentrysearch.git cd sentrysearch uv sync uv sync --extra tesla sentrysearch initConfigure the Local Backend (No API Key)
masterRun indexing and search locally using Qwen3-VL-Embedding models. This is free and private.
Hardware-specific Installation:
- Apple Silicon (24 GB+ RAM):
uv tool install ".[local]"(usesqwen8b) - Apple Silicon (16 GB RAM):
uv tool install ".[local]"(usesqwen2b) - Apple Silicon (8 GB RAM):
uv tool install ".[local]"(usesqwen2b) - NVIDIA (18 GB+ VRAM):
uv tool install ".[local]"(usesqwen8b) - NVIDIA (8–16 GB VRAM):
uv tool install ".[local-quantized]"(uses 4-bitqwen8b)
Important Notes:
- Requires Python 3.11 or 3.12. For Python 3.13+, use:
uv python install 3.12 && uv tool install --python 3.12 ".[local]". - Mac users must install FFmpeg:
brew install ffmpeg. - The
--modelflag can be used to override the auto-detected model (e.g.,--model qwen2b). - Embeddings from different backends are not compatible.
# Example for NVIDIA with limited VRAM uv tool install ".[local-quantized]" sentrysearch index /path/to/footage --backend local sentrysearch search "car running a red light"- Apple Silicon (24 GB+ RAM):
Use Local Backend (No API Key)
masterThe local backend uses Qwen3-VL-Embedding to run indexing and searching entirely on your hardware. It is free and private.
Hardware Selection & Installation:
Hardware Install Command Auto-detected Model Notes Apple Silicon (RAM $\ge$ 24GB) uv tool install ".[local]"qwen8b MPS float16 Apple Silicon (16GB RAM) uv tool install ".[local]"qwen2b 8B won't fit; 2B is ~6GB Apple Silicon (8GB RAM) uv tool install ".[local]"qwen2b High load may cause swapping NVIDIA (VRAM $\ge$ 18GB) uv tool install ".[local]"qwen8b bf16 (Linux/Win uses CUDA) NVIDIA (VRAM 8–16GB) uv tool install ".[local-quantized]"qwen8b 4-bit quantization (~6–8GB) Important Notes:
- Python Version: Requires Python 3.11 or 3.12. If using 3.13+, use:
uv python install 3.12 && uv tool install --python 3.12 ".[local]". - Mac Requirement: Must install FFmpeg via
brew install ffmpeg. - Model Overrides: Use
--model qwen2bor--model qwen8bto manually select a model. Using--modelimplies--backend local. - Compatibility: Different backends/models use incompatible vector spaces. You must re-index if you switch models.
sentrysearch index /path/to/footage --backend local sentrysearch search "car running a red light"- Python Version: Requires Python 3.11 or 3.12. If using 3.13+, use:
Understand Qwen DashScope (Alibaba Cloud) billing
masterDashScope billing for
qwen3-vl-embeddingis based on Tokens per 1,000 inputs and varies by modality:- Text Input: ~¥0.0007 / 1k Tokens
- Image/Video Input: ~¥0.0018 / 1k Tokens
Note that indexing uses the Video modality, while
searchandimgqueries primarily use Text or Image tokens. Total costs depend on the token count, which is influenced by resolution, duration, and sampling settings (e.g., theDASHSCOPE_VIDEO_FPSenvironment variable).Index video footage
masterUse the
indexcommand to process video files into searchable chunks. You can customize chunking, resolution, and frame rate via options.Options:
--chunk-duration <seconds>: Duration of each chunk (default:30).--overlap <seconds>: Overlap between consecutive chunks (default:5).--no-preprocess: Skip downscaling and frame rate reduction (sends raw chunks).--target-resolution <pixels>: Target height for preprocessing (default:480).--target-fps <fps>: Target frame rate for preprocessing (default:5).--no-skip-still: Embed all chunks, even those with no visual change.--backend <backend>: Specify the backend (e.g.,local).
$ sentrysearch index /path/to/video/footage