Cinemetrica is a Python module with useful tools for the statistical analysis of movies
With AI/ML entering the film industry the first computer generated feature film might not be so far away. Whilist movie script generation has already produced some comic, yet interesting, results (Have a look at Scraps of Mechanical Souls and Sunspring), for computers to be able to produce a movie will require the development not only of AI-screenwriters, but also AI directors, cinematographers, editors, sound designers and, the biggest feat of all, AI actors. Such accomplishment will be possible only by establishing first a thorough framework of tools for the statistical analysis of film and the generation of detailed and robust datasets that go well beyond reviews and metadata. Cinemetrica is an attempt to do just that.
- Detect shots;
- Extract frames from shots;
- Get shot length and other statistics (mean lenght, shortest/longest shots, standard deviation, etc)
- Generate a color palette from extracted frames;
In the near future you will be able to:
- Generate fancy infographics from extracted data;
- Export graphs;
- Detect cut types;
- Detect movie shot types (currently you can use shot-type-classifier);
- Detect actors.
Cinemetrica requires PySceneDetect, colorgram.py, opencv, PIL and tqdm to run.
Description | |
---|---|
shot_list |
List containing all the shots detected as tuples of (start, end) FrameTimecodes (loot at PySceneDetect documentation for FrameTimecodes objects. |
Function | Description |
---|---|
shot_detector(video_path) |
Returns a shot_list video_path : path .mp4 /.mkv file. |
get_shot_frames(video_path, image_format, quality, scale) |
Extracts one frame per shot detected. Images are stored in FRAMES folder. video_path : path .mp4 /.mkv ; image_format : .jpg or .png ;quality : from 1 to 100 ; scale : downscale factor. |
list_convert(shot_list, has_id) |
Returns a list of tuples (shot_number, shot_duration(s)) if has_id = true, else returns a list of shot_duration(s) |
mean_shot_length(shot_list) |
Returns the tuple (mean shot length, standard deviation) . |
longest_n_shots(shot_list, n) |
Returns the last n longest shots in ascending order as tuples (shot_number, duration) . |
shortest_n_shots(shot_list, n) |
Returns the last n shortest shots in ascending order as tuples (shot_number, duration) . |
palette(path, n, width, height, id) |
Generates a n -color palette from any image stored in path folder. Palette images are store in PALETTE folder. width, height refer to the dimensions of the palette image. |
Apache 2.0
Free Software, Hell Yeah!