Skip to main content

Parse Hikvision datadirs that Hikvision IP cameras store the videos

Project description

LibHikvision

PyPI Version

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

#!/usr/bin/python3

from libhikvision import libHikvision
from datetime import datetime
from datetime import timedelta

cameradir = '/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

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

libhikvision-0.3.10.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

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

libhikvision-0.3.10-py3-none-any.whl (6.6 kB view details)

Uploaded Python 3

File details

Details for the file libhikvision-0.3.10.tar.gz.

File metadata

  • Download URL: libhikvision-0.3.10.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for libhikvision-0.3.10.tar.gz
Algorithm Hash digest
SHA256 c1af12b4c006442212c1c10e80a3f9a860849a3e3f0c133e90e5f4a8fb13dae8
MD5 f26ebdf53e694e8e2cb8823d21823f76
BLAKE2b-256 30ea9eccf867cf3b491f9c23fa165ad1b12abbd62f24a1fba75747220054c2da

See more details on using hashes here.

File details

Details for the file libhikvision-0.3.10-py3-none-any.whl.

File metadata

  • Download URL: libhikvision-0.3.10-py3-none-any.whl
  • Upload date:
  • Size: 6.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.9.23

File hashes

Hashes for libhikvision-0.3.10-py3-none-any.whl
Algorithm Hash digest
SHA256 3a0c1e7126f3e0e085681539de31376e6f2921ccc7c6d98b072699220f5bb3e1
MD5 e3e37239db69782d3e1dbd6ac8fb2513
BLAKE2b-256 09eaaf492fe6d4694e6119eccbbbcf4f01ce7b0466c34c6ec662fef10c15109f

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