This is the package including tools for BrainFrame developers to work with onvif cameras.
Project description
ONVIF Tools - Latest Updates
Changes Made
This update implements the following improvements to the ONVIF tools:
1. Configuration File Rename
- Changed:
brainframe_config.csv→config.csv - Reason:
.csvextension makes it clearer that the file is in CSV format - Impact: All three scripts and documentation updated
2. Column Order Update
- Changed: Column order in the CSV header
- Old:
...system_datetime,osd,rtsp_url - New:
...system_datetime,rtsp_url,osd - Reason: RTSP URL logically precedes OSD text in importance
- Impact: All three scripts updated to write columns in the new order
3. Script Rename
- Changed:
validate_rtsp_urls.py→validate_onvif_cameras.py - Reason: Better reflects the script's purpose of validating ONVIF cameras
- Impact: Main script renamed, and import statement in
brainframe-onvif-tools.pyupdated
4. Documentation Updates
- Updated: CHANGES.md to reflect all changes
- Created: This README.md to summarize deliverables
Authentication Design and Workflow
This tool suite employs a robust, multi-stage authentication strategy designed to be safe, efficient, and reliable. The core philosophy is to prevent camera lockouts caused by brute-force attacks while providing flexibility for different network environments.
Core Principles
-
A Single Source of Truth: The system is built on the principle that a single camera has one primary administrative credential set. The
scanscript's job is to discover this credential, and thevalidatescript's job is to verify it against other services (like RTSP). -
Safety First (No Brute-Force): The
validatescript never attempts to discover credentials. It only uses the single credential provided by thescanphase or a manual user override. This deliberate design eliminates the risk of sending multiple failed login attempts and getting locked out by camera security features. -
Predictable Priority: The scripts follow a strict and predictable order of precedence for credential sources:
- Command-Line (CLI) Override: Highest priority. A user-provided credential is treated as an expert instruction and is used exclusively.
- JSON Inventory File: The default source, using the credential discovered during the
scanphase. - Common Credentials List: Lowest priority, used only during the
scanphase if no override is given.
-
Anonymous-First: For any camera, an anonymous login is always attempted first to correctly identify and classify cameras that do not require authentication.
The Three-Stage Workflow
The authentication logic is distributed across the three main commands:
1. discover
- Role: Finds potential camera IPs on the network.
- Authentication: None. This stage is completely anonymous and uses network broadcast protocols.
2. scan
- Role: Discovers the single, correct administrative credential for each camera.
- Credential Order of Attempt:
- Anonymous (
""/""): Always tried first. If successful, the script stops and records the camera as anonymous. - CLI Override (
--user/--password): If an anonymous attempt fails and a CLI override is provided, only that credential is used. If it fails, the script stops and reports the failure for that camera. - Common Credentials List: If the Anonymous fails and no CLI Override was given, the script tries a list of common credentials. It stops on the first success.
- Anonymous (
- Output: The
camera_onvif_info.jsonfile now contains one confirmed credential set (or anonymous) for each successfully scanned camera.
3. validate
- Role: Verifies the discovered credential against RTSP and Snapshot services. It never discovers new credentials.
- Credential Source Priority:
- CLI Override (
--user/--password): If provided, this credential is used instead of what's in the JSON file. If it fails, the validation fails. There is no fallback. - JSON File (
camera_onvif_info.json): If no override is given, the script uses the single credential set from the JSON file. If it fails, the validation fails.
- CLI Override (
- Behavior: This script will only ever make one authentication attempt per stream, ensuring it is safe to run repeatedly.
Handling Edge Cases
It is rare, but possible, for a camera's RTSP or Snapshot service to use a different credential than its ONVIF administrative service. This design handles that scenario safely:
- In an edge case where the
validatestep fails with the discovered credential, the stream is correctly marked as invalid. - This provides clear feedback to the user that the service requires a different authentication method.
- The user can then investigate the camera's web interface and use the CLI override as an expert tool to provide the correct, specific credential for that service, ensuring all cameras can be configured correctly without compromising safety.
Note on CLI Overrides: When using an override with the validate command, it will update the final config.csv with the successful override credentials to produce a working configuration. However, it will not modify the master camera_onvif_info.json inventory. To permanently update the inventory with new credentials, you should update the credentials.txt or re-run the scan command with new credentials.
Deliverables
Updated Scripts
- discover_onvif_cameras.py - Updated for
config.csvand new column order - scan_onvif_cameras.py - Updated for
config.csvand new column order - validate_onvif_cameras.py - Renamed from
validate_rtsp_urls.py, updated forconfig.csvand new column order - brainframe-onvif-tools.py - Updated to import
validate_onvif_camerasinstead ofvalidate_rtsp_urls
Documentation
- CHANGES.md - Updated with complete change history
- README.md - This file, summarizing deliverables
Files Changed Summary
| File | Type of Change | Description |
|---|---|---|
| discover_onvif_cameras.py | Modified | Filename and column order |
| scan_onvif_cameras.py | Modified | Filename and column order |
| validate_rtsp_urls.py → validate_onvif_cameras.py | Renamed + Modified | File rename, filename and column order |
| brainframe-onvif-tools.py | Modified | Import statement and help text |
| CHANGES.md | Modified | Updated documentation |
New CSV Header Format
# ip:port,username,password,manufacturer,model,serial_number,audio_in,audio_out,auth_required,encoding,width,height,framerate,bitrate,system_datetime,rtsp_url,osd
Note: rtsp_url now appears before osd
Backward Compatibility
⚠️ Important: These changes are NOT backward compatible with:
- Old
brainframe.configfiles (different filename) - Files using the old column order (osd before rtsp_url)
To migrate:
- Run
discoveragain to create a newconfig.csv - Or manually rename and reorder columns in existing files
Usage
All scripts continue to work the same way, just with the new filenames:
# Discover cameras
python3 discover_onvif_cameras.py --auto
# Scan cameras
python3 scan_onvif_cameras.py
# Validate cameras
python3 validate_onvif_cameras.py
# Or use the unified tool
python3 brainframe-onvif-tools.py discover
python3 brainframe-onvif-tools.py scan
python3 brainframe-onvif-tools.py validate
What Stayed the Same
- File structure with opening/closing tags:
<add_stream, load_settings, start_analyzing>and</> - CSV format with comma-separated values
- All command-line arguments
- All functionality and features
- RTSP URL embedding with credentials
- Video encoder information extraction
- Snapshot functionality
Only the filename, column order, and one script name changed.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file brainframe_onvif_tools-0.1.tar.gz.
File metadata
- Download URL: brainframe_onvif_tools-0.1.tar.gz
- Upload date:
- Size: 3.9 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b6109d7cafb203799aed87d8f50704885dd798719287edb5249c8f2e4658db54
|
|
| MD5 |
2540b27db77a7732aa5cb904b68c76b0
|
|
| BLAKE2b-256 |
ef7ff6dba8306d084d218073ae7b950ac1ac70c8dc1d032d8def572c1033173c
|
File details
Details for the file brainframe_onvif_tools-0.1-py3-none-any.whl.
File metadata
- Download URL: brainframe_onvif_tools-0.1-py3-none-any.whl
- Upload date:
- Size: 3.9 MB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.3
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1205113fac260a5401e6925ac051d450511303125d7a3cbc04eef5252f24ab9f
|
|
| MD5 |
2a4606fade17e0e8b82911ab07b91108
|
|
| BLAKE2b-256 |
5ed9afcb4a09e7c7536ac51ccf4a8a28719f5ac7182f44dcd3e28d7d7ac61917
|