A community-maintained Python framework for creating mathematical animations.
Revert "Make manim crash when ffmpeg crashes (#546)"
Devin Neal3b56cd9d2181
diff --git a/docs/source/examples/3d.rst b/docs/source/examples/3d.rstindex e68ae17af..5ffddca16 100644--- a/docs/source/examples/3d.rst+++ b/docs/source/examples/3d.rst@@ -78,3 +78,4 @@self.add(axes, curve1)self.set_camera_orientation(phi=80 * DEGREES, theta=-60 * DEGREES)self.wait()+diff --git a/docs/source/installation/linux.rst b/docs/source/installation/linux.rstindex 532cb3937..d3b7c791f 100644--- a/docs/source/installation/linux.rst+++ b/docs/source/installation/linux.rst@@ -11,7 +11,7 @@ The two necessary dependencies are cairo and ffmpeg. LaTeX is stronglyrecommended, as it is necessary to have access to the ``Tex`` and ``MathTex`` classes.Ubuntu/Mint/Debian-******************+*************Before installing anything, make sure that your system is up to date.@@ -42,15 +42,15 @@ To install LaTeX:If you don't have python3-pip installed, install it:.. code-block:: bash-+sudo apt install python3-pip-+.. note:: These instructions are also valid for other Debian-baseddistributions or distributions that use the ``apt`` package manager.Fedora/CentOS/RHEL-******************+*************To install cairo:@@ -116,7 +116,7 @@ To install LaTeX:If you don't have python-pip installed, install it:.. code-block:: bash-+sudo pacman -S python-pipdiff --git a/docs/source/manim_directive.py b/docs/source/manim_directive.pyindex 7f66a374f..7e0fb3cdb 100644--- a/docs/source/manim_directive.py+++ b/docs/source/manim_directive.py@@ -168,14 +168,6 @@ class ManimDirective(Directive):video_dir = os.path.join(media_dir, "videos")output_file = f"{clsname}-{classnamedict[clsname]}"- # Important: note that all scenes are being rendered on the same python- # interpreter. That means that each time we change the config, that- # same config will be used for the next scene. For this reason, we- # have to make sure to restore the original config after each scene.- save_config_code = [- "original_config = copy.deepcopy(config)",- "original_fw_config = copy.deepcopy(file_writer_config)",- ]file_writer_config_code = [f'config["frame_rate"] = {frame_rate}',f'config["pixel_height"] = {pixel_height}',@@ -189,14 +181,6 @@ class ManimDirective(Directive):f'file_writer_config["save_as_gif"] = {save_as_gif}',f'file_writer_config["output_file"] = "{output_file}"',]- file_writer_config_code.append(- 'file_writer_config["write_to_movie"] = '- + ("False" if save_last_frame else "True")- )- restore_config_code = [- "config = original_config",- "file_writer_config = original_fw_config",- ]user_code = self.contentif user_code[0].startswith(">>> "): # check whether block comes from doctest@@ -206,12 +190,9 @@ class ManimDirective(Directive):code = ["from manim import *",- f"logger.info('rendering {clsname}')",- *save_config_code,*file_writer_config_code,*user_code,f"{clsname}().render()",- *restore_config_code,]exec("\n".join(code), globals())diff --git a/manim/constants.py b/manim/constants.pyindex c83b06821..2f13f226e 100644--- a/manim/constants.py+++ b/manim/constants.py@@ -1,4 +1,6 @@-"""Constant definitions."""+"""+Constant definitions.+"""import numpy as npdiff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.pyindex 528791c19..e11647715 100644--- a/manim/scene/scene_file_writer.py+++ b/manim/scene/scene_file_writer.py@@ -544,11 +544,8 @@ class SceneFileWriter(object):if not self.includes_sound:commands.insert(-1, "-an")- try:- subprocess.check_call(commands)- except subprocess.CalledProcessError as exc:- logger.error(f"FFMPEG returned with code {exc.returncode}")- raise exc+ combine_process = subprocess.Popen(commands)+ combine_process.wait()if self.includes_sound:sound_file_path = movie_file_path.replace(@@ -585,12 +582,7 @@ class SceneFileWriter(object):# "-shortest",temp_file_path,]- try:- subprocess.check_call(commands)- except subprocess.CalledProcessError as exc:- logger.error(f"FFMPEG returned with code {exc.returncode}")- raise exc-+ subprocess.call(commands)shutil.move(temp_file_path, movie_file_path)os.remove(sound_file_path)diff --git a/manim/utils/caching.py b/manim/utils/caching.pyindex 9afed9433..6b611b96c 100644--- a/manim/utils/caching.py+++ b/manim/utils/caching.py@@ -36,21 +36,16 @@ def handle_caching_play(func):hash_play = get_hash_from_play_call(self, self.camera, animations, mobjects_on_scene)- if file_writer_config["write_to_movie"]:- if self.file_writer.is_already_cached(hash_play):- logger.info(- f"Animation {self.num_plays} : Using cached data (hash : %(hash_play)s)",- {"hash_play": hash_play},- )- file_writer_config["skip_animations"] = True+ if self.file_writer.is_already_cached(hash_play):+ logger.info(+ f"Animation {self.num_plays} : Using cached data (hash : %(hash_play)s)",+ {"hash_play": hash_play},+ )+ file_writer_config["skip_animations"] = Trueelse:hash_play = "uncached_{:05}".format(self.num_plays)self.animations_hashes.append(hash_play)- if (- not file_writer_config["disable_caching"]- and file_writer_config["write_to_movie"]- ):- self.file_writer.add_partial_movie_file(hash_play)+ self.file_writer.add_partial_movie_file(hash_play)logger.debug("List of the first few animation hashes of the scene: %(h)s",{"h": str(self.animations_hashes[:5])},@@ -89,20 +84,15 @@ def handle_caching_wait(func):hash_wait = get_hash_from_wait_call(self, self.camera, duration, stop_condition, scene.get_mobjects())- if file_writer_config["write_to_movie"]:- if self.file_writer.is_already_cached(hash_wait):- logger.info(- f"Wait {self.num_plays} : Using cached data (hash : {hash_wait})"- )- file_writer_config["skip_animations"] = True+ if self.file_writer.is_already_cached(hash_wait):+ logger.info(+ f"Wait {self.num_plays} : Using cached data (hash : {hash_wait})"+ )+ file_writer_config["skip_animations"] = Trueelse:hash_wait = "uncached_{:05}".format(self.num_plays)self.animations_hashes.append(hash_wait)- if (- not file_writer_config["disable_caching"]- and file_writer_config["write_to_movie"]- ):- self.file_writer.add_partial_movie_file(hash_wait)+ self.file_writer.add_partial_movie_file(hash_wait)logger.debug("List of the first few animation hashes of the scene: %(h)s",{"h": str(self.animations_hashes[:5])},