Animation engine for explanatory math videos
Find a file
2018-11-28 19:33:42 +01:00
active_projects Retire borsuk_addition to old_projects 2018-11-18 10:31:02 -06:00
animation Fix the idle_stream()'s sleep duration and change the stream FPS to 30 2018-11-03 21:05:20 +03:00
camera Fixed frame_center bug 2018-10-05 17:18:21 -07:00
container Added simple TODO 2018-05-09 14:03:53 -07:00
continual_animation ContinualUpdateFromFunc -> ContinualUpdate 2018-08-13 13:40:52 -07:00
files Added various svg files to files directory (not usually where they live) so anyone outisde 3b1b wanting to download the code and try it out won't see it break on all pi creature scenes 2018-01-12 13:39:51 -08:00
for_3b1b_videos Fixes to patron scroll 2018-11-18 10:28:49 -06:00
mobject Mobject.clear_updaters now returns self 2018-11-18 10:29:41 -06:00
old_projects Merge pull request #341 from vavanade/patch-1 2018-11-18 08:33:59 -08:00
once_useful_constructs submobject_family -> get_family 2018-08-21 19:15:16 -07:00
scene Merge pull request #336 from mertyildiran/master 2018-11-18 08:41:35 -08:00
utils Merge branch 'master' into pr 2018-11-18 08:49:04 -08:00
.gitignore ContinualUpdateFromFunc -> ContinualUpdate 2018-08-13 13:40:52 -07:00
.travis.yml pip install --upgrade pip 2018-09-24 08:35:34 +01:00
__init__.py Name animation script 2018-04-12 21:54:30 -07:00
big_ol_pile_of_manim_imports.py First few animations of shadows project 2018-10-05 17:20:03 -07:00
constants.py Merge pull request #336 from mertyildiran/master 2018-11-18 08:41:35 -08:00
ctex_template.tex Add support for ctex 2018-09-26 21:09:04 +08:00
Dockerfile update Dockerfile for python 3 2018-09-17 19:44:13 -07:00
example.png After running 2to3 2018-08-09 17:56:05 -07:00
example_scenes.py Updated example scenes 2018-08-12 19:06:08 -07:00
extract_scene.py Renamed ANIMATION_DIR to VIDEO_DIR, also replacing 'animations' with 'video' in the path 2018-10-30 12:28:22 -07:00
LICENSE Create LICENSE 2018-03-30 15:50:28 -07:00
manim.py Fix the idle_stream()'s sleep duration and change the stream FPS to 30 2018-11-03 21:05:20 +03:00
README.md Prefix the link to the documentation with https:// . 2018-11-28 19:33:42 +01:00
requirements.txt Reimplented svg rendering using cairo, and changed vmobject color model to allow for gradeints and strokes with opacities. Many errors associated with python 2 to python 3 conversion are likely still present at this point. 2018-08-10 15:12:49 -07:00
stage_scenes.py After running 2to3 2018-08-09 17:56:05 -07:00
stream_starter.py Add a stream lock and an idle state for stream to provide continuous frame flow 2018-11-01 11:23:34 +03:00
tex_template.tex Reduced to a single tex_template file 2018-08-13 15:17:53 -07:00

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
mkdir media
echo "media" > media_dir.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
mkdir media
echo "media" > media_dir.txt
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
mkdir media
echo "media" > media_dir.txt
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.