Skip to main content

Video Hashing Library

Project description

VideoHash

A simple Video Hashing Library

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


Installation

You must have ffmpeg installed to use this library.

➤ Install FFmpeg

Linux
  • APT
sudo apt-get update
sudo apt install ffmpeg
  • Snap
sudo snap install ffmpeg
Windows

Steps are Based on video.stackexchange.com/a/20496, but note that the download site is outdated as of January 2021.

  • Download the release full variant from https://www.gyan.dev/ffmpeg/builds/. You can download any variant you want, but I prefer the full release.
  • Decompress the archive.
  • Copy the bin directory from the decompressed folder, and paste inside C:\Program Files\ffmpeg\.
  • Right click on "This PC" and navigate to Properties > Advanced System Settings > Advanced tab > Environment Variables.
  • In the Environment Variables window, click the "Path" row under the "Variable" column, then click Edit.
  • Click New and add C:\Program Files\ffmpeg\bin\to the list.
  • Click Ok on all the windows we just opened up. (Answer postive)

If you still have doubts read the answer https://video.stackexchange.com/a/20496, it has images to guide you.

Prefer video? https://www.youtube.com/watch?v=qjtmgCb8NcE

macOS
brew install ffmpeg

Install videohash

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

Usage

>>> import videohash
>>> hash1 = videohash.from_url("https://raw.githubusercontent.com/akamhy/videohash/main/assets/rocket.mkv")
>>> str(hash1)
'be1fffff9ffc0000'
>>> hash2 = videohash.from_url("https://www.youtube.com/watch?v=PapBjpzRhnA")
>>> str(hash2)
'fe3fffff9ffc0000'
>>>
>>> diff = hash1 - hash2
>>> diff
2
>>>
>>> hash3 = videohash.from_url("https://www.youtube.com/watch?v=_T8cn2J13-4")
>>> diff = hash1 - hash3
>>> diff
31
>>> str(hash3)
'3cffff00000081f0'
>>>
>>> #hash4 file is hash1 file downloaded locally. Use absolute path
>>> hash4 = videohash.from_path("/home/akamhy/Downloads/rocket.mkv")
>>> diff = hash4 - hash1
>>> diff
0
>>>

Run the above code @ https://repl.it/@akamhy/video-hash-example#main.py


You can change the algorithm used to generate the hash of the collage via the image_hash argument. The default algorithm is average_hash.

>>> hash = videohash.from_url("https://www.youtube.com/watch?v=PapBjpzRhnA", image_hash="crop_resistant_hash")
>>> hash = videohash.from_path("/home/akamhy/Downloads/rocket.mkv", image_hash="phash")
➤ Algorithms supported

  • average_hash
  • phash
  • dhash
  • whash
  • colorhash
  • crop_resistant_hash

videohash is using https://github.com/JohannesBuchner/imagehash to use these image-hashing algorithms.

License

License: MIT

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

Released under the MIT License. See license for details.


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-1.0.5.tar.gz (9.4 kB view hashes)

Uploaded Source

Built Distribution

videohash-1.0.5-py3-none-any.whl (7.8 kB view hashes)

Uploaded Python 3

Supported by

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