{"id":13598789,"url":"https://github.com/akamhy/videohash","last_synced_at":"2025-05-16T14:04:31.048Z","repository":{"id":39654466,"uuid":"330458533","full_name":"akamhy/videohash","owner":"akamhy","description":"Near Duplicate Video Detection (Perceptual Video Hashing) - Get a 64-bit comparable hash-value for any video. ","archived":false,"fork":false,"pushed_at":"2024-07-12T22:43:13.000Z","size":5688,"stargazers_count":310,"open_issues_count":18,"forks_count":52,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-05-15T04:09:57.037Z","etag":null,"topics":["duplicate-detection","duplicate-video-finder","duplicate-videos","ffmpeg","find-similar-videos-by-content","ndvd","ndvr","near-duplicate-video","near-duplicate-video-clip-detection","python","video","video-deduplication","video-similarity-search","visual-claim"],"latest_commit_sha":null,"homepage":"https://pypi.org/project/videohash","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akamhy.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-17T18:27:08.000Z","updated_at":"2025-05-13T06:55:32.000Z","dependencies_parsed_at":"2024-01-14T04:44:02.146Z","dependency_job_id":"2a74af6c-6793-40be-b80b-861a69792450","html_url":"https://github.com/akamhy/videohash","commit_stats":{"total_commits":198,"total_committers":6,"mean_commits":33.0,"dds":"0.025252525252525304","last_synced_commit":"e407bb0b26de625a846c2700072efccd9eb44e9a"},"previous_names":[],"tags_count":25,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamhy%2Fvideohash","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamhy%2Fvideohash/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamhy%2Fvideohash/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akamhy%2Fvideohash/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akamhy","download_url":"https://codeload.github.com/akamhy/videohash/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254544146,"owners_count":22088807,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["duplicate-detection","duplicate-video-finder","duplicate-videos","ffmpeg","find-similar-videos-by-content","ndvd","ndvr","near-duplicate-video","near-duplicate-video-clip-detection","python","video","video-deduplication","video-similarity-search","visual-claim"],"created_at":"2024-08-01T17:00:56.467Z","updated_at":"2025-05-16T14:04:31.011Z","avatar_url":"https://github.com/akamhy.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"\u003cdiv align=\"center\"\u003e\n\u003cimg src=\"https://raw.githubusercontent.com/akamhy/videohash/main/assets/logo/logo-optimized.svg\"\u003e\u003cbr\u003e\n\u003c/div\u003e\n\n\u003ch2 align=\"center\"\u003e The Python package for near duplicate video detection \u003c/h2\u003e\n\n\u003cp align=\"center\"\u003e\n\u003ca href=\"https://github.com/akamhy/videohash/actions?query=workflow%3AUbuntu\"\u003e\u003cimg alt=\"Build Status\" src=\"https://github.com/akamhy/videohash/workflows/Ubuntu/badge.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/akamhy/videohash/actions?query=workflow%3AWindows\"\u003e\u003cimg alt=\"Build Status\" src=\"https://github.com/akamhy/videohash/workflows/Windows/badge.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/akamhy/videohash/actions?query=workflow%3AmacOS\"\u003e\u003cimg alt=\"Build Status\" src=\"https://github.com/akamhy/videohash/workflows/macOS/badge.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://codecov.io/gh/akamhy/videohash\"\u003e\u003cimg alt=\"codecov\" src=\"https://codecov.io/gh/akamhy/videohash/branch/main/graph/badge.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://lgtm.com/projects/g/akamhy/videohash/alerts/\"\u003e\u003cimg alt=\"Total alerts\" src=\"https://img.shields.io/lgtm/alerts/g/akamhy/videohash.svg?logo=lgtm\u0026logoWidth=18\"\u003e\u003c/a\u003e\n\u003ca href=\"https://lgtm.com/projects/g/akamhy/videohash/context:python\"\u003e\u003cimg alt=\"Language grade: Python\" src=\"https://img.shields.io/lgtm/grade/python/g/akamhy/videohash.svg?logo=lgtm\u0026logoWidth=18\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pypi.org/project/videohash/\"\u003e\u003cimg alt=\"pypi\" src=\"https://img.shields.io/pypi/v/videohash.svg\"\u003e\u003c/a\u003e\n\u003ca href=\"https://pepy.tech/project/videohash?versions=1*\u0026versions=2*\u0026versions=3*\"\u003e\u003cimg alt=\"Downloads\" src=\"https://pepy.tech/badge/videohash/month\"\u003e\u003c/a\u003e\n\u003ca href=\"https://github.com/akamhy/videohash/commits/main\"\u003e\u003cimg alt=\"GitHub lastest commit\" src=\"https://img.shields.io/github/last-commit/akamhy/videohash?color=blue\u0026style=flat-square\"\u003e\u003c/a\u003e\n\u003ca href=\"#\"\u003e\u003cimg alt=\"PyPI - Python Version\" src=\"https://img.shields.io/pypi/pyversions/videohash?style=flat-square\"\u003e\u003c/a\u003e\n\u003c/p\u003e\n\n--------------------------------------------------------------------------\n\n# \u003cimg src=\"https://github.githubassets.com/images/icons/emoji/unicode/2b50.png\" width=\"30\"\u003e\u003c/img\u003e Introduction\n\nVideohash is a [Python package](https://www.udacity.com/blog/2021/01/what-is-a-python-package.html) for **detecting near-duplicate videos (Perceptual Video Hashing)**.\nIt can take any input video and generate a 64-bit equivalent hash value. Videohash is way more faster than comparing the imagehash values of individual [frames](https://en.wikipedia.org/wiki/Film_frame) of the video and more reliable than hashing [keyframes](https://en.wikipedia.org/wiki/Key_frame).\n\nThe video-hash-values for identical or near-duplicate videos are the same or similar, implying that if the video is resized (upscaled/downscaled), [transcoded](https://medium.com/videocoin/what-is-video-transcoding-and-why-do-you-do-it-348a2610cefc), [watermark](https://en.wikipedia.org/wiki/Digital_watermarking) added/removed, [stabilized](https://link.springer.com/referenceworkentry/10.1007%2F978-0-387-78414-4_76), [color changed](https://en.wikipedia.org/wiki/Chrominance), [frame rate](https://www.techsmith.com/blog/frame-rate-beginners-guide/) changed, changed [aspect ratio](https://en.wikipedia.org/wiki/Aspect_ratio_(image)),  [cropped](https://www.avs4you.com/blog/trim-cut-crop-avs4you/), [black-bars](https://en.wikipedia.org/wiki/Letterboxing_(filming)) added or removed, the hash-value should remain unchanged or not vary substantially.\n\n### How the hash values are calculated\n\n\u003e - Every one second, a frame from the input video is extracted, the frames are shrunk to a 144x144 pixel square, a collage is constructed that contains all of the resized frames(square-shaped), the collage's [wavelet hash](https://fullstackml.com/wavelet-image-hash-in-python-3504fdd282b5)'s bit-list is the first bit-list that we use. The frames extracted are now stitched horizontally to each other, and finally divided into 64 equal sized images, the domiant color of these 64 images are detected and compared with a pre-defined pattern of dominant colors, if they match the bit is set else unset. So now we have two bitlist, finally we bitwise XOR these two bitlists. The XOR'ed output is  used to generate the final 64 bit hash-value for the video. The bits are joined to form the 64 bit hash-value of the  input value.\n\n### When not to use Videohash\n\n\u003e - Videohash cannot be used to verify whether one video is a part of another (video fingerprinting). If the video is reversed or rotated by a substantial angle (greater than 10 degrees), Videohash will not provide the same or similar hash result, but you can always reverse the video manually and generate the hash value for reversed video.\n\n### How to compare the video hash values stored in a database\n\n\u003e - Read [Hamming Distance / Similarity searches in a database - Stack Overflow](https://stackoverflow.com/questions/9606492/hamming-distance-similarity-searches-in-a-database) [(Archive link)](https://web.archive.org/web/20211015120052/https://stackoverflow.com/questions/9606492/hamming-distance-similarity-searches-in-a-database)\n\n--------------------------------------------------------------------------\n\n## \u003cimg src=\"https://github.githubassets.com/images/icons/emoji/unicode/1f3d7.png\" width=\"20\"\u003e\u003c/img\u003e Installation\n\nTo use this software, you must have [FFmpeg](https://ffmpeg.org/) installed. Please read [how to install FFmpeg](https://github.com/akamhy/videohash/wiki/Install-FFmpeg,-but-how%3F) if you don't already know how.\n\n#### Install videohash\n\nUpgrade pip\n```bash\npython3 -m pip install --upgrade pip\n```\nIf you do not want to upgrade pip and the installation fails try appending `--prefer-binary` to the following installation command(s).\n\n**Install from the [PyPi](https://pypi.org/) (recommended)**:\n\n```bash\npip install videohash\n```\n\n**Using [conda](https://en.wikipedia.org/wiki/Conda_(package_manager)), from [conda-forge](https://anaconda.org/conda-forge/videohash) (recommended)**:\n\nMaintainer is  [@step21](https://github.com/step21)\n\n```bash\nconda install -c conda-forge videohash\n```\n\n**Install directly from [the](https://github.com/akamhy/videohash) GitHub repository (NOT recommended)**:\n\n```bash\npip install git+https://github.com/akamhy/videohash.git\n```\n\n--------------------------------------------------------------------------\n\n### Features\n\n- Generate videohash of a video directly from its URL(uses [yt-dlp](https://github.com/yt-dlp/yt-dlp)) or its path.\n- Can be used as the core of a scalable Near Duplicate Video Retrieval (NDVR) system.\n- The end-user can access the image representation(the collage) of the video.\n- A videohash instance can be compared to a 64-bit stored hash, its hex representation, bitlist, and other videohash instances.\n\n--------------------------------------------------------------------------\n\n## \u003cimg src=\"https://github.githubassets.com/images/icons/emoji/unicode/1f680.png\" width=\"20\"\u003e\u003c/img\u003e Usage\n\nIn the following usage example the first two and the fourth instance of VideoHash class are computing the hash for the same video(not same as in checksum) and the third one is a different video.\n\n- videohash1 is the VideoHash object for the video at \u003chttps://user-images.githubusercontent.com/64683866/168872267-7c6682f8-7294-4d9a-8a68-8c6f44c06df6.mp4\u003e.\n\n- videohash2 video (link : \u003chttps://user-images.githubusercontent.com/64683866/168869109-1f77c839-6912-4e24-8738-42cb15f3ab47.mp4\u003e) is upscaled, FPS changed and a text overlay added version of the first video, url1 at \u003chttps://user-images.githubusercontent.com/64683866/168872267-7c6682f8-7294-4d9a-8a68-8c6f44c06df6.mp4\u003e.\n\n- videohash3 video is a completely different video, at \u003chttps://user-images.githubusercontent.com/64683866/148960165-a210f2d2-6c41-4349-bd8d-a4cb673bc0af.mp4\u003e.\n\n- videohash4 video is a local copy of url1,  \u003chttps://user-images.githubusercontent.com/64683866/168872267-7c6682f8-7294-4d9a-8a68-8c6f44c06df6.mp4\u003e.\n\n```python\n\u003e\u003e\u003e from videohash import VideoHash\n\u003e\u003e\u003e url1 = \"https://user-images.githubusercontent.com/64683866/168872267-7c6682f8-7294-4d9a-8a68-8c6f44c06df6.mp4\"\n\u003e\u003e\u003e videohash1 = VideoHash(url=url1)\n\u003e\u003e\u003e \n\u003e\u003e\u003e url2 = \"https://user-images.githubusercontent.com/64683866/168869109-1f77c839-6912-4e24-8738-42cb15f3ab47.mp4\"\n\u003e\u003e\u003e videohash2 = VideoHash(url=url2)\n\u003e\u003e\u003e videohash2 - videohash1\n2\n\u003e\u003e\u003e videohash2.is_similar(videohash1)\nTrue\n\u003e\u003e\u003e \n\u003e\u003e\u003e url3 = \"https://user-images.githubusercontent.com/64683866/148960165-a210f2d2-6c41-4349-bd8d-a4cb673bc0af.mp4\"\n\u003e\u003e\u003e videohash3 = VideoHash(url=url3)\n\u003e\u003e\u003e videohash3.is_similar(videohash1)\nFalse\n\u003e\u003e\u003e videohash3.is_diffrent(videohash2)\nTrue\n\u003e\u003e\u003e videohash3-videohash1\n34\n\u003e\u003e\u003e videohash3-videohash2\n34\n\u003e\u003e\u003e path4 = \"/home/akamhy/Downloads/168872267-7c6682f8-7294-4d9a-8a68-8c6f44c06df6.mp4\"\n\u003e\u003e\u003e videohash4 = VideoHash(path=path4)\n\u003e\u003e\u003e videohash4 == videohash1\nTrue\n\u003e\u003e\u003e videohash4 - videohash1\n0\n\u003e\u003e\u003e videohash4.is_similar(videohash2)\nTrue\n\u003e\u003e\u003e videohash4.is_similar(videohash4)\nTrue\n\u003e\u003e\u003e videohash4.is_similar(videohash3)\nFalse\n\u003e\u003e\u003e \n```\n\n**Extended Usage** : \u003chttps://github.com/akamhy/videohash/wiki/Extended-Usage\u003e\n\n**API Reference** : \u003chttps://github.com/akamhy/videohash/wiki/API-Reference\u003e\n\n--------------------------------------------------------------------------\n\n\n### Credits\n\n  - [JohannesBuchner](https://github.com/JohannesBuchner) and [bunchesofdonald](https://github.com/bunchesofdonald) for [imagehash](https://github.com/JohannesBuchner/imagehash).\n  - [Dmitry Petrov](https://medium.com/@fullstackml) for [implementing](https://fullstackml.com/wavelet-image-hash-in-python-3504fdd282b5) [discrete wavelet transform](https://en.wikipedia.org/wiki/Discrete_wavelet_transform) (DWT) based image hashing in Python.\n  - [FFmpeg developers](https://ffmpeg.org/consulting.html).\n  - [Sam Dobson](https://github.com/samdobson) for [image_slicer](https://github.com/samdobson/image_slicer), videohash incorporates some code from image_slicer.\n  - [Eddievin](https://github.com/Eddievin) for README design.\n  - [iconolocode](https://github.com/iconolocode) for the videohash logo.\n \n--------------------------------------------------------------------------\n  \n### License\n\n[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/akamhy/videohash/blob/main/LICENSE)\n\nCopyright (c) 2021-2022 Akash Mahanty. See\n[license](https://github.com/akamhy/videohash/blob/main/LICENSE) for details.\n\nThe VideoHash logo was created by [iconolocode](https://github.com/iconolocode). See [license](https://github.com/akamhy/videohash/blob/main/assets/logo/LICENSE-LOGO) for details.\n\nVideos are from NASA and are in the public domain.\n\u003e NASA copyright policy states that \"NASA material is not protected by copyright unless noted\".\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakamhy%2Fvideohash","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakamhy%2Fvideohash","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakamhy%2Fvideohash/lists"}