Skip to main content

videohash - Perceptual Video Hashing package

Project description

VideoHash

Python package for Perceptual Video Hashing

Build Status Build Status Build Status codecov pypi Downloads GitHub lastest commit PyPI - Python Version


Installation

You must have FFmpeg installed to use this software. If you don't know how to install FFmpeg, please read How to install FFmpeg.

Install videohash

pip install videohash
  • Install directly from GitHub:
pip install git+https://github.com/akamhy/videohash.git

Features

  • Generate videohash of a video directly from its URL or its path.
  • Image representation of the video is accessible by the end-user.
  • An instance of videohash can be compared with a stored hash(64-bit), its hex representation, and other instances of videohash.
  • Faster than the primitive process of comparing all the frames one by one. The videohash package produces a single 64-bit hash, a lot of database space is saved. And the number of comparisons required drops significantly.

Usage

Extended Usage

>>> from videohash import VideoHash
>>> hash1 = VideoHash(url="https://www.youtube.com/watch?v=PapBjpzRhnA", download_worst=False)
>>> str(hash1)
'0b0011010000011111111011111111111110001111011110000000000000000000'
>>> hash1.hash
'0b0011010000011111111011111111111110001111011110000000000000000000'
>>> hash1.hash_hex
'0x341fefff8f780000'
>>> repr(hash1)
'VideoHash(hash=0b0011010000011111111011111111111110001111011110000000000000000000, hash_hex=0x341fefff8f780000, collage_path=/tmp/tmpe07d_b1g/temp_storage_dir/acn6zsdcb40q/collage/collage.jpg, bits_in_hash=64)'
>>> hash1.collage_path
'/tmp/tmpe07d_b1g/temp_storage_dir/acn6zsdcb40q/collage/collage.jpg'
>>> hash1.bits_in_hash
64
>>> len(hash1)
66
>>> hash2 = VideoHash(url="https://raw.githubusercontent.com/akamhy/videohash/main/assets/rocket.mkv")
>>> hash2.hash
'0b0011010000011111111011111111111110001111011110000000000000000000'
>>> hash2.hash_hex
'0x341fefff8f780000'
>>> hash1.hash_hex
'0x741fcfff8f780000'
>>> hash1 - hash2
0
>>> hash2 - "0x341fefff8f780000"
0
>>> hash1 - "0b0011010000011111111011111111111110001111011110000000000000000000"
2
>>> hash1 == hash2
True
>>> hash1 != hash2
False
>>> hash3 = VideoHash(path="/home/akamhy/Downloads/rocket.mkv")
>>> hash3.hash_hex
'0x341fefff8f780000'
>>> hash3.hash
'0b0011010000011111111011111111111110001111011110000000000000000000'
>>> hash3 - hash2
0
>>> hash3 == hash1
False
>>> hash3 == hash2
True
>>> hash4 = VideoHash(url="https://www.youtube.com/watch?v=_T8cn2J13-4")
>>> hash4.hash_hex
'0x7cffff000000eff0'
>>> hash4 - "0x7cffff000000eff0"
0
>>> hash4.hash
'0b0111110011111111111111110000000000000000000000001110111111110000'
>>> hash4 - "0b0111110011111111111111110000000000000000000000001110111111110000"
0
>>> hash4 == hash3
False
>>> hash4 - hash2
34
>>> hash4 != hash2
True
>>> hash4 - "0b0011010000011111111011111111111110001111011110000000000000000000"
34
>>>

Run the above code @ https://replit.com/@akamhy/videohash-usage-2xx-example-code-for-video-hashing#main.py

Wiki/Usage/Docs : https://github.com/akamhy/videohash/wiki

License

License: MIT

Released under the MIT License. See license for details.

Videos are from NASA and are in the public domain.

NASA videos are in the public domain. NASA copyright policy states that "NASA material is not protected by copyright unless noted".


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

videohash-2.0.1.tar.gz (14.9 kB view details)

Uploaded Source

Built Distribution

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

videohash-2.0.1-py3-none-any.whl (15.7 kB view details)

Uploaded Python 3

File details

Details for the file videohash-2.0.1.tar.gz.

File metadata

  • Download URL: videohash-2.0.1.tar.gz
  • Upload date:
  • Size: 14.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for videohash-2.0.1.tar.gz
Algorithm Hash digest
SHA256 f63c9a7284accfefc096639b95330a620e387314eeb50ab0f939477c5388f880
MD5 86e4d8f7e7461e62fcd7296cd19bd90d
BLAKE2b-256 044d9a2f57a1b88325db38ecfded6826e9d21f6e9e41ab526a931a4d40d20a56

See more details on using hashes here.

File details

Details for the file videohash-2.0.1-py3-none-any.whl.

File metadata

  • Download URL: videohash-2.0.1-py3-none-any.whl
  • Upload date:
  • Size: 15.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.9.7

File hashes

Hashes for videohash-2.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 1c2d6aa007f435481f13ec4b5cc6831fba066ba3fe6c8c361c3aa94301d0a724
MD5 e3333314176787f9c0818bf95a50e2d0
BLAKE2b-256 9ba0ff6e6c7d21f08bee48f9fb35ff18341582a28712a4b311bdc49ec36aa31d

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