Skip to main content

A robust, flexible Python library to search and download recorded clips from a Hikvision NVR.

Project description

Hikvision NVR Clip Downloader A robust, flexible Python library for searching and downloading recorded video clips from a Hikvision NVR using the ISAPI endpoints.

This library simplifies the process of retrieving video footage by handling authentication, time-based search, and precise trimming, ensuring you get exactly the clip you need.

✨ Key Features Robust Authentication: Utilizes requests with HTTPDigestAuth for secure communication.

Flexible Parameters: Easily specify the camera channel and stream type (main/sub).

Time-Based Downloads: Search and download clips based on a precise start and end time range.

Intelligent Trimming: The library automatically trims the downloaded video chunks to the exact duration requested by the user, even if the requested clip spans across multiple recording chunks on the NVR.

Resilient Downloads: Supports resumable (idempotent) downloads with built-in retries and exponential backoff for reliable operation.

Clean Output: Converts downloaded video streams to the widely compatible .mp4 format.

Highly Configurable: Provides sensible defaults while allowing you to override port, scheme, and other parameters.

🚀 Getting Started These instructions will get you a copy of the project up and running on your local machine.

Prerequisites Python 3.6+

FFmpeg (must be installed and available in your system's PATH)

Installation Create and activate a virtual environment:

Bash python -m venv venv source venv/bin/activate # On macOS/Linux venv\Scripts\activate # On Windows Install dependencies:

Bash pip install -r requirements.txt

💻 Usage Run the script from your terminal, providing the required arguments.

Example Command Bash

python hikvision_nvr_downloader.py 192.168.1.4 admin yourpassword 2025-08-24T10:00:00Z 2025-08-24T10:05:00Z --camera 1 --stream main --out ./downloads Arguments host: The NVR's IP address or hostname (e.g., 192.168.1.4).

username: The NVR login username (e.g., admin).

password: The NVR login password.

start: The start time of the clip in ISO 8601 format (e.g., 2025-08-24T10:00:00Z).

end: The end time of the clip in ISO 8601 format (e.g., 2025-08-24T10:05:00Z).

Optional Arguments --camera: The camera number (defaults to 1).

--stream: The stream type (main or sub, defaults to main).

--port: The ISAPI port on the NVR (defaults to 80).

--scheme: The protocol (http or https, defaults to http).

--out: The output directory for the downloaded file (defaults to .).

--verbose: Enables verbose logging for troubleshooting.

Notes The maximum clip duration is 2 hours.

The NVR must be reachable over HTTP on the same network.

Timezones: The library assumes times are in the UTC (Z) timezone. If you provide a timezone-naive datetime object in your code, the library will assume the local timezone.

Track IDs: On most Hikvision NVRs, the track IDs follow a convention: trackID = N100 + 1 for the main stream and trackID = N100 + 2 for the sub stream.

🤝 Contributing We welcome contributions! If you would like to help improve this project, please follow these steps:

Fork the repository.

Create a new branch for your feature or bug fix.

Commit your changes with a clear and descriptive message.

Push your branch to your forked repository.

Submit a pull request describing your changes.

📄 License This project is licensed under the MIT License.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

hikvision_nvr_downloader-0.1.0.tar.gz (14.5 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

hikvision_nvr_downloader-0.1.0-py3-none-any.whl (14.2 kB view details)

Uploaded Python 3

File details

Details for the file hikvision_nvr_downloader-0.1.0.tar.gz.

File metadata

  • Download URL: hikvision_nvr_downloader-0.1.0.tar.gz
  • Upload date:
  • Size: 14.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.10

File hashes

Hashes for hikvision_nvr_downloader-0.1.0.tar.gz
Algorithm Hash digest
SHA256 40bbee996ea10c0750342e850483de1d8c4afc29519d0f9f66741a4086a5bab5
MD5 c463ef5af3d76655d9c9a6b8b8faed4d
BLAKE2b-256 2a55a0f0b285a47a418df1fa3357c59a5d3e7cc385c718f7b9c64fdb35a13684

See more details on using hashes here.

File details

Details for the file hikvision_nvr_downloader-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for hikvision_nvr_downloader-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d91c20b09b90e2b8692d4bd5fe8ca66bed10e31eda1a171f54e43a1d094ac712
MD5 c07a51a6c8f15347a38096c5c9e7ec46
BLAKE2b-256 edf02d753d223df9d7f0282cefb38d2782748fbe20e4b52ecc1ab156f2d117de

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page