Python program to generate a movie "barcode", or a visualization of the colour palette used in a film. It is generated by compressing each frame into a single column of pixels that are stacked sequentially to form a barcode-like image. Makes for a neat wallpaper.
There are many implementations available, and I don't claim this is the best, but it's clean, simple, efficient, and easily-customizable. Automatically adjusts sample rate according to the length of the video. Runs in under 2 minutes for a typical 2 hour movie.
Supported on Python 3 and OpenCV 3+. Tested on macOS.
- OpenCV
- numpy
The Lord of the Rings: The Fellowship of the Ring

python barcode.py -video <PATH_TO_VIDEO> [-u]
-video: The path to the movie to be processed. Only tested on.mp4files, but should work with any format supported by OpenCV.-u: Optional flag to compress all frames into a single color, thus producing uniform columns.
There are some constants defined in the code that can be changed if desired.
- Set
OUT_WIDTHandOUT_HEIGHTto the desired output dimensions. - Set
SAMPLE_HEIGHTto change the granularity of the columns.SAMPLE_HEIGHTshould be at most the input video height and at least 1 (which is equivalent to using the-uflag). This is a matter of personal preference; larger values preserve more detail while smaller values yield smoother results. - Tip: use low-resolution videos. It won't effect the result at all and it will run much faster.






