From 3e3e4de5e9d819658e9d9b39556f38d42b65208d Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Wed, 8 Feb 2023 20:09:33 -0800 Subject: [PATCH] Add option for gamma correction to SceneFileWriter --- manimlib/scene/scene_file_writer.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/manimlib/scene/scene_file_writer.py b/manimlib/scene/scene_file_writer.py index 3b5a32bc..53bbb589 100644 --- a/manimlib/scene/scene_file_writer.py +++ b/manimlib/scene/scene_file_writer.py @@ -49,7 +49,8 @@ class SceneFileWriter(object): progress_description_len: int = 40, video_codec: str = "libx264", pixel_format: str = "yuv420p", - saturation: float = 1.7 + saturation: float = 1.7, + gamma: float = 1.2, ): self.scene: Scene = scene self.write_to_movie = write_to_movie @@ -69,6 +70,7 @@ class SceneFileWriter(object): self.video_codec = video_codec self.pixel_format = pixel_format self.saturation = saturation + self.gamma = gamma # State during file writing self.writing_process: sp.Popen | None = None @@ -264,7 +266,7 @@ class SceneFileWriter(object): '-pix_fmt', 'rgba', '-r', str(fps), # frames per second '-i', '-', # The input comes from a pipe - '-vf', f'eq=saturation={self.saturation},vflip', + '-vf', f'vflip,eq=saturation={self.saturation}:gamma={self.gamma}', '-an', # Tells FFMPEG not to expect any audio '-loglevel', 'error', ]