After getting inspired by a blog post about using Voronoi tesselation to get interesting visual effects and another blog post on onset detection and video synthesis with Python, I decided to combine both for a music video of the band I’m playing in, kiriloff. Here it is:
MoviePy is used for its video editing functions that can be used in Python. Using aubio, it’s possible to detect when notes are played (onset detection). Input video clips then get the special “spider web effect” by constructing Voronoi diagrams according to the detected onsets and their amplitude. For this, I convert the input video frame to a binary image and sample some of the white pixels while the sample size is dependent on the onset amplitude (hence more pixels are sampled in the louder parts). With NumPy’s where function the coordinates of the sampled pixels are found out and those coordinates are used to construct a Voronoi diagram using SciPy. The resulting lines are rendered and MoviePy writes it to the video file.
For more details, see the project page and the github repository.