Skip to content

alebcay/vid2xlsx

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 

Repository files navigation

vid2xlsx

Convert videos into Excel spreadsheets

Example Image

Requirements

  • Python 3.6+
  • NumPy
  • Loguru
  • imutils
  • OpenCV
  • xlsxwriter
  • scikit-learn

Usage

vid2xlsx.py -i <path to video file> -o <path to xlsx destination> -f <frames> -c <colors> [-v] [-d]

Arguments accepted:

  • -i | --input: Path to input video flie. Can be any format readable by OpenCV.
  • -o | --output: Path to output xlsx file. Must end in .xlsx extension
  • -f | --frames: How often a frame should be generated. -f 1 will render every frame, -f 2 will render every other frame, -f 3 will render every third frame, etc.
  • -c | --colors: Number of colors to quantize each frame to
  • -v | --verbose: Shows verbose/detailed information
  • -d | --debug: Shows debug/diagnostic information used for development/troubleshooting

Limitations

An Excel workbook can only contain up to 64000 styles. Considering that each pixel can take up to 2563≈16 million colors, this program performs color quantization (via k-means clustering) to limit the number of colors used in each frame. Consecutive frames often share many colors in common, so only one cell format style object is created for each unique color identified between all frames (i.e. every style created represents a unique style).

The amount of clusters to quantize colors to can be configured with the -c | --colors flag. For example, with a video 2319 frames in length that has every third frame rendered (-f 3), using a setting of -c 64 will generate up to 64 colors per frame rendered, for a maximum of 49280 colors used.

Note that -c 128 will generate up to 98944 colors in total in this case, but in reality, the actual number of colors generated will not be close to this theoretical maximum. This is because contiguous/adjacent cells often share the same color and consecutive frames also likely share many colors. The number used with -c does not necessarily have to be a power of 2; the values of 64 and 128 are provided here for demonstration purposes.

Thus, increasing -c (increasing number of colors) or decreasing -f (rendering frames more often) is likely going to increase the number of colors required. However, the increase should be less than linear, because increasing the number of colors per frame increases the likelihood that adjacent cells/frames can reuse colors, and interstitial frames generated by rendering frames more often likely share colors with other frames as well.

Features roadmap/future planned features

  • Automatically optimize/maximize the number of colors to use given an -f value

About

Convert videos into Excel spreadsheets - inspired by https://www.youtube.com/watch?v=7kbgOX9NRNI

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages