This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Turn a piano MIDI file into a basic 3D animated piano video. | |
See the result here: | |
I am leaving it as a script because it is not tested on enough MIDI files yet. | |
Zulko 2014 | |
This script is released under a Public Domain (Creative Commons 0) licence. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# | |
# This Python script makes a summary of a football game by cutting | |
# the video around the 10 % loudest moments, which generally | |
# include the goals and other important events. | |
# For more details, see this blog post: | |
# http://zulko.github.io/blog/2014/07/04/automatic-soccer-highlights-compilations-with-python/ | |
# | |
# LICENCE: Creative Commons 0 - Public Domain | |
# I, the author of this script, wave any rights and place this work in the public domain. | |
# |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
An alternative text clip for Moviepy, relying on Gizeh instead of ImageMagick | |
Advantages: | |
- Super fast (20x faster) | |
- no need to install imagemagick | |
- full-vector graphic, no aliasing problems | |
- Easier font names | |
Disadvantages: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
Physics simulation with PyODE followed by a (basic) rendering with Vapory | |
See the result here: http://i.imgur.com/TdhxwGz.gifv | |
Zulko 2014 | |
This script is placed in the Public Domain (Licence Creative Commons 0) | |
""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import inspect | |
def class_name(cls): | |
"""Return a string representing the class""" | |
# NOTE: can be changed to str(class) for more complete class info | |
return cls.__name__ | |
def classes_tree(module, base_module=None): | |
if base_module is None: | |
base_module == module.__name__ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# This is a function to merge several nodes into one in a Networkx graph | |
def merge_nodes(G,nodes, new_node, attr_dict=None, **attr): | |
""" | |
Merges the selected `nodes` of the graph G into one `new_node`, | |
meaning that all the edges that pointed to or from one of these | |
`nodes` will point to or from the `new_node`. | |
attr_dict and **attr are defined as in `G.add_node`. | |
""" | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
This creates the following GIF, where the text appears to be "embedded" | |
in the video and "disappears" behind rapunzel. | |
http://i.imgur.com/gxEHfLX.gif | |
""" | |
from moviepy.editor import * | |
import numpy as np | |
import skimage.morphology as skm |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# Taken from http://zulko.github.io/blog/2015/02/01/extracting-perfectly-looping-gifs-from-videos-with-python-and-moviepy/ | |
import os | |
import sys | |
import moviepy.editor as mp | |
from moviepy.video.tools.cuts import FramesMatches | |
if len(sys.argv) != 2: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import numpy as np | |
def supersample(clip, d, nframes): | |
""" Replaces each frame at time t by the mean of `nframes` equally spaced frames | |
taken in the interval [t-d, t+d]. This results in motion blur.""" | |
def fl(gf, t): | |
tt = np.linspace(t-d, t+d, nframes) | |
avg = np.mean(1.0*np.array([gf(t_) for t_ in tt]),axis=0) | |
return avg.astype("uint8") | |
return clip.fl(fl) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from moviepy.editor import * | |
from moviepy import * | |
video = VideoFileClip(r"[MYFILE]").subclip(50,60) | |
# Make the text. Many more options are available. | |
txt_clip = ( TextClip("My Holidays 2013",fontsize=70,color='white') | |
.set_position('center') | |
.set_duration(10) ) |
NewerOlder