Turn a video into a colorbar
Project description
movie_colorbar
A command line tool to create colorbars from videos.
Install
The package requires Python 3.10+ versions, and to have have ffmpgeg installed in your path.
One can install from PyPI in a virtual enrivonment with:
python -m pip install movie_colorbar
As a uv tool
The package also supports being installed as a tool with uv:
uv tool install movie_colorbar
Speedups
If the joblib and/or numba packages are available in the environment, they will be used to speed up the processing of video frames and color calculations.
This can lead to drastic speedups when extracting a high number of images (by processing long videos or simply setting a high fps option value).
One can install these along with the package via the fast extra dependency group:
python -m pip install movie_colorbar[fast]
As a uv tool
uv tool install movie_colorbar[fast]
Usage
Once installed, the package generates two executables (colorbar and movie_colorbar) to be called from the command line.
It can also be called directly through python or via the uv tool interface.
Full command line interface
Detailed usage goes as follows:
Usage: python -m movie_colorbar [OPTIONS] INPUT OUTPUT
Command line tool to create colorbars from videos.
From the input video individual frames are extracted with ffmpeg and written to disk in a directory placed next to the final output
and named after the video. Each frame is reduced to a single color according to the chosen method. Finally a colorbar is created
from these determined colors, and written to disk as an image file at the provided output location. By default the extracted frames
are removed after processing, but they can be kept if desired (see the 'cleanup' option).
Should the input be a directory, then every video file contained within will be processed, provided it is supported by ffmpeg. In
this case the output should also be a directory, in which one colorbar will be created for each video file.
╭─ Arguments ───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ * input PATH Path to the input video file or directory. [required] │
│ * output PATH Path to the output colorbar image or directory. [required] │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ─────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╮
│ --method [common|hsv|hue|kmeans|lab|quantized|resize Method used to calculate the color for each │
│ |rgb|rgbsquared|xyz] frame. │
│ [default: rgb] │
│ --fps INTEGER RANGE [x>=0] Number of frames to extract per second of │
│ video footage. │
│ [default: 10] │
│ --cleanup --no-cleanup Whether to remove the extracted frames after │
│ processing. │
│ [default: cleanup] │
│ --log-level [trace|debug|info|warning|error|critical] The base console logging level. │
│ [default: info] │
│ --install-completion Install completion for the current shell. │
│ --show-completion Show completion for the current shell, to │
│ copy it or customize the installation. │
│ --help Show this message and exit. │
╰───────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────╯
As a uv tool
One can call the tool via the package name with uvx:
uvx movie_colorbar [OPTIONS] INPUT OUTPUT
It is also possible to use the colorbar command alias by specifying the tool to source from:
uvx --from movie_colorbar colorbar [OPTIONS] INPUT OUTPUT
Here is an example command:
python -m movie_colorbar ~/Desktop/STARWARS_9_TRAILER.mkv ~/Desktop/colorbar.png --method rgbsquared --fps 25
One can also provide a directory as input (and must then provide a directory as output), which will process all video files found in this directory.
Note: It is recommended to decrease the fps when processing long videos such as entire movies.
Examples
Here are examples of colorbars produced from the Star Wars 9 trailer.
All these files can be found in the bars folder of this repository.
How to reproduce
The following command was used to generate all the colorbars:
for method in common hsv hue kmeans lab quantized resize rgb rgbsquared xyz; do python -m movie_colorbar ~/Desktop/STARWARS_9_TRAILER.mkv bars/sw9_trailer/SW9_trailer_$method.png --method $method --fps 25; done
Kmeans:
Rgb:
Rgbsquared:
Lab:
MIT © 2019 Felix Soubelet
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
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file movie_colorbar-0.3.0.tar.gz.
File metadata
- Download URL: movie_colorbar-0.3.0.tar.gz
- Upload date:
- Size: 121.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dd72a113946a8387d8e74d9802ace56ae83e669a05b4b22a2bbcd065cbe49c43
|
|
| MD5 |
d350a54152ec1c1b6b338ec132b073f3
|
|
| BLAKE2b-256 |
5dc45dd042edd31a1c76c0795a635d0ac35339c065021b679d5d710d38162722
|
File details
Details for the file movie_colorbar-0.3.0-py3-none-any.whl.
File metadata
- Download URL: movie_colorbar-0.3.0-py3-none-any.whl
- Upload date:
- Size: 16.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ce5dc1db98350d92d500b3a12d670ee70008dc773e6318c6f09537ce352995af
|
|
| MD5 |
409333f10ddf8dcff154983e3ac70ec8
|
|
| BLAKE2b-256 |
9365a509be14710e99aaaef199ff4b313732e169b5c6a442fe98e995f8d720d1
|