Skip to content

Commit

Permalink
Merge pull request #1 from Demmenie/v3.0.2
Browse files Browse the repository at this point in the history
V3.0.2
  • Loading branch information
Demmenie authored Jul 3, 2024
2 parents e407bb0 + c44d61c commit 6d67fd9
Show file tree
Hide file tree
Showing 27 changed files with 93 additions and 109 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: ['3.7', '3.8', '3.9', '3.10']
python-version: ['3.7', '3.8', '3.9', '3.10', '3.11']
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -33,15 +33,12 @@ jobs:
- name: Lint with flake8
run: |
# stop the build if there are Python syntax errors or undefined names
flake8 videohash/ --count --select=E9,F63,F7,F82 --show-source --statistics
flake8 videohash2/ --count --select=E9,F63,F7,F82 --show-source --statistics
# exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide
flake8 videohash/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --per-file-ignores="videohash/__init__.py:F401"
flake8 videohash2/ --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics --per-file-ignores="videohash/__init__.py:F401"
- name: Static type test with mypy
run: |
mypy
- name: Test with pytest
run: |
pytest
- name: Upload coverage to Codecov
run: |
bash <(curl -s https://codecov.io/bash) -t ${{ secrets.CODECOV_TOKEN }}
4 changes: 2 additions & 2 deletions .github/workflows/ci_windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@ jobs:
pip install -r requirements-test.txt
pip install -U setuptools wheel
python assets/windows_ffmpeg_downloader_at_cwd.py
$env:Path += ";D:\a\videohash\videohash"
$env:Path += ";D:\a\videohash2\videohash2"
ffmpeg -version
- name: Build test the package
run: |
python setup.py sdist bdist_wheel
- name: Test with pytest
run: |
pytest --cov=videohash tests/ -v
pytest --cov=videohash2 tests/ -v
10 changes: 7 additions & 3 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
## Contributing

When contributing to this repository, first discuss the change you wish to make via issue or email with the owner(s) of this repository. By contributing to the project you agree to publish your changes under the [MIT License](/LICENSE).
When contributing to this repository, first discuss the change you wish to make
via issue or email with the owner(s) of this repository. By contributing to the
project you agree to publish your changes under the [MIT License](/LICENSE).

## Pull Request Process

Unless there's an obvious error in the repository please first create an issue and only then create a pull request.
Unless there's an obvious error in the repository please first create an issue
and only then create a pull request.

Also read [DEVELOPMENT.md](/DEVELOPMENT.md) before creating a pull request.


## Code of Conduct

Try your best to use welcoming and inclusive language and be respectful. That's it. Don't want a big Code of Conducts for this small project.
Try your best to use welcoming and inclusive language and be respectful. That's
it. Don't want a big Code of Conducts for this small project.
13 changes: 9 additions & 4 deletions DEVELOPMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,14 @@

### Code formatting

We use the [black](https://github.com/psf/black) code formatter. Always format the code with black before
We use the [black](https://github.com/psf/black) code formatter. Always format
the code with black before
submitting a pull request.

### Testing

Before submitting a pull request, make sure the code passes all the tests and is formatted by black:
Before submitting a pull request, make sure the code passes all the tests and is
formatted by black:

```bash
# Inside the project root (directory containing this file)
Expand All @@ -18,11 +20,14 @@ mypy
pytest
black .
```
This should create a virtual environment and install project's all dependencies including the ones required for running the tests, run the tests and finally format the code with black.
This should create a virtual environment and install project's all dependencies
including the ones required for running the tests, run the tests and finally
format the code with black.

### Packaging (uploading to PyPI)

In the project root run the following command inside the virtual environment created for testing.
In the project root run the following command inside the virtual environment
created for testing.

```bash
pip install setuptools wheel twine
Expand Down
2 changes: 1 addition & 1 deletion LICENSE
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
MIT License

Copyright (c) 2021-2022 Akash Mahanty
Copyright (c) 2024 Akash Mahanty

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
Expand Down
48 changes: 19 additions & 29 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,27 +1,24 @@
<div align="center">
<img src="https://raw.githubusercontent.com/akamhy/videohash/main/assets/logo/logo-optimized.svg"><br>
<img src="https://raw.githubusercontent.com/demmenie/videohash2/main/assets/logo/logo-optimized.svg"><br>
</div>

<h2 align="center"> The Python package for near duplicate video detection </h2>

<p align="center">
<a href="https://github.com/akamhy/videohash/actions?query=workflow%3AUbuntu"><img alt="Build Status" src="https://github.com/akamhy/videohash/workflows/Ubuntu/badge.svg"></a>
<a href="https://github.com/akamhy/videohash/actions?query=workflow%3AWindows"><img alt="Build Status" src="https://github.com/akamhy/videohash/workflows/Windows/badge.svg"></a>
<a href="https://github.com/akamhy/videohash/actions?query=workflow%3AmacOS"><img alt="Build Status" src="https://github.com/akamhy/videohash/workflows/macOS/badge.svg"></a>
<a href="https://codecov.io/gh/akamhy/videohash"><img alt="codecov" src="https://codecov.io/gh/akamhy/videohash/branch/main/graph/badge.svg"></a>
<a href="https://lgtm.com/projects/g/akamhy/videohash/alerts/"><img alt="Total alerts" src="https://img.shields.io/lgtm/alerts/g/akamhy/videohash.svg?logo=lgtm&logoWidth=18"></a>
<a href="https://lgtm.com/projects/g/akamhy/videohash/context:python"><img alt="Language grade: Python" src="https://img.shields.io/lgtm/grade/python/g/akamhy/videohash.svg?logo=lgtm&logoWidth=18"></a>
<a href="https://pypi.org/project/videohash/"><img alt="pypi" src="https://img.shields.io/pypi/v/videohash.svg"></a>
<a href="https://pepy.tech/project/videohash?versions=1*&versions=2*&versions=3*"><img alt="Downloads" src="https://pepy.tech/badge/videohash/month"></a>
<a href="https://github.com/akamhy/videohash/commits/main"><img alt="GitHub lastest commit" src="https://img.shields.io/github/last-commit/akamhy/videohash?color=blue&style=flat-square"></a>
<a href="#"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/videohash?style=flat-square"></a>
<a href="https://github.com/demmenie/videohash2/actions?query=workflow%3AUbuntu"><img alt="Build Status" src="https://github.com/demmenie/videohash2/workflows/Ubuntu/badge.svg"></a>
<a href="https://github.com/demmenie/videohash2/actions?query=workflow%3AWindows"><img alt="Build Status" src="https://github.com/demmenie/videohash2/workflows/Windows/badge.svg"></a>
<a href="https://github.com/demmenie/videohash2/actions?query=workflow%3AmacOS"><img alt="Build Status" src="https://github.com/demmenie/videohash2/workflows/macOS/badge.svg"></a>
<a href="https://pypi.org/project/videohash2/"><img alt="pypi" src="https://img.shields.io/pypi/v/videohash2.svg"></a>
<a href="https://pepy.tech/project/videohash?versions=1*&versions=2*&versions=3*"><img alt="Downloads" src="https://pepy.tech/badge/videohash/"></a>
<a href="https://github.com/demmenie/videohash2/commits/main"><img alt="GitHub lastest commit" src="https://img.shields.io/github/last-commit/demmenie/videohash2?color=blue&style=flat-square"></a>
<a href="#"><img alt="PyPI - Python Version" src="https://img.shields.io/pypi/pyversions/videohash2?style=flat-square"></a>
</p>

--------------------------------------------------------------------------

# <img src="https://github.githubassets.com/images/icons/emoji/unicode/2b50.png" width="30"></img> Introduction

Videohash 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)**.
Videohash2 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)**.
It 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).

The 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.
Expand Down Expand Up @@ -55,21 +52,13 @@ If you do not want to upgrade pip and the installation fails try appending `--pr
**Install from the [PyPi](https://pypi.org/) (recommended)**:

```bash
pip install videohash
pip install videohash2
```

**Using [conda](https://en.wikipedia.org/wiki/Conda_(package_manager)), from [conda-forge](https://anaconda.org/conda-forge/videohash) (recommended)**:

Maintainer is [@step21](https://github.com/step21)

```bash
conda install -c conda-forge videohash
```

**Install directly from [the](https://github.com/akamhy/videohash) GitHub repository (NOT recommended)**:
**Install directly from [the](https://github.com/demmenie/videohash2) GitHub repository (NOT recommended)**:

```bash
pip install git+https://github.com/akamhy/videohash.git
pip install git+https://github.com/demmenie/videohash2.git
```

--------------------------------------------------------------------------
Expand All @@ -96,7 +85,7 @@ In the following usage example the first two and the fourth instance of VideoHas
- videohash4 video is a local copy of url1, <https://user-images.githubusercontent.com/64683866/168872267-7c6682f8-7294-4d9a-8a68-8c6f44c06df6.mp4>.

```python
>>> from videohash import VideoHash
>>> from videohash2 import VideoHash
>>> url1 = "https://user-images.githubusercontent.com/64683866/168872267-7c6682f8-7294-4d9a-8a68-8c6f44c06df6.mp4"
>>> videohash1 = VideoHash(url=url1)
>>>
Expand All @@ -117,7 +106,7 @@ True
34
>>> videohash3-videohash2
34
>>> path4 = "/home/akamhy/Downloads/168872267-7c6682f8-7294-4d9a-8a68-8c6f44c06df6.mp4"
>>> path4 = "/home/demmenie/Downloads/168872267-7c6682f8-7294-4d9a-8a68-8c6f44c06df6.mp4"
>>> videohash4 = VideoHash(path=path4)
>>> videohash4 == videohash1
True
Expand Down Expand Up @@ -147,17 +136,18 @@ False
- [Sam Dobson](https://github.com/samdobson) for [image_slicer](https://github.com/samdobson/image_slicer), videohash incorporates some code from image_slicer.
- [Eddievin](https://github.com/Eddievin) for README design.
- [iconolocode](https://github.com/iconolocode) for the videohash logo.
- [Demmenie](https://github.com/demmenie) for forking and maintaining videohash2.

--------------------------------------------------------------------------

### License

[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/akamhy/videohash/blob/main/LICENSE)
[![License: MIT](https://img.shields.io/badge/License-MIT-green.svg)](https://github.com/demmenie/videohash2/blob/main/LICENSE)

Copyright (c) 2021-2022 Akash Mahanty. See
[license](https://github.com/akamhy/videohash/blob/main/LICENSE) for details.
[license](https://github.com/demmenie/videohash2/blob/main/LICENSE) for details.

The 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.
The VideoHash logo was created by [iconolocode](https://github.com/iconolocode). See [license](https://github.com/demmenie/videohash2/blob/main/assets/logo/LICENSE-LOGO) for details.

Videos are from NASA and are in the public domain.
> NASA copyright policy states that "NASA material is not protected by copyright unless noted".
> NASA copyright policy states that "NASA material is not protected by copyright unless noted".
1 change: 1 addition & 0 deletions assets/windows_ffmpeg_downloader_at_cwd.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import os
import sys
import shutil
import tempfile
from pathlib import Path
Expand Down
4 changes: 2 additions & 2 deletions mypy.ini
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
[mypy]

files =
videohash
videohash2

[mypy-numpy.*]
ignore_missing_imports = True

[mypy-imagehash.*]
ignore_missing_imports = True

[mypy-imagedominantcolor.*]
[mypy-imagedominantcolour.*]
ignore_missing_imports = True

[mypy-image_slicer.*]
Expand Down
2 changes: 1 addition & 1 deletion pytest.ini
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ addopts =
# enable all warnings
-Wd
# coverage and html report
--cov=videohash
--cov=videohash2
--cov-report=html
testpaths =
tests
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ImageHash
Pillow
imagedominantcolor
imagedominantcolour
yt-dlp
16 changes: 8 additions & 8 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@
long_description = f.read()

about = {}
with open(os.path.join(os.path.dirname(__file__), "videohash", "__version__.py")) as f:
with open(os.path.join(os.path.dirname(__file__), "videohash2", "__version__.py")) as f:
exec(f.read(), about)

version = str(about["__version__"])

download_url = f"https://github.com/akamhy/videohash/archive/{version}.tar.gz"
download_url = f"https://github.com/demmenie/videohash2/archive/{version}.tar.gz"

setup(
name=about["__title__"],
packages=["videohash"],
packages=["videohash2"],
version=version,
description=about["__description__"],
long_description=long_description,
Expand All @@ -26,7 +26,7 @@
url=about["__url__"],
download_url=download_url,
keywords=[
"videohash",
"videohash2",
"near duplicate video detection",
"NDVD",
"perceptual video hashing",
Expand All @@ -39,7 +39,7 @@
install_requires=[
"Pillow",
"ImageHash",
"imagedominantcolor",
"imagedominantcolour",
"yt-dlp",
],
python_requires=">=3.6",
Expand All @@ -61,16 +61,16 @@
"License :: OSI Approved :: MIT License",
"Programming Language :: Python",
"Programming Language :: Python :: 3",
"Programming Language :: Python :: 3.6",
"Programming Language :: Python :: 3.7",
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11",
"Programming Language :: Python :: Implementation :: CPython",
],
project_urls={
"Source": "https://github.com/akamhy/videohash",
"Source": "https://github.com/demmenie/videohash2",
"Documentation": "https://github.com/akamhy/videohash/wiki",
"Tracker": "https://github.com/akamhy/videohash/issues",
"Tracker": "https://github.com/demmenie/videohash2/issues",
},
)
6 changes: 3 additions & 3 deletions tests/test_collagemaker.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import pytest

from videohash.collagemaker import MakeCollage
from videohash.exceptions import CollageOfZeroFramesError
from videohash.utils import create_and_return_temporary_directory
from videohash2.collagemaker import MakeCollage
from videohash2.exceptions import CollageOfZeroFramesError
from videohash2.utils import create_and_return_temporary_directory


def test_all():
Expand Down
6 changes: 3 additions & 3 deletions tests/test_downloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import pytest

from videohash.downloader import Download
from videohash.exceptions import DownloadFailed, DownloadOutPutDirDoesNotExist
from videohash.utils import (
from videohash2.downloader import Download
from videohash2.exceptions import DownloadFailed, DownloadOutPutDirDoesNotExist
from videohash2.utils import (
create_and_return_temporary_directory,
get_list_of_all_files_in_dir,
)
Expand Down
6 changes: 3 additions & 3 deletions tests/test_framesextractor.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import pytest

from videohash.exceptions import FFmpegNotFound, FramesExtractorOutPutDirDoesNotExist
from videohash.framesextractor import FramesExtractor
from videohash.utils import create_and_return_temporary_directory
from videohash2.exceptions import FFmpegNotFound, FramesExtractorOutPutDirDoesNotExist
from videohash2.framesextractor import FramesExtractor
from videohash2.utils import create_and_return_temporary_directory

script_path = os.path.dirname(os.path.realpath(__file__))

Expand Down
2 changes: 1 addition & 1 deletion tests/test_videoduration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import pytest

from videohash.videoduration import video_duration
from videohash2.videoduration import video_duration

this_dir = os.path.dirname(os.path.realpath(__file__))

Expand Down
6 changes: 3 additions & 3 deletions tests/test_videohash.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,9 @@

import pytest

from videohash.exceptions import DidNotSupplyPathOrUrl, StoragePathDoesNotExist
from videohash.utils import create_and_return_temporary_directory
from videohash.videohash import VideoHash
from videohash2.exceptions import DidNotSupplyPathOrUrl, StoragePathDoesNotExist
from videohash2.utils import create_and_return_temporary_directory
from videohash2.videohash import VideoHash

this_dir = os.path.dirname(os.path.realpath(__file__))

Expand Down
14 changes: 0 additions & 14 deletions videohash/__version__.py

This file was deleted.

4 changes: 2 additions & 2 deletions videohash/__init__.py → videohash2/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
Usage:
>>> from videohash import VideoHash
>>> from videohash2 import VideoHash
>>> # video: Artemis I Hot Fire Test
>>> videohash1 = VideoHash(url="https://www.youtube.com/watch?v=PapBjpzRhnA", download_worst=False)
>>>
Expand Down Expand Up @@ -67,7 +67,7 @@
:copyright: (c) 2021 Akash Mahanty
:license: MIT, see LICENSE for more details.
:pypi: https://pypi.org/project/videohash/
:pypi: https://pypi.org/project/videohash2/
:wiki: https://github.com/akamhy/videohash/wiki
:cite: https://doi.org/10.5281/zenodo.4448295
"""
Expand Down
Loading

0 comments on commit 6d67fd9

Please sign in to comment.