Skip to main content

Turn a video into a colorbar

Project description

movie_colorbar

A simple script to turn a video into a colorbar.

Install

Prerequisites

This code is compatible with all currently supported Python versions, and requires that you have ffmpgeg installed in your path. You can install it in your virtual enrivonment with:

python -m pip install movie_colorbar

Usage

With this package is installed in the activated enrivonment, it can be called through python -m movie_colorbar or through a newly created colorbar command.

Detailed usage goes as follows:

 Usage: python -m movie_colorbar [OPTIONS] [SOURCE_PATH]                                      
                                                                                              
 Turn a video into a colorbar.                                                                
                                                                                              
╭─ Arguments ────────────────────────────────────────────────────────────────────────────────╮
│   source_path      [SOURCE_PATH]  Location, relative or absolute, of the source video file │
│                                   to get the images from.                                  │
│                                   [default: .]                                             │
╰────────────────────────────────────────────────────────────────────────────────────────────╯
╭─ Options ──────────────────────────────────────────────────────────────────────────────────╮
│ --title                     TEXT     Name that will be given to the output directory.      │
│                                      [default: output]                                     │
│ --method                    TEXT     Method used to calculate the average color. Options   │
│                                      are: 'rgb', 'hsv', 'hue', 'kmeans', 'common', 'lab',  │
│                                      'xyz', 'rgbsquared', 'resize' and 'quantized'.        │
│                                      [default: rgbsquared]                                 │
│ --fps                       INTEGER  Number of frames to extract per second of video       │
│                                      footage.                                              │
│                                      [default: 10]                                         │
│ --log-level                 TEXT     The base console logging level. Can be 'debug',       │
│                                      'info', 'warning' and 'error'.                        │
│                                      [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.                           │
╰────────────────────────────────────────────────────────────────────────────────────────────╯

An example command is then:

python -m movie_colorbar ~/Desktop/STARWARS_9_TRAILER.webm --title sw9_trailer --method rgbsquared --fps 25

The script will call ffmpeg to extract 25 (in this case) images per second from the video file. It will then apply the chosen method - here rgbsquared - to determine the average color of each frame. Finally, it creates the colorbar with all averages and saves it in a new folder titled bars/title, with title being the argument you provided. The final output's name is a concatenation of the provided file, and of the method used. Giving a directory as input will process all video files found in this directory.

It is recommended to decrease the fps when processing long videos such as entire movies.

TODO

  • Delete the images folder after completion.
  • Turn into a package.
  • Improving the command line experience.
  • Offer an option to do all at the same time.

Output example

Here is an example of what the script outputs, when ran on the last Star Wars 9 trailer. All methods output can be found in the bars folder of this repository.

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

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

movie_colorbar-0.2.2.tar.gz (93.1 kB view hashes)

Uploaded Source

Built Distribution

movie_colorbar-0.2.2-py3-none-any.whl (10.3 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page