movie-barcodes


Namemovie-barcodes JSON
Version 0.2.0 PyPI version JSON
download
home_pagehttps://github.com/Wazzabeee/movie-barcodes
SummaryCompress every frame of a movie in a single color barcode.Transform entire movies into stunning single-barcode visualizations.Capture the essence of cinematic storytelling through dominant color extraction from each frame.
upload_time2024-05-11 11:59:19
maintainerNone
docs_urlNone
authorClément Delteil
requires_python>=3.10
licenseNone
keywords visualization python opencv color extraction data science machine learning movies computer vision multiprocessing parallel computing barcode image processing multithreading data visualization video processing color barcode
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Movie Barcodes
The Lodger: A Story of the London Fog (1927) - Alfred Hitchcock - [Public Domain](https://archive.org/details/TheLodgerAStoryOfTheLondonFog_579)

Circular Barcode           |  Horizontal Barcode
:-------------------------:|:-------------------------:
![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/thelodgerastoryofthelondonfog_circular.png)  |  ![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/thelodgerastoryofthelondonfog_horizontal.png)

![PyPI - Version](https://img.shields.io/pypi/v/movie-barcodes)
![PyPI - License](https://img.shields.io/pypi/l/movie-barcodes)
![Python](https://img.shields.io/badge/python-3.11-blue)
![Status](https://img.shields.io/pypi/status/movie-barcodes.svg)
![Codecov](https://codecov.io/gh/Wazzabeee/movie-barcodes/branch/main/graph/badge.svg)
![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)
![Black](https://img.shields.io/badge/code%20style-black-000000.svg)

# Overview

Compress every frame of a movie in a single color barcode.

This project is a robust and highly configurable utility designed to extract dominant colors from video files and generate color barcodes. Built with Python and OpenCV, the tool offers multiple algorithms for color extraction, including average color, K-means clustering, and HSV/BGR histograms. The output can be generated in various forms, like horizontal and circular barcodes, providing a visually intuitive summary of the color distribution in the video.

Designed with performance in mind, the application supports both sequential and parallel processing. It scales automatically based on the available CPU cores but can be fine-tuned for a specified number of workers. This makes it suitable for analyzing both short clips and full-length movies with high efficiency.

# Features
- Horizontal and Circular Barcodes
- Fast frame skipping for efficiency.
- Supports `.mp4` & `.webm` files
- Multiprocessing support for parallel processing.
- Customizable color extraction function (Average or K-means).
- Progress tracking and estimated time remaining.

# Usage
```bash
# Install the package
$ pip install movie-barcodes

# Generate a movie barcode
$ movie-barcodes -i "path/to/video.mp4"
```

***Mandatory Arguments:***
- `-i`, `--input_video_path`: The path to the input video file. (Required, type: str)

***Optional Arguments:***
- `-d`, `--destination_path`: The path where the output image will be saved. If not provided, defaults to a pre-defined location. (Optional, type: str)

- `-t`, `--barcode_type`: The type of barcode to generate. Options are horizontal or circular. Default is horizontal. (Optional, type: str)

- `-m`, `--method`: The algorithm for extracting the dominant color from frames. Options are avg (average), kmeans (K-Means clustering), hsv (HSV histogram), and bgr (BGR histogram). Default is avg. (Optional, type: str)

- `-w`, `--workers`: Number of parallel workers for processing. By default, the script will use all available CPU cores. Setting this to 1 will use sequential processing. (Optional, type: int)

- `--width`: The output image's width in pixels. If not specified, the width will be the same as the input video. (Optional, type: int)

- `-n`, `--output_name`: Custom name for the output barcode image. If not provided, a name will be automatically generated. (Optional, type: str)

- `-a`, `--all_methods`: If set to True, all methods for color extraction will be employed, overriding the --method argument. Default is False. (Optional, type: bool)

# Examples
## Sequential Processing
```python
python -m src.main -i "path/to/video" --width 200 -w 1
```
## Parallel Processing
```python
python -m src.main -i "path/to/video" --width 200 -w 8
```

# Development Setup
```bash
# Clone this repository
$ git clone https://github.com/Wazzabeee/movie-barcodes

# Go into the repository
$ cd movie-barcodes

# Install requirements
$ pip install -r requirements.txt
$ pip install -r requirements_lint.txt

# Install precommit
$ pip install pre-commit
$ pre-commit install

# Run tests
$ pip install pytest
$ pytest tests/

# Run package locally
$ python -m src.main -i "path_to_video.mp4"
```

# Todo

- [ ] Optimize K-means to speed up the process
- [ ] Add a small GUI with all options available
- [ ] Add option to modify the barcode's height (current is frame's height)
- [ ] Ensure the software can handle various video formats beyond MP4
- [ ] Allow the software to process multiple videos at once
- [ ] Develop POC on Hugging Face Space
- [ ] Remove the logs creation when using package

# More Examples
## Your Name / Kimi no Na wa / 君の名は (2016) - Makoto Shinkai
```python
movie-barcodes -i "Your Name.mp4" -t "circular"
movie-barcodes -i "Your Name.mp4" --width 1920 -t "horizontal"
```
Circular Barcode           |  Horizontal Barcode
:-------------------------:|:-------------------------:
![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/your_name_avg_circular.png)  |  ![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/your_name_avg_horizontal.png)
## Drive (2011) - Nicolas Winding Refn
```python
movie-barcodes -i "Drive.mp4" -t "circular"
movie-barcodes -i "Drive.mp4" --width 1920 -t "horizontal"
```
Circular Barcode           |  Horizontal Barcode
:-------------------------:|:-------------------------:
![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/drive_avg_circular.png)  |  ![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/drive_avg_horizontal.png)



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/Wazzabeee/movie-barcodes",
    "name": "movie-barcodes",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "visualization, python, opencv, color extraction, data science, machine learning, movies, computer vision, multiprocessing, parallel computing, barcode, image processing, multithreading, data visualization, video processing, color barcode",
    "author": "Cl\u00e9ment Delteil",
    "author_email": "clement45.delteil45@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/33/5b/c7077dd26fe19415e99caa8fc5fdbda3127001c160a2fb74378bd4a5f464/movie-barcodes-0.2.0.tar.gz",
    "platform": null,
    "description": "# Movie Barcodes\nThe Lodger: A Story of the London Fog (1927) - Alfred Hitchcock - [Public Domain](https://archive.org/details/TheLodgerAStoryOfTheLondonFog_579)\n\nCircular Barcode           |  Horizontal Barcode\n:-------------------------:|:-------------------------:\n![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/thelodgerastoryofthelondonfog_circular.png)  |  ![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/thelodgerastoryofthelondonfog_horizontal.png)\n\n![PyPI - Version](https://img.shields.io/pypi/v/movie-barcodes)\n![PyPI - License](https://img.shields.io/pypi/l/movie-barcodes)\n![Python](https://img.shields.io/badge/python-3.11-blue)\n![Status](https://img.shields.io/pypi/status/movie-barcodes.svg)\n![Codecov](https://codecov.io/gh/Wazzabeee/movie-barcodes/branch/main/graph/badge.svg)\n![pre-commit](https://img.shields.io/badge/pre--commit-enabled-brightgreen?logo=pre-commit&logoColor=white)\n![Black](https://img.shields.io/badge/code%20style-black-000000.svg)\n\n# Overview\n\nCompress every frame of a movie in a single color barcode.\n\nThis project is a robust and highly configurable utility designed to extract dominant colors from video files and generate color barcodes. Built with Python and OpenCV, the tool offers multiple algorithms for color extraction, including average color, K-means clustering, and HSV/BGR histograms. The output can be generated in various forms, like horizontal and circular barcodes, providing a visually intuitive summary of the color distribution in the video.\n\nDesigned with performance in mind, the application supports both sequential and parallel processing. It scales automatically based on the available CPU cores but can be fine-tuned for a specified number of workers. This makes it suitable for analyzing both short clips and full-length movies with high efficiency.\n\n# Features\n- Horizontal and Circular Barcodes\n- Fast frame skipping for efficiency.\n- Supports `.mp4` & `.webm` files\n- Multiprocessing support for parallel processing.\n- Customizable color extraction function (Average or K-means).\n- Progress tracking and estimated time remaining.\n\n# Usage\n```bash\n# Install the package\n$ pip install movie-barcodes\n\n# Generate a movie barcode\n$ movie-barcodes -i \"path/to/video.mp4\"\n```\n\n***Mandatory Arguments:***\n- `-i`, `--input_video_path`: The path to the input video file. (Required, type: str)\n\n***Optional Arguments:***\n- `-d`, `--destination_path`: The path where the output image will be saved. If not provided, defaults to a pre-defined location. (Optional, type: str)\n\n- `-t`, `--barcode_type`: The type of barcode to generate. Options are horizontal or circular. Default is horizontal. (Optional, type: str)\n\n- `-m`, `--method`: The algorithm for extracting the dominant color from frames. Options are avg (average), kmeans (K-Means clustering), hsv (HSV histogram), and bgr (BGR histogram). Default is avg. (Optional, type: str)\n\n- `-w`, `--workers`: Number of parallel workers for processing. By default, the script will use all available CPU cores. Setting this to 1 will use sequential processing. (Optional, type: int)\n\n- `--width`: The output image's width in pixels. If not specified, the width will be the same as the input video. (Optional, type: int)\n\n- `-n`, `--output_name`: Custom name for the output barcode image. If not provided, a name will be automatically generated. (Optional, type: str)\n\n- `-a`, `--all_methods`: If set to True, all methods for color extraction will be employed, overriding the --method argument. Default is False. (Optional, type: bool)\n\n# Examples\n## Sequential Processing\n```python\npython -m src.main -i \"path/to/video\" --width 200 -w 1\n```\n## Parallel Processing\n```python\npython -m src.main -i \"path/to/video\" --width 200 -w 8\n```\n\n# Development Setup\n```bash\n# Clone this repository\n$ git clone https://github.com/Wazzabeee/movie-barcodes\n\n# Go into the repository\n$ cd movie-barcodes\n\n# Install requirements\n$ pip install -r requirements.txt\n$ pip install -r requirements_lint.txt\n\n# Install precommit\n$ pip install pre-commit\n$ pre-commit install\n\n# Run tests\n$ pip install pytest\n$ pytest tests/\n\n# Run package locally\n$ python -m src.main -i \"path_to_video.mp4\"\n```\n\n# Todo\n\n- [ ] Optimize K-means to speed up the process\n- [ ] Add a small GUI with all options available\n- [ ] Add option to modify the barcode's height (current is frame's height)\n- [ ] Ensure the software can handle various video formats beyond MP4\n- [ ] Allow the software to process multiple videos at once\n- [ ] Develop POC on Hugging Face Space\n- [ ] Remove the logs creation when using package\n\n# More Examples\n## Your Name / Kimi no Na wa / \u541b\u306e\u540d\u306f (2016) - Makoto Shinkai\n```python\nmovie-barcodes -i \"Your Name.mp4\" -t \"circular\"\nmovie-barcodes -i \"Your Name.mp4\" --width 1920 -t \"horizontal\"\n```\nCircular Barcode           |  Horizontal Barcode\n:-------------------------:|:-------------------------:\n![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/your_name_avg_circular.png)  |  ![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/your_name_avg_horizontal.png)\n## Drive (2011) - Nicolas Winding Refn\n```python\nmovie-barcodes -i \"Drive.mp4\" -t \"circular\"\nmovie-barcodes -i \"Drive.mp4\" --width 1920 -t \"horizontal\"\n```\nCircular Barcode           |  Horizontal Barcode\n:-------------------------:|:-------------------------:\n![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/drive_avg_circular.png)  |  ![](https://raw.githubusercontent.com/Wazzabeee/movie_color_barcode/main/examples/drive_avg_horizontal.png)\n\n\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Compress every frame of a movie in a single color barcode.Transform entire movies into stunning single-barcode visualizations.Capture the essence of cinematic storytelling through dominant color extraction from each frame.",
    "version": "0.2.0",
    "project_urls": {
        "Homepage": "https://github.com/Wazzabeee/movie-barcodes"
    },
    "split_keywords": [
        "visualization",
        " python",
        " opencv",
        " color extraction",
        " data science",
        " machine learning",
        " movies",
        " computer vision",
        " multiprocessing",
        " parallel computing",
        " barcode",
        " image processing",
        " multithreading",
        " data visualization",
        " video processing",
        " color barcode"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "fd0b3677e70fb809b4aa64f955bb639c3b8adacd3ff6766992c42ac65872728e",
                "md5": "3c8a7bd3f1e2e548a286e14e52def7c1",
                "sha256": "18a5a827ce6287a969130423fa13087f6041d28bbab2dfdd7ad2a4da4a2d2a8e"
            },
            "downloads": -1,
            "filename": "movie_barcodes-0.2.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3c8a7bd3f1e2e548a286e14e52def7c1",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.10",
            "size": 26500,
            "upload_time": "2024-05-11T11:59:17",
            "upload_time_iso_8601": "2024-05-11T11:59:17.957425Z",
            "url": "https://files.pythonhosted.org/packages/fd/0b/3677e70fb809b4aa64f955bb639c3b8adacd3ff6766992c42ac65872728e/movie_barcodes-0.2.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "335bc7077dd26fe19415e99caa8fc5fdbda3127001c160a2fb74378bd4a5f464",
                "md5": "827376911666c6c0f516f2c81ff50402",
                "sha256": "f783821405e7de317299b05ad340e3eae0fcb7b00e06da3f876eb4e7a3f82963"
            },
            "downloads": -1,
            "filename": "movie-barcodes-0.2.0.tar.gz",
            "has_sig": false,
            "md5_digest": "827376911666c6c0f516f2c81ff50402",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 22418,
            "upload_time": "2024-05-11T11:59:19",
            "upload_time_iso_8601": "2024-05-11T11:59:19.215066Z",
            "url": "https://files.pythonhosted.org/packages/33/5b/c7077dd26fe19415e99caa8fc5fdbda3127001c160a2fb74378bd4a5f464/movie-barcodes-0.2.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-05-11 11:59:19",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Wazzabeee",
    "github_project": "movie-barcodes",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "requirements": [],
    "lcname": "movie-barcodes"
}
        
Elapsed time: 0.25101s