This repository contains the sample code for the blog-post Video Generation with Python using Python’s MoviePy, SciPy and ImageMagick libraries. If you are looking for the original sample code that uses Python’s MoviePy and Gizeh libraries you can find it in its own repository.
To build and run this sample follow the instructions below to install requirements and set-up your python environment with pipenv.
ImageMagick is required to run python_video.py for creating Moviepy TextClips.
You can download the source binaries in the download page and follow your development environment section to install from source. Otherwise, you can use a system package manager for the desired OS as follows.
To verify ImageMagick installation you can run the following command that will create a gif file.
$ convert logo: logo.gifYour distribution may already have installed ImageMagick. But in case its not, type:
$ sudo apt install imagemagickUsing Homebrew which provides pre-built binaries for Mac, type:
$ brew install imagemagickImageMagick depends on Ghostscript fonts. To install them, type:
$ brew install ghostscriptThe Windows version of ImageMagick is self-installing. Simply go to the download page to get a version that will launch itself and ask a few installation questions.
Using version manager asdf-vm.
Install Python Plugin:
$ asdf plugin-add python https://github.com/danhper/asdf-python.gitPython version is specified in .tools-versions file.
$ asdf installNote: This can be installed using package managers as well, the instruction may vary according to your package manager:
- In Ubuntu:
sudo apt-get install python3- In OSx:
brew install python3Using package manager Chocolatey:
C:\> choco install python3If not installed yet, run from the root of the project to install pipenv:
$ pip install --user pipenvFrom root project directory run:
$ pipenv installFrom root project folder, enable virtual env typing:
pipenv shellInstall required library for Moviepy
brew install ffmpegWith pipenv virtualenv enabled and from the root project folder run:
python python_video.pyNote: It's possible to execute the script directly with pipenv using:
pipenv run python python_video.pyTo Disable it type exit
If you encounter errors when linking ImageMagick binaries like in this known issue 693, it does not have the proper permission set.
Check for the ImageMagick policy file at
/etc/ImageMagick-6/policy.xml and comment out (or remove the line that reads)
<policy domain="path" rights="none" pattern="@*" />
<!-- <policy domain="path" rights="none" pattern="@*" /> -->