Giter Club home page Giter Club logo

libhikvision's Introduction

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

libhikvision's People

Contributors

bkbilly avatar race666 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

Forkers

race666 hoppke

libhikvision's Issues

SQLLite

hi, same way as your PHP ui, i'm in the case of record_index and event_index rather bin file and don't see this part ln the lib.

also, befor continue to debug, is the lib display the green, blue or red vector (event, motion area) during playback?

thank

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.