Skip to main content

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: Example_sw9_trailer_kmeans

Rgb: Example_sw9_trailer_rgb

Rgbsquared: Example_sw9_trailer_rgbsquared

Lab: Example_sw9_trailer_lab


Made with ♥︎ by fsoubelet
MIT © 2019 Felix Soubelet

Metadata

Release files for movie-colorbar 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for movie-colorbar 0.3.0
File Size Uploaded
movie_colorbar-0.3.0.tar.gz 121.4 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for movie-colorbar 0.3.0
File Interpreter ABI Platform
movie_colorbar-0.3.0-py3-none-any.whl Python 3 none any Details

Total release size: 138.1 kB

Release files / movie_colorbar-0.3.0.tar.gz

Download URL movie_colorbar-0.3.0.tar.gz
Size 121.4 kB
Tags Source
SHA-256 checksum
How to use checksums
dd72a113946a8387d8e74d9802ace56ae83e669a05b4b22a2bbcd065cbe49c43
BLAKE2b-256 checksum
How to use checksums
5dc45dd042edd31a1c76c0795a635d0ac35339c065021b679d5d710d38162722
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release files / movie_colorbar-0.3.0-py3-none-any.whl

Download URL movie_colorbar-0.3.0-py3-none-any.whl
Size 16.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ce5dc1db98350d92d500b3a12d670ee70008dc773e6318c6f09537ce352995af
BLAKE2b-256 checksum
How to use checksums
9365a509be14710e99aaaef199ff4b313732e169b5c6a442fe98e995f8d720d1
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.1.0 CPython/3.13.1

Release history Release notifications | RSS feed

This release

0.3.0 This release

2 release files

0.2.2

2 release files

0.2.1

2 release files

0.2.0

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page