Video Hashing Library
Project description
VIDEOHASH
A simple Video Hashing Library
Installation
You must have ffmpeg installed to use this library.
Install FFmpeg
Linux
- APT
sudo apt install ffmpeg
- Snap
sudo snap install ffmpeg
macOS
brew install ffmpeg
Install videohash
- Using pip:
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.webm")
>>> str(hash1)
'7c7e7ff9ffff0000'
>>> hash2 = videohash.from_url("https://www.youtube.com/watch?v=PapBjpzRhnA")
>>> str(hash2)
'fc7e7ffbffff0000'
>>>
>>> diff = hash1 - hash2
>>> diff
2
>>>
>>> hash3 = videohash.from_url("https://www.youtube.com/watch?v=_T8cn2J13-4")
>>> diff = hash1 - hash3
>>> diff
37
>>> str(hash3)
'3cffff0000000eff'
>>>
>>> #hash4 file is hash1 file downloaded locally. Use absolute path
>>> hash4 = videohash.from_path("/home/akamhy/Downloads/rocket.webm")
>>> diff = hash4 - hash1
>>> diff
0
>>>
-
https://raw.githubusercontent.com/akamhy/videohash/main/assets/rocket.webm is copy of https://www.youtube.com/watch?v=PapBjpzRhnA, and are about the Artemis program and SLS rocket.
-
https://www.youtube.com/watch?v=_T8cn2J13-4 is an entirely distinct video also about the Artemis program.
-
Notice that the difference of hash1 and hash2 is 2, but the difference between hash1 and hash3 is 37.
-
The difference of hash1 and hash2 is not 0 as the file in this repository is slightly modified and downscaled.
-
A collage of frames is generated and imagehash(Average hashing) of this collage is videohash for the full video.
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.webm", image_hash="phash")
Algorithms supported
average_hash
phash
dhash
whash
colorhash
crop_resistant_hash
videohash uses https://github.com/JohannesBuchner/imagehash to use these hashing algorithms.
License
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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Hashes for videohash-1.0.3-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1dcdbaa7d46664e016d47bc30bc2a132a54d4f640e91adcbcd964460381a62ff |
|
MD5 | cd1be3703f5386147773de6b06d5e341 |
|
BLAKE2b-256 | ad6749593d55c07054ad8f0a4b4b6d77e88f489d04efbf1106a24205a762beff |