Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 0 additions & 22 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -124,31 +124,9 @@ Documentation is in progress at [eulertour.com/docs](https://www.eulertour.com/d
### Walkthrough
Todd Zimmerman put together a [tutorial](https://talkingphysics.wordpress.com/2019/01/08/getting-started-animating-with-manim-and-python-3-7/) on getting started with manim, which has been updated to run on Python 3.7.

### Live Streaming
To live stream your animations, simply run manim with the `--livestream` option.

```sh
> python -m manim --livestream
Writing to media/videos/scene/scene/1080p30/LiveStreamTemp.mp4

Manim is now running in streaming mode. Stream animations by passing
them to manim.play(), e.g.
>>> c = Circle()
>>> manim.play(ShowCreation(c))

>>>
```

It is also possible to stream directly to Twitch. To do that simply pass
`--livestream` and `--to-twitch to manim` and specify the stream key with
`--with-key`. Then 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 directory `from_3b1b`, which by and large generate the visuals for 3b1b videos, are copyright 3Blue1Brown.

Expand Down
2 changes: 0 additions & 2 deletions manim.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,3 @@

if __name__ == "__main__":
manimlib.main()
else:
manimlib.stream_starter.start_livestream()
13 changes: 3 additions & 10 deletions manimlib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@
import manimlib.config
import manimlib.constants
import manimlib.extract_scene
import manimlib.stream_starter


def main():
args = manimlib.config.parse_cli()
if not args.livestream:
config = manimlib.config.get_configuration(args)
manimlib.constants.initialize_directories(config)
manimlib.extract_scene.main(config)
else:
manimlib.stream_starter.start_livestream(
to_twitch=args.to_twitch,
twitch_key=args.twitch_key,
)
config = manimlib.config.get_configuration(args)
manimlib.constants.initialize_directories(config)
manimlib.extract_scene.main(config)
30 changes: 1 addition & 29 deletions manimlib/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,35 +129,7 @@ def parse_cli():
"--tex_dir",
help="directory to write tex",
)

# For live streaming
module_location.add_argument(
"--livestream",
action="store_true",
help="Run in streaming mode",
)
parser.add_argument(
"--to-twitch",
action="store_true",
help="Stream to twitch",
)
parser.add_argument(
"--with-key",
dest="twitch_key",
help="Stream key for twitch",
)
args = parser.parse_args()

if args.file is None and not args.livestream:
parser.print_help()
sys.exit(2)
if args.to_twitch and not args.livestream:
print("You must run in streaming mode in order to stream to twitch")
sys.exit(2)
if args.to_twitch and args.twitch_key is None:
print("Specify the twitch stream key with --with-key")
sys.exit(2)
return args
return parser.parse_args()
except argparse.ArgumentError as err:
print(str(err))
sys.exit(2)
Expand Down
11 changes: 0 additions & 11 deletions manimlib/scene/scene.py
Original file line number Diff line number Diff line change
Expand Up @@ -552,17 +552,6 @@ def show_frame(self):
self.update_frame(ignore_skipping=True)
self.get_image().show()

# TODO, this doesn't belong in Scene, but should be
# part of some more specialized subclass optimized
# for livestreaming
def tex(self, latex):
eq = TextMobject(latex)
anims = []
anims.append(Write(eq))
for mobject in self.mobjects:
anims.append(ApplyMethod(mobject.shift, 2 * UP))
self.play(*anims)


class EndSceneEarlyException(Exception):
pass
20 changes: 1 addition & 19 deletions manimlib/scene/scene_file_writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,6 @@ class SceneFileWriter(object):
"save_last_frame": False,
"movie_file_extension": ".mp4",
"gif_file_extension": ".gif",
"livestreaming": False,
"to_twitch": False,
"twitch_key": None,
# Previous output_file_name
# TODO, address this in extract_scene et. al.
"file_name": None,
Expand Down Expand Up @@ -171,15 +168,10 @@ def add_sound(self, sound_file, time=None, gain=None, **kwargs):
def begin_animation(self, allow_write=False):
if self.write_to_movie and allow_write:
self.open_movie_pipe()
if self.livestreaming:
self.stream_lock = False

def end_animation(self, allow_write=False):
if self.write_to_movie and allow_write:
self.close_movie_pipe()
if self.livestreaming:
self.stream_lock = True
thread.start_new_thread(self.idle_stream, ())

def write_frame(self, frame):
if self.write_to_movie:
Expand Down Expand Up @@ -247,22 +239,12 @@ def open_movie_pipe(self):
'-vcodec', 'libx264',
'-pix_fmt', 'yuv420p',
]
if self.livestreaming:
if self.to_twitch:
command += ['-f', 'flv']
command += ['rtmp://live.twitch.tv/app/' + self.twitch_key]
else:
command += ['-f', 'mpegts']
command += [STREAMING_PROTOCOL + '://' + STREAMING_IP + ':' + STREAMING_PORT]
else:
command += [temp_file_path]
command += [temp_file_path]
self.writing_process = subprocess.Popen(command, stdin=subprocess.PIPE)

def close_movie_pipe(self):
self.writing_process.stdin.close()
self.writing_process.wait()
if self.livestreaming:
return True
shutil.move(
self.temp_partial_movie_file_path,
self.partial_movie_file_path,
Expand Down
53 changes: 0 additions & 53 deletions manimlib/stream_starter.py

This file was deleted.