Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/bkbilly/libhikvision
Extract videos/photos from HikVision camera datadirs
https://github.com/bkbilly/libhikvision
dvr hikvision pypi video
Last synced: 1 day ago
JSON representation
Extract videos/photos from HikVision camera datadirs
- Host: GitHub
- URL: https://github.com/bkbilly/libhikvision
- Owner: bkbilly
- License: mit
- Created: 2019-08-23T14:50:34.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2023-05-06T19:20:01.000Z (over 1 year ago)
- Last Synced: 2024-09-09T22:37:53.230Z (25 days ago)
- Topics: dvr, hikvision, pypi, video
- Language: Python
- Homepage: https://pypi.org/project/libhikvision/
- Size: 20.5 KB
- Stars: 14
- Watchers: 5
- Forks: 2
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# LibHikvision
[![PyPI Version](https://img.shields.io/pypi/v/libHikvision?label=PyPI&logo=pypi)](https://pypi.org/project/libHikvision/)Python library to parse Hikvision datadirs that Hikvision IP cameras store the videos.
Using this class you can view details about recordings stored in a datadir and extract video and thumbnails.### Working Example
```python
#!/usr/bin/python3from libhikvision import libHikvision
from datetime import datetime
from datetime import timedeltacameradir = '/var/tmp/hikvision/'
hik = libHikvision(cameradir, 'video')# Get information about the server
print(hik.getNASInfo())# Extract the segments within a specific range of dates
# segments = hik.getSegments(
# from_time=datetime(2023, 5, 5, 8, 0, 0),
# to_time=datetime(2023, 5, 20, 23, 59, 00),
#)# Extract last 3 Hours
segments = hik.getSegments(
from_time=(datetime.now() - timedelta(hours=3)),
to_time=(datetime.now()),
)# Extract the Videos and Images from segments found above
for num, segment in enumerate(segments, start=0):
print('{0:4}) {1[cust_filePath]:55} {1[cust_duration]:5} {1[startOffset]:10} {1[endOffset]:10} {1[cust_startTime]} - {1[cust_endTime]}'.format(
num,
segment
))
oDate = datetime.strptime("{0[cust_startTime]}".format(segment), '%Y-%m-%d %H:%M:%S')
sDateFormated=oDate.strftime('%Y%m%d-%H%M%S')
print(hik.extractSegmentMP4(num, cachePath='/var/tmp/', filename='/var/tmp/video-{0}.mp4'.format(sDateFormated)))
print(hik.extractSegmentJPG(num, cachePath='/var/tmp/', filename='/var/tmp/video-{0}.jpg'.format(sDateFormated)))
```You should also check the documentation of each method for extra options.
### Credits
Based on Dave Hope's PHP code available at https://github.com/davehope/libHikvision