Builds an image representing the chromatic identity of a film from the average color of its frames.
Required parameters:
- video file path (obviously)
- resolution: defines the precision of the image to build.
- shapes: defines the shape(s) of the image to build (see example below)
public class Main {
public static void main(String filePath, int resolution) throws IOException {
FilmCapture capture = new FilmCapture(filePath);
ImageBuilder builder = capture.getBuilder(resolution);
builder.setShapers(new DiscShaper(), new BarCodeShaper());
builder.build();
}
}
cd <filedir>
java -jar color-of-film-cli-1.0.0-jar-with-dependencies.jar -fp <filename> -r 1000 --shapes DISC,BARCODE
Batman Begins (2005) - 1080p YIFY, using a resolution of 1000 chunks, both Barcode and Disc shapes, and all the frames of the movie:
Barcode | Disc |
---|---|
![]() |
![]() |
The video file is read using opencv, the video is read frame by frame, for each frame, the mean color value of the frame is calculated using the library.
The conventional framerate of a movie is 24fps (little less actually), so a 1hour movie is composed of about 86400 frames. Building an image of 86400 pixels aside would be way too costly (around 30 GB of RAM).
Therefore, we split the video in chunks, in which we average the color of all the frames, obtaining a chunk color, which
we paint on the image to build.
The number of chunks is the resolution, so for a resolution of 1000, the provided video is split in 1000 chunks, which
output 1000 colors, which are painted as a line on the output image, in the shape required.
The built image is in 32bits, the dimensions are roughly resolution × resolution. During build the image is not compressed, so the space complexity is quadratic. Therefore, if you use too large resolution you will reach heap space. For example, using resolution 25000 with the disc shape would result in a 50001 × 50001 image in 32bits which results in a RAM need of 50001 × 50001 × 4octet = 10 GB
- Versioning: I'm sorry about the git history on this repo, it is quite disastrous, this was my first time using conventional commits, semantic release, and GitHub Actions, so it's quite dirty, but it should be cleaner from now one
I am working on a web app project to handle my collection of downloaded movies and series, you can find it here: The Movie Shelf
This is a personal project for my needs, so it probably won't be interesting for you (I might actually keep it private), but I need to develop some libraries for this main project which might be useful to you: