From f9a44c9975c454814d2f5cbcd55f1fbcc9048840 Mon Sep 17 00:00:00 2001 From: Grant Sanderson Date: Tue, 10 Dec 2024 19:29:55 -0600 Subject: [PATCH] Make ffmpeg_bin specification a piece of file_writer_config --- manimlib/constants.py | 2 -- manimlib/default_config.yml | 5 +++-- manimlib/scene/scene_file_writer.py | 10 ++++++---- 3 files changed, 9 insertions(+), 8 deletions(-) diff --git a/manimlib/constants.py b/manimlib/constants.py index 20df34ff..32e48dd7 100644 --- a/manimlib/constants.py +++ b/manimlib/constants.py @@ -66,8 +66,6 @@ DEGREES: float = TAU / 360 # when juxtaposed with expressions like 30 * DEGREES RADIANS: float = 1 -FFMPEG_BIN: str = GLOBAL_CONFIG["ffmpeg_bin"] - JOINT_TYPE_MAP: dict = { "no_joint": 0, "auto": 1, diff --git a/manimlib/default_config.yml b/manimlib/default_config.yml index 8f0f598e..ce2ded52 100644 --- a/manimlib/default_config.yml +++ b/manimlib/default_config.yml @@ -49,6 +49,9 @@ file_writer: # easier when working with the broken up scene, which # effectively has cuts at all the places you might want. break_into_partial_movies: False + # What command to use for ffmpeg + ffmpeg_bin: "ffmpeg" + # Parameters to pass into ffmpeg video_codec: "libx264" pixel_format: "yuv420p" saturation: 1.0 @@ -144,7 +147,5 @@ colors: light_pink: "#DC75CD" green_screen: "#00FF00" orange: "#FF862F" -# What command to use for ffmpeg -ffmpeg_bin: "ffmpeg" universal_import_line: "from manimlib import *" ignore_manimlib_modules_on_reload: True diff --git a/manimlib/scene/scene_file_writer.py b/manimlib/scene/scene_file_writer.py index f98d68c8..dcbf5e2f 100644 --- a/manimlib/scene/scene_file_writer.py +++ b/manimlib/scene/scene_file_writer.py @@ -11,7 +11,6 @@ from pydub import AudioSegment from tqdm.auto import tqdm as ProgressDisplay from pathlib import Path -from manimlib.constants import FFMPEG_BIN from manimlib.logger import log from manimlib.mobject.mobject import Mobject from manimlib.utils.file_ops import add_extension_if_not_present @@ -49,6 +48,8 @@ class SceneFileWriter(object): quiet: bool = False, total_frames: int = 0, progress_description_len: int = 40, + # Name of the binary used for ffmpeg + ffmpeg_bin: str = "ffmpeg", video_codec: str = "libx264", pixel_format: str = "yuv420p", saturation: float = 1.0, @@ -70,6 +71,7 @@ class SceneFileWriter(object): self.quiet = quiet self.total_frames = total_frames self.progress_description_len = progress_description_len + self.ffmpeg_bin = ffmpeg_bin self.video_codec = video_codec self.pixel_format = pixel_format self.saturation = saturation @@ -236,7 +238,7 @@ class SceneFileWriter(object): vf_arg += f',eq=saturation={self.saturation}:gamma={self.gamma}' command = [ - FFMPEG_BIN, + self.ffmpeg_bin, '-y', # overwrite output file if it exists '-f', 'rawvideo', '-s', f'{width}x{height}', # size of one frame @@ -358,7 +360,7 @@ class SceneFileWriter(object): movie_file_path = self.get_movie_file_path() commands = [ - FFMPEG_BIN, + self.ffmpeg_bin, '-y', # overwrite output file if it exists '-f', 'concat', '-safe', '0', @@ -385,7 +387,7 @@ class SceneFileWriter(object): ) temp_file_path = stem + "_temp" + ext commands = [ - FFMPEG_BIN, + self.ffmpeg_bin, "-i", movie_file_path, "-i", sound_file_path, '-y', # overwrite output file if it exists