From 87d8671995b92fc7ead3f1fc0e557b2ae15102b1 Mon Sep 17 00:00:00 2001 From: Devin Neal Date: Thu, 16 Apr 2020 23:59:22 -0700 Subject: [PATCH] Remove livestreaming option --- README.md | 22 ------------ manim.py | 2 -- manimlib/__init__.py | 13 ++----- manimlib/config.py | 30 +--------------- manimlib/scene/scene.py | 11 ------ manimlib/scene/scene_file_writer.py | 20 +---------- manimlib/stream_starter.py | 53 ----------------------------- 7 files changed, 5 insertions(+), 146 deletions(-) delete mode 100644 manimlib/stream_starter.py diff --git a/README.md b/README.md index 2b12fa6a..62e2adc2 100644 --- a/README.md +++ b/README.md @@ -124,31 +124,9 @@ Documentation is in progress at [eulertour.com/learn/manim](https://www.eulertou ### 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. diff --git a/manim.py b/manim.py index 2f659056..2bebaea6 100755 --- a/manim.py +++ b/manim.py @@ -3,5 +3,3 @@ import manimlib if __name__ == "__main__": manimlib.main() -else: - manimlib.stream_starter.start_livestream() diff --git a/manimlib/__init__.py b/manimlib/__init__.py index 5eb9e228..f4274cb6 100644 --- a/manimlib/__init__.py +++ b/manimlib/__init__.py @@ -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) diff --git a/manimlib/config.py b/manimlib/config.py index 7518d14d..39046120 100644 --- a/manimlib/config.py +++ b/manimlib/config.py @@ -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) diff --git a/manimlib/scene/scene.py b/manimlib/scene/scene.py index 014ea528..e187b2c1 100644 --- a/manimlib/scene/scene.py +++ b/manimlib/scene/scene.py @@ -552,17 +552,6 @@ class Scene(Container): 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 diff --git a/manimlib/scene/scene_file_writer.py b/manimlib/scene/scene_file_writer.py index b67d97f3..ef1586e1 100644 --- a/manimlib/scene/scene_file_writer.py +++ b/manimlib/scene/scene_file_writer.py @@ -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, @@ -171,15 +168,10 @@ class SceneFileWriter(object): 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: @@ -247,22 +239,12 @@ class SceneFileWriter(object): '-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, diff --git a/manimlib/stream_starter.py b/manimlib/stream_starter.py deleted file mode 100644 index 8a77f4ea..00000000 --- a/manimlib/stream_starter.py +++ /dev/null @@ -1,53 +0,0 @@ -from time import sleep -import code -import os -import readline -import subprocess - -from manimlib.scene.scene import Scene -import manimlib.constants - - -def start_livestream(to_twitch=False, twitch_key=None): - class Manim(): - - def __new__(cls): - kwargs = { - "scene_name": manimlib.constants.LIVE_STREAM_NAME, - "open_video_upon_completion": False, - "show_file_in_finder": False, - # By default, write to file - "write_to_movie": True, - "show_last_frame": False, - "save_pngs": False, - # If -t is passed in (for transparent), this will be RGBA - "saved_image_mode": "RGB", - "movie_file_extension": ".mp4", - "quiet": True, - "ignore_waits": False, - "write_all": False, - "name": manimlib.constants.LIVE_STREAM_NAME, - "start_at_animation_number": 0, - "end_at_animation_number": None, - "skip_animations": False, - "camera_config": manimlib.constants.HIGH_QUALITY_CAMERA_CONFIG, - "livestreaming": True, - "to_twitch": to_twitch, - "twitch_key": twitch_key, - } - return Scene(**kwargs) - - if not to_twitch: - FNULL = open(os.devnull, 'w') - subprocess.Popen( - [manimlib.constants.STREAMING_CLIENT, manimlib.constants.STREAMING_URL], - stdout=FNULL, - stderr=FNULL) - sleep(3) - - variables = globals().copy() - variables.update(locals()) - shell = code.InteractiveConsole(variables) - shell.push("manim = Manim()") - shell.push("from manimlib.imports import *") - shell.interact(banner=manimlib.constants.STREAMING_CONSOLE_BANNER)