Animation engine for explanatory math videos
Switch branches/tags
Clone or download
eulertour Remove creating media/ from instructions
After #365 the media directory is automatically created, so the instructions can be simplified.
Latest commit 465951a Dec 10, 2018
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.github Change a word Dec 5, 2018
active_projects Retire borsuk_addition to old_projects Nov 18, 2018
animation Fix the idle_stream()'s sleep duration and change the stream FPS to 30 Nov 3, 2018
camera Fixed frame_center bug Oct 6, 2018
container Added simple TODO May 9, 2018
continual_animation ContinualUpdateFromFunc -> ContinualUpdate Aug 13, 2018
files Added various svg files to files directory (not usually where they li… Jan 12, 2018
for_3b1b_videos revised fallback to plain pi creature, revise some latex, make once_u… Dec 1, 2018
mobject scale SVGMobject about origin Dec 5, 2018
old_projects revised fallback to plain pi creature, revise some latex, make once_u… Dec 1, 2018
once_useful_constructs revised fallback to plain pi creature, revise some latex, make once_u… Dec 1, 2018
scene Merge pull request #336 from mertyildiran/master Nov 18, 2018
utils Merge branch 'master' into pr Nov 18, 2018
.gitignore ContinualUpdateFromFunc -> ContinualUpdate Aug 13, 2018
.travis.yml pip install --upgrade pip Sep 24, 2018
Dockerfile Removed vim from default Dockerfile after discussion with Devin Neal, Oct 4, 2018
LICENSE Create LICENSE Mar 30, 2018
README.md Remove creating media/ from instructions Dec 11, 2018
__init__.py Name animation script Apr 13, 2018
big_ol_pile_of_manim_imports.py First few animations of shadows project Oct 6, 2018
constants.py replace exists() with isfile() and isdir() Dec 11, 2018
ctex_template.tex Add support for ctex Sep 26, 2018
example.png After running 2to3 Aug 10, 2018
example_scenes.py Updated example scenes Aug 13, 2018
extract_scene.py Renamed ANIMATION_DIR to VIDEO_DIR, also replacing 'animations' with … Oct 30, 2018
manim.py Fix the idle_stream()'s sleep duration and change the stream FPS to 30 Nov 3, 2018
requirements.txt Reimplented svg rendering using cairo, and changed vmobject color mod… Aug 10, 2018
stage_scenes.py After running 2to3 Aug 10, 2018
stream_starter.py Add a stream lock and an idle state for stream to provide continuous … Nov 1, 2018
tex_template.tex Reduced to a single tex_template file Aug 13, 2018

README.md

Manim - Mathematical Animation Engine

Documentation Status MIT License

Manim is an animation engine for explanatory math videos. It's used to create precise animations programmatically.

Installation

Manim runs on python 3.7. You can install the python requirements with pip install -r requirements.txt. System requirements are cairo, latex, ffmpeg, and sox.

Directly

git clone https://github.com/3b1b/manim.git
cd manim
pip install -r requirements.txt
python3 extract_scene.py example_scenes.py SquareToCircle -pl

Using virtualenv and virtualenvwrapper

After installing virtualenv and virtualenvwrapper

git clone https://github.com/3b1b/manim.git
mkvirtualenv -a manim -r requirements.txt manim
python3 extract_scene.py example_scenes.py SquareToCircle -pl

Using Docker

Since it's a bit tricky to get all the dependencies set up just right, there is a Dockerfile provided in this repo as well as a premade image on Docker Hub.

The image does not contain a copy of the repo. This is intentional, as it allows you to either bind mount a repo that you've cloned locally or clone any fork/branch you want. Since test coverage is painfully lacking, the image may not have dependencies for all of manim.

  1. Install Docker
  2. Get the docker image
  • Pull it (recommended): docker pull eulertour/manim:latest, or
  • Build it: docker build -t manim .
  1. Start the image
  • Bind mount a local repo (recommended): docker run -itv /absolute/path/to/your/local/manim/repo:/root/manim eulertour/manim or
  • Clone a remote repo: docker run -it eulertour/manim, then git clone https://github.com/eulertour/manim.git
  1. Render an animation
cd manim
python3 extract_scene.py example_scenes.py SquareToCircle -l

Note that the image doesn't have any development tools installed and can't preview animations. Its purpose is building and testing only.

Using manim

Try running the following:

python3 extract_scene.py example_scenes.py SquareToCircle -pl

The -p is for previewing, meaning the the video file will automatically open when it is done rendering. Use -l for a faster rendering at a lower quality. Use -s to skip to the end and just show the final frame. Use -n (number) to skip ahead to the n'th animation of a scene. Use -f to show the file in finder (for osx)

Set MEDIA_DIR environment variable to determine where image and animation files will be written.

Look through the old_projects folder to see the code for previous 3b1b videos. Note, however, that developments are often made to the library without considering backwards compatibility on those old_projects. To run them with a guarantee that they will work, you will have to go back to the commit which complete that project.

While developing a scene, the -s flag is helpful to just see what things look like at the end without having to generate the full animation. It can also be helpful to use the -n flag to skip over some number of animations.

Documentation

Documentation is in progress at manim.readthedocs.io.

(Outdated) Walkthrough

Todd Zimmerman put together a tutorial on getting started with manim, but it uses an outdated version that runs on python 2.7. It may not be fully compatible with the current version of manim, but it does a good job laying out the basics.

Live Streaming

To live stream your animations, simply assign IS_LIVE_STREAMING = True in constants.py file and from your Python Interactive Shell (python3) import the stream starter with from stream_starter import * while under the project directory. This will provide a clean interactive shell to enter your commands. manim object is a Manim() instance so as soon as you play an animation with manim.play() your stream will start. A video player will pop-up and you can broadcast that video using OBS Studio which is the most practical way of streaming with this math animation library. An example:

>>> from stream_starter import *
YOUR STREAM IS READY!
>>> circle = Circle()
>>> manim.play(ShowCreation(circle))
Animation 0: ShowCreationCircle: 100%|███████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 60/60 [00:01<00:00, 37.30it/s]
<scene.scene.Scene object at 0x7f0756d5a8d0>

It is also possible to stream directly to Twitch. To do that simply assign IS_STREAMING_TO_TWITCH = True in constants.py file and put your Twitch Stream Key to TWITCH_STREAM_KEY = "YOUR_STREAM_KEY" and when you follow the above example the stream will directly start on your Twitch channel(with no audio support).

Contributing

Is always welcome. In particular, there is a dire need for tests and documentation.

License

All files in the directories active_projects and old_projects, which by and large generate the visuals for 3b1b videos, are copyright 3Blue1Brown.

The general purpose animation code found in the remainder of the repository, on the other hand, is under the MIT license.