Skip to content

armgit / manim

Public Imported from GitHub
0

A community-maintained Python framework for creating mathematical animations.

Improved quality of GIFs (#1144)

KingWampy74ce5b7e4a13
diff --git a/manim/scene/scene_file_writer.py b/manim/scene/scene_file_writer.py
index 5b06c5e56..49d69dc00 100644
--- a/manim/scene/scene_file_writer.py
+++ b/manim/scene/scene_file_writer.py
@@ -476,7 +476,11 @@ class SceneFileWriter(object):
self.gif_file_path = str(
add_version_before_extension(self.gif_file_path)
)
- commands += [self.gif_file_path]
+ commands += [
+ "-vf",
+ f"fps={np.clip(config['frame_rate'], 1, 50)},split[s0][s1];[s0]palettegen=stats_mode=diff[p];[s1][p]paletteuse=dither=bayer:bayer_scale=5:diff_mode=rectangle",
+ self.gif_file_path,
+ ]
if not self.includes_sound:
commands.insert(-1, "-an")