Skip to content

Instantly share code, notes, and snippets.

@Zulko
Zulko / moviepy_time_accuracy.py
Created November 13, 2014 15:55
Checking MoviePy's time accuracy
"""
This script checks the time accuracy of MoviePy.
First, a one-hour video is generated, where the frame
at time t displays t (in seconds, e.g. '1200.50') in white
on a black baground.
Then we ask MoviePy to open this video file, fetch
different times (1200.5, 850.2, 2000.3, 150.25, 150.25),
extract the corresponding frame as a JPEG image file, and
@Zulko
Zulko / cubes_pyode_vapory.py
Last active December 27, 2023 12:29
3D cubes animation with PyODE and Vapory
"""
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)
"""
@Zulko
Zulko / 3D_piano_from_midi.py
Last active April 9, 2024 05:51
Turn a piano MIDI file into a basic 3D animated piano video.
"""
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.
@Zulko
Zulko / animated_brain.py
Last active August 14, 2019 09:37
Animated brain (Vispy) turned into a video/GIF (MoviePy)
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# vispy: gallery 2
# Copyright (c) 2014, Vispy Development Team.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
#
# Modified for animation with MoviePy by Zulko
# See result here: http://i.imgur.com/sSCBkFd.gif
#
@Zulko
Zulko / animated_atom.py
Last active June 23, 2020 04:23
Animated atom (Vispy) turned into a video/GIF (MoviePy)
# -*- coding: utf-8 -*-
# vispy: gallery 30
# -----------------------------------------------------------------------------
# Copyright (c) 2014, Vispy Development Team. All Rights Reserved.
# Distributed under the (new) BSD License. See LICENSE.txt for more info.
# -----------------------------------------------------------------------------
# Author: Nicolas P .Rougier
# Date: 06/03/2014
# Abstract: Fake electrons orbiting
# Keywords: Sprites, atom, particles
@Zulko
Zulko / bacterial_growth_animation.py
Last active December 15, 2020 17:36
Growing bacteria with population size analysis (Matplotlib/MoviePy)
"""
This script produces a video analysis proving for the first time in history
that bacterial populations grow exponentially. See the result here:
http://i.imgur.com/uoITKiA.gif
We proceed as follows:
- Download a video of bacteria growing under a microscope.
- Cut the video to keep only the first 7 seconds.
- Threshold each frame to find where the bacteria are, and compute the
@Zulko
Zulko / zombie_france.py
Last active May 22, 2024 22:21
Zombie pandemic simulation in France
"""
Model of a Zombie outbreak in France, starting in Grenoble
This is a rewrite from this blog post by Max Berrgren:
http://maxberggren.github.io/2014/11/27/model-of-a-zombie-outbreak/
with a different country, a slightly different model, and different
libraries. The map of population density is taken from Wikimedia Commons
@Zulko
Zulko / conformal_falling.py
Last active August 29, 2015 14:10
Animation with complex tranformation 1/Z - t
"""
Conformal animations with MoviePy and Scikit Image, after user u/spel3o on Reddit.
Links:
Reddit discussion:
http://www.reddit.com/r/math/comments/2o9wge/conformal_image_map_animation_of_1z_to/
Original gif:
https://i.imgur.com/2W5dCvF.gif
"""
Animation of a head slicing.
Based on a BSD-like licenced code by Gael Varoquaux
http://docs.enthought.com/mayavi/mayavi/auto/example_mri.html
Result:
http://i.imgur.com/EJZELfi.gif
"""
@Zulko
Zulko / awkward.py
Last active August 16, 2022 02:32
Awkward date gif code
# Code for this GIF:
# http://imgur.com/gallery/pTypr1Y
# This demonstrates how to freeze a region with MoviePy
from moviepy.editor import *
clip = (VideoFileClip("the_fault_in_our_stars.mp4")
.subclip("00:59:48.4","00:59:49.6")
.resize(width=600)