Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Merge branch 'master' into master

Grant Sandersonbfce8b47cdcc
diff --cc manimlib/scene/scene.py
index b3135cf02,241664180..abd5baa7d
--- a/manimlib/scene/scene.py
+++ b/manimlib/scene/scene.py
@@@ -735,16 -793,40 +796,45 @@@ class Scene(Container)
'-loglevel', 'error',
movie_file_path
]
+ if not self.includes_sound:
+ commands.insert(-1, '-an')
- subprocess.call(commands)
++
+ combine_process = subprocess.Popen(commands)
+ combine_process.wait()
+ for pf_path in partial_movie_files:
+ os.remove(pf_path)
os.remove(file_list)
- os.rmdir(partial_movie_file_directory)
- os.rmdir(os.path.join(partial_movie_file_directory, os.path.pardir))
+ print("File ready at {}".format(movie_file_path))
+ if self.includes_sound:
+ sound_file_path = movie_file_path.replace(
+ self.movie_file_extension, ".wav"
+ )
+ # Makes sure sound file length will match video file
+ self.add_audio_segment(AudioSegment.silent(0))
+ self.audio_segment.export(sound_file_path)
+ temp_file_path = movie_file_path.replace(".", "_temp.")
+ commands = commands = [
+ "ffmpeg",
+ "-i", movie_file_path,
+ "-i", sound_file_path,
+ '-y', # overwrite output file if it exists
+ "-c:v", "copy", "-c:a", "aac",
+ '-loglevel', 'error',
+ "-shortest",
+ "-strict", "experimental",
+ temp_file_path,
+ ]
+ subprocess.call(commands)
+ shutil.move(temp_file_path, movie_file_path)
+ # subprocess.call(["rm", self.temp_movie_file_path])
+ subprocess.call(["rm", sound_file_path])
+
+ print("\nAnimation ready at {}\n".format(movie_file_path))
+
+ # 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 = []